Start working on test speeds

This commit is contained in:
Mariano Sorgente 2020-06-18 13:11:51 +09:00 committed by Gene Hoffman
parent 8dbae4cea8
commit c0441391b8
10 changed files with 123 additions and 35 deletions

72
Timings.txt Normal file
View File

@ -0,0 +1,72 @@
cc_wallet total: 290s
87.44s call cc_wallet/test_cc_wallet.py::TestColouredCoins::test_cc_trade_with_multiple_colours
46.40s call cc_wallet/test_cc_wallet.py::TestColouredCoins::test_cc_spend
41.74s call cc_wallet/test_cc_wallet.py::TestColouredCoins::test_create_offer_with_zero_val
39.61s call cc_wallet/test_cc_wallet.py::TestColouredCoins::test_cc_trade
30.13s call cc_wallet/test_cc_wallet.py::TestColouredCoins::test_cc_spend_uncoloured
17.18s call cc_wallet/test_cc_wallet.py::TestColouredCoins::test_generate_zero_val
8.66s call cc_wallet/test_cc_wallet.py::TestColouredCoins::test_get_wallet_for_colour
7.98s call cc_wallet/test_cc_wallet.py::TestColouredCoins::test_colour_creation
1.40s setup cc_wallet/test_cc_wallet.py::TestColouredCoins::test_generate_zero_val
1.16s setup cc_wallet/test_cc_wallet.py::TestColouredCoins::test_create_offer_with_zero_val
1.03s setup cc_wallet/test_cc_wallet.py::TestColouredCoins::test_get_wallet_for_colour
0.92s setup cc_wallet/test_cc_wallet.py::TestColouredCoins::test_colour_creation
0.89s setup cc_wallet/test_cc_wallet.py::TestColouredCoins::test_cc_spend
0.81s setup cc_wallet/test_cc_wallet.py::TestColouredCoins::test_cc_trade_with_multiple_colours
0.81s setup cc_wallet/test_cc_wallet.py::TestColouredCoins::test_cc_spend_uncoloured
0.70s setup cc_wallet/test_cc_wallet.py::TestColouredCoins::test_cc_trade
0.46s teardown cc_wallet/test_cc_wallet.py::TestColouredCoins::test_cc_spend
0.41s teardown cc_wallet/test_cc_wallet.py::TestColouredCoins::test_cc_trade_with_multiple_colours
0.38s teardown cc_wallet/test_cc_wallet.py::TestColouredCoins::test_create_offer_with_zero_val
0.35s teardown cc_wallet/test_cc_wallet.py::TestColouredCoins::test_cc_trade
0.30s teardown cc_wallet/test_cc_wallet.py::TestColouredCoins::test_get_wallet_for_colour
0.27s teardown cc_wallet/test_cc_wallet.py::TestColouredCoins::test_cc_spend_uncoloured
0.23s teardown cc_wallet/test_cc_wallet.py::TestColouredCoins::test_generate_zero_val
0.23s teardown cc_wallet/test_cc_wallet.py::TestColouredCoins::test_colour_creation
Total: 932
85.83s call cc_wallet/test_cc_wallet.py::TestColouredCoins::test_cc_trade_with_multiple_colours
66.47s call test_simulation.py::TestSimulation::test_simulation_1
55.79s call wallet/test_wallet_sync.py::TestWalletSync::test_short_sync_with_transactions_wallet
53.73s call wallet/test_wallet_sync.py::TestWalletSync::test_basic_sync_wallet
50.39s call cc_wallet/test_cc_wallet.py::TestColouredCoins::test_cc_spend
39.32s call cc_wallet/test_cc_wallet.py::TestColouredCoins::test_create_offer_with_zero_val
36.63s call cc_wallet/test_cc_wallet.py::TestColouredCoins::test_cc_trade
29.92s call full_node/test_transactions.py::TestTransactions::test_tx_propagation
28.82s call cc_wallet/test_cc_wallet.py::TestColouredCoins::test_cc_spend_uncoloured
24.34s call full_node/test_node_load.py::TestNodeLoad::test_unfinished_blocks_load
21.74s call wallet/test_wallet_sync.py::TestWalletSync::test_fast_sync_wallet
20.64s call full_node/test_node_load.py::TestNodeLoad::test_blocks_load
19.80s call cc_wallet/test_cc_wallet.py::TestColouredCoins::test_generate_zero_val
16.53s call full_node/test_full_node.py::TestFullNodeProtocol::test_respond_unfinished
16.52s call rpc/test_farmer_harvester_rpc.py::TestRpc::test1
16.25s call util/test_streamable.py::TestStreamable::test_json
15.48s call full_node/test_block_store.py::TestBlockStore::test_deadlock
15.19s call wallet/test_wallet.py::TestWalletSimulator::test_wallet_make_transaction
15.17s call wallet/test_wallet.py::TestWalletSimulator::test_wallet_make_transaction_with_fee
14.16s call full_node/test_full_sync.py::TestFullSync::test_basic_sync
11.94s call full_node/test_transactions.py::TestTransactions::test_mempool_tx_sync
11.76s call wallet/test_wallet.py::TestWalletSimulator::test_wallet_coinbase_reorg
10.04s call wallet/test_wallet.py::TestWalletSimulator::test_wallet_send_to_three_peers
9.68s call wallet/test_wallet.py::TestWalletSimulator::test_wallet_make_transaction_hop
8.66s setup rpc/test_farmer_harvester_rpc.py::TestRpc::test1
8.36s call cc_wallet/test_cc_wallet.py::TestColouredCoins::test_colour_creation
7.68s call full_node/test_full_node.py::TestFullNodeProtocol::test_new_transaction
7.37s call cc_wallet/test_cc_wallet.py::TestColouredCoins::test_get_wallet_for_colour
6.71s call full_node/test_full_node.py::TestFullNodeProtocol::test_new_pot
6.62s call full_node/test_full_sync.py::TestFullSync::test_short_sync
5.97s call rpc/test_full_node_rpc.py::TestRpc::test1
5.25s call full_node/test_full_node.py::TestFullNodeProtocol::test_new_unfinished
4.78s call wallet/test_wallet.py::TestWalletSimulator::test_wallet_coinbase
4.74s call full_node/test_transactions.py::TestTransactions::test_wallet_coinbase
4.51s call full_node/test_blockchain_transactions.py::TestBlockchainTransactions::test_assert_time_exceeds
4.22s call full_node/test_mempool.py::TestMempool::test_coinbase_freeze
4.01s teardown test_simulation.py::TestSimulation::test_simulation_1
3.93s call wallet/test_wallet_sync.py::TestWalletSync::test_short_sync_wallet
3.86s call full_node/test_blockchain_transactions.py::TestBlockchainTransactions::test_validate_blockchain_spend_reorg_since_genesis
3.84s teardown full_node/test_full_sync.py::TestFullSync::test_basic_sync
3.55s teardown rpc/test_farmer_harvester_rpc.py::TestRpc::test1
3.48s call full_node/test_mempool.py::TestMempool::test_assert_time_exceeds_both_cases
3.41s call full_node/test_blockchain_transactions.py::TestBlockchainTransactions::test_validate_blockchain_with_reorg_double_spend
3.19s setup test_simulation.py::TestSimulation::test_simulation_1

View File

@ -74,7 +74,7 @@ class BlockTools:
# Can't go much lower than 18, since plots start having no solutions
k: uint8 = uint8(18)
# Uses many plots for testing, in order to guarantee proofs of space at every height
num_plots = 30
num_plots = 20
# Use the empty string as the seed for the private key
self.keychain = Keychain("testing", True)

View File

@ -126,7 +126,7 @@ class TestBlockchainTransactions:
@pytest.mark.asyncio
async def test_validate_blockchain_with_double_spend(self, two_nodes):
num_blocks = 10
num_blocks = 5
wallet_a = WalletTool()
coinbase_puzzlehash = wallet_a.get_new_puzzlehash()
wallet_receiver = WalletTool()
@ -156,12 +156,12 @@ class TestBlockchainTransactions:
program = best_solution_program(block_spendbundle)
aggsig = block_spendbundle.aggregated_signature
dic_h = {11: (program, aggsig)}
dic_h = {(num_blocks + 1): (program, aggsig)}
new_blocks = bt.get_consecutive_blocks(
test_constants, 1, blocks, 10, b"", coinbase_puzzlehash, dic_h
)
next_block = new_blocks[11]
next_block = new_blocks[num_blocks + 1]
error = await full_node_1.blockchain._validate_transactions(
next_block, next_block.header.data.fees_coin.amount
)
@ -200,12 +200,12 @@ class TestBlockchainTransactions:
program = best_solution_program(block_spendbundle)
aggsig = block_spendbundle.aggregated_signature
dic_h = {11: (program, aggsig)}
dic_h = {(num_blocks + 1): (program, aggsig)}
new_blocks = bt.get_consecutive_blocks(
test_constants, 1, blocks, 10, b"", coinbase_puzzlehash, dic_h
)
next_block = new_blocks[11]
next_block = new_blocks[(num_blocks + 1)]
error = await full_node_1.blockchain._validate_transactions(
next_block, next_block.header.data.fees_coin.amount
)

View File

@ -200,7 +200,7 @@ class TestCoinStore:
@pytest.mark.asyncio
async def test_get_puzzle_hash(self):
num_blocks = 20
num_blocks = 10
blocks = bt.get_consecutive_blocks(test_constants, num_blocks, [], 9)
db_path = Path("blockchain_test.db")
if db_path.exists():

View File

@ -57,12 +57,7 @@ async def two_nodes():
yield _
@pytest.fixture(scope="module")
async def wallet_blocks(two_nodes):
"""
Sets up the node with 10 blocks, and returns a payer and payee wallet.
"""
num_blocks = 5
async def wb(num_blocks, two_nodes):
full_node_1, _, _, _ = two_nodes
wallet_a = WalletTool()
coinbase_puzzlehash = wallet_a.get_new_puzzlehash()
@ -77,6 +72,19 @@ async def wallet_blocks(two_nodes):
return wallet_a, wallet_receiver, blocks
@pytest.fixture(scope="module")
async def wallet_blocks(two_nodes):
"""
Sets up the node with 3 blocks, and returns a payer and payee wallet.
"""
return await wb(3, two_nodes)
@pytest.fixture(scope="module")
async def wallet_blocks_five(two_nodes):
return await wb(5, two_nodes)
class TestFullNodeProtocol:
@pytest.mark.asyncio
async def test_new_tip(self, two_nodes, wallet_blocks):
@ -93,19 +101,19 @@ class TestFullNodeProtocol:
assert len(msgs_1) == 1
assert msgs_1[0].message.data == fnp.RequestBlock(
uint32(5), blocks[-1].header_hash
uint32(3), blocks[-1].header_hash
)
new_tip_2 = fnp.NewTip(
blocks[3].height, blocks[3].weight, blocks[3].header_hash
blocks[2].height, blocks[2].weight, blocks[2].header_hash
)
msgs_2 = [x async for x in full_node_1.new_tip(new_tip_2)]
assert len(msgs_2) == 0
@pytest.mark.asyncio
async def test_new_transaction(self, two_nodes, wallet_blocks):
async def test_new_transaction(self, two_nodes, wallet_blocks_five):
full_node_1, full_node_2, server_1, server_2 = two_nodes
wallet_a, wallet_receiver, blocks = wallet_blocks
wallet_a, wallet_receiver, blocks = wallet_blocks_five
conditions_dict: Dict = {ConditionOpcode.CREATE_COIN: []}
# Mempool has capacity of 100, make 110 unspents that we can use
@ -209,9 +217,9 @@ class TestFullNodeProtocol:
[_ async for _ in full_node_1.respond_block(fnp.RespondBlock(blocks_new[-1]))]
@pytest.mark.asyncio
async def test_request_respond_transaction(self, two_nodes, wallet_blocks):
async def test_request_respond_transaction(self, two_nodes, wallet_blocks_five):
full_node_1, full_node_2, server_1, server_2 = two_nodes
wallet_a, wallet_receiver, blocks = wallet_blocks
wallet_a, wallet_receiver, blocks = wallet_blocks_five
tx_id = token_bytes(32)
request_transaction = fnp.RequestTransaction(tx_id)
@ -483,7 +491,7 @@ class TestFullNodeProtocol:
blocks_new = bt.get_consecutive_blocks(
test_constants,
10,
1,
blocks_list[:],
4,
reward_puzzlehash=coinbase_puzzlehash,

View File

@ -39,7 +39,7 @@ class TestTransactions:
@pytest.mark.asyncio
async def test_wallet_coinbase(self, wallet_node):
num_blocks = 10
num_blocks = 5
full_nodes, wallets = wallet_node
full_node_1, server_1 = full_nodes[0]
wallet_node, server_2 = wallets[0]
@ -61,7 +61,7 @@ class TestTransactions:
@pytest.mark.asyncio
async def test_tx_propagation(self, three_nodes_two_wallets):
num_blocks = 10
num_blocks = 5
full_nodes, wallets = three_nodes_two_wallets
wallet_0, wallet_server_0 = wallets[0]
@ -138,7 +138,7 @@ class TestTransactions:
@pytest.mark.asyncio
async def test_mempool_tx_sync(self, three_nodes_two_wallets):
num_blocks = 10
num_blocks = 5
full_nodes, wallets = three_nodes_two_wallets
wallet_0, wallet_server_0 = wallets[0]

View File

@ -24,7 +24,7 @@ class TestRpc:
@pytest.mark.asyncio
async def test1(self, two_nodes):
num_blocks = 10
num_blocks = 5
test_rpc_port = uint16(21522)
full_node_1, full_node_2, server_1, server_2 = two_nodes
blocks = bt.get_consecutive_blocks(test_constants, num_blocks, [], 10)

View File

@ -53,7 +53,14 @@ async def _teardown_nodes(node_aiters: List) -> None:
pass
async def setup_full_node(db_name, port, introducer_port=None, simulator=False, dic={}):
async def setup_full_node(
db_name,
port,
introducer_port=None,
simulator=False,
send_uncompact_interval=30,
dic={},
):
test_constants_copy = test_constants.copy()
for k in dic.keys():
test_constants_copy[k] = dic[k]
@ -64,7 +71,7 @@ async def setup_full_node(db_name, port, introducer_port=None, simulator=False,
config = load_config(bt.root_path, "config.yaml", "full_node")
config["database_path"] = db_name
config["send_uncompact_interval"] = 30
config["send_uncompact_interval"] = send_uncompact_interval
periodic_introducer_poll = None
if introducer_port is not None:
periodic_introducer_poll = (
@ -453,8 +460,8 @@ async def setup_full_system(dic={}):
setup_farmer(21235, 21237, dic),
setup_timelord(21236, 21237, False, dic),
setup_vdf_clients(8000),
setup_full_node("blockchain_test.db", 21237, 21233, False, dic),
setup_full_node("blockchain_test_2.db", 21238, 21233, False, dic),
setup_full_node("blockchain_test.db", 21237, 21233, False, 10, dic),
setup_full_node("blockchain_test_2.db", 21238, 21233, False, 10, dic),
setup_timelord(21239, 21238, True, dic),
setup_vdf_clients(7999),
]

View File

@ -35,14 +35,15 @@ class TestSimulation:
start = time.time()
# Use node2 to test node communication, since only node1 extends the chain.
while time.time() - start < 100:
if max([h.height for h in node2.blockchain.get_current_tips()]) > 10:
if max([h.height for h in node2.blockchain.get_current_tips()]) > 7:
break
await asyncio.sleep(1)
if max([h.height for h in node2.blockchain.get_current_tips()]) <= 10:
raise Exception("Failed: could not get 10 blocks.")
if max([h.height for h in node2.blockchain.get_current_tips()]) <= 7:
raise Exception("Failed: could not get 7 blocks.")
# Wait additional 2 minutes to get a compact block.
start = time.time()
while time.time() - start < 120:
max_height = node1.blockchain.lca_block.height
for h in range(1, max_height):

View File

@ -46,7 +46,7 @@ class TestWalletSimulator:
@pytest.mark.asyncio
async def test_wallet_coinbase(self, wallet_node):
num_blocks = 10
num_blocks = 5
full_nodes, wallets = wallet_node
full_node_1, server_1 = full_nodes[0]
wallet_node, server_2 = wallets[0]
@ -68,7 +68,7 @@ class TestWalletSimulator:
@pytest.mark.asyncio
async def test_wallet_make_transaction(self, two_wallet_nodes):
num_blocks = 10
num_blocks = 5
full_nodes, wallets = two_wallet_nodes
full_node_1, server_1 = full_nodes[0]
wallet_node, server_2 = wallets[0]
@ -127,7 +127,7 @@ class TestWalletSimulator:
@pytest.mark.asyncio
async def test_wallet_coinbase_reorg(self, wallet_node):
num_blocks = 10
num_blocks = 5
full_nodes, wallets = wallet_node
full_node_1, server_1 = full_nodes[0]
wallet_node, server_2 = wallets[0]
@ -324,7 +324,7 @@ class TestWalletSimulator:
@pytest.mark.asyncio
async def test_wallet_make_transaction_with_fee(self, two_wallet_nodes):
num_blocks = 10
num_blocks = 5
full_nodes, wallets = two_wallet_nodes
full_node_1, server_1 = full_nodes[0]
wallet_node, server_2 = wallets[0]