dtr-org / unit-e

A digital currency for a new era of decentralized trust
https://unit-e.io
MIT License
45 stars 15 forks source link

example_test.py is floating #993

Closed cmihai closed 5 years ago

cmihai commented 5 years ago

Describe the bug example_test starts three nodes (0, 1 and 2), connects them, sends manually constructed blocks to node0 via p2p, then connects a P2PInterface to node2, sends a getdata with the block IDs and waits for the blocks to be sent back as a response.

However, the test doesn't guarantee that node2 has received all the blocks at the moment we ask for them. In that case, it will ignore a part of the getdata request, and later send inv messages for the blocks it received with a delay:

019-04-16T11:26:02.525210Z [         net] ProcessGetBlockData: ignoring request from peer=1 for old block that isn't in the main chain
2019-04-16T11:26:02.496000Z TestFramework.mininode (DEBUG): Send message to 127.0.0.1:11010: msg_getdata(inv=[CInv(type=Block hash=9f8de316e181978177846991452eb0ec29250d879c7280d132be2e3e148461fc), CInv(type=Block hash=b1b07f8d2e617caefb0c77765096656e74472536a1d428e6031627e7966ff428), CInv(type=Block hash=dad5534ed7de514d4646a3d57656b6c50956e9e3842c5aefc820af95c1ff3127), CInv(type=Block hash=ccc92ffaff954fefe78119fbeb4a9a87891959809b1d1cd1581136ff9138f8b7), CInv(type=Block hash=92801daf102430228b59cc3e23fd1d68923a69b5a894ffd267d25087d38049c8), CInv(type=Block hash=fec9a1ee8636334df29f1e... (msg truncated)
...
2019-04-16T11:26:02.524000Z TestFramework.mininode (DEBUG): Received message from 127.0.0.1:11010: msg_block(block=CBlock(nVersion=536870912 hashPrevBlock=11653ab821392762827c39963475d435b3a1cbd1144484e375c51d4a43393a1b hashMerkleRoot=5b28f19e4376ff938d1cced7a6aa08d86e0e3f2b2154426bbba44457ad8a200c hash_witness_merkle_root=f480d68abea02433291ffb0c79a4bd95b76a87688d55d43bc8936bcd218bf644 hash_finalizer_commits_merkle_root=0000000000000000000000000000000000000000000000000000000000000000 nTime=Tue Apr 16 13:26:02 2019 nBits=207fffff vtx=[CTransaction(nVersion=65537 vin=[CTxIn(prevout=COutPoint(h... (msg truncated)
2019-04-16T11:26:02.525000Z TestFramework.mininode (DEBUG): Received message from 127.0.0.1:11010: msg_block(block=CBlock(nVersion=1 hashPrevBlock=9f8de316e181978177846991452eb0ec29250d879c7280d132be2e3e148461fc hashMerkleRoot=5c4ffa11ddc9339470ba9035705563300cd0bca769818696ebd9b10ace486827 hash_witness_merkle_root=5c4ffa11ddc9339470ba9035705563300cd0bca769818696ebd9b10ace486827 hash_finalizer_commits_merkle_root=0000000000000000000000000000000000000000000000000000000000000000 nTime=Tue Apr 16 13:26:03 2019 nBits=207fffff vtx=[CTransaction(nVersion=65537 vin=[CTxIn(prevout=COutPoint(hash=0000... (msg truncated)
2019-04-16T11:26:02.525000Z TestFramework.mininode (DEBUG): Received message from 127.0.0.1:11010: msg_block(block=CBlock(nVersion=1 hashPrevBlock=b1b07f8d2e617caefb0c77765096656e74472536a1d428e6031627e7966ff428 hashMerkleRoot=1674058afb3614d3f06678b55a2805bcd1972207b86cee8295aea902d5190db9 hash_witness_merkle_root=1674058afb3614d3f06678b55a2805bcd1972207b86cee8295aea902d5190db9 hash_finalizer_commits_merkle_root=0000000000000000000000000000000000000000000000000000000000000000 nTime=Tue Apr 16 13:26:04 2019 nBits=207fffff vtx=[CTransaction(nVersion=65537 vin=[CTxIn(prevout=COutPoint(hash=0000... (msg truncated)
2019-04-16T11:26:02.525000Z TestFramework.mininode (DEBUG): Received message from 127.0.0.1:11010: msg_block(block=CBlock(nVersion=1 hashPrevBlock=dad5534ed7de514d4646a3d57656b6c50956e9e3842c5aefc820af95c1ff3127 hashMerkleRoot=5486a36c1ea47a970533cf4aa84be7977cdd1524d1d93804e4f19ca50892f85c hash_witness_merkle_root=5486a36c1ea47a970533cf4aa84be7977cdd1524d1d93804e4f19ca50892f85c hash_finalizer_commits_merkle_root=0000000000000000000000000000000000000000000000000000000000000000 nTime=Tue Apr 16 13:26:05 2019 nBits=207fffff vtx=[CTransaction(nVersion=65537 vin=[CTxIn(prevout=COutPoint(hash=0000... (msg truncated)
2019-04-16T11:26:02.525000Z TestFramework.mininode (DEBUG): Received message from 127.0.0.1:11010: msg_block(block=CBlock(nVersion=1 hashPrevBlock=ccc92ffaff954fefe78119fbeb4a9a87891959809b1d1cd1581136ff9138f8b7 hashMerkleRoot=5242de8bf96f660da3672c566f7690ea84a1a5fa470e6bb672bcf62bf4fadab6 hash_witness_merkle_root=5242de8bf96f660da3672c566f7690ea84a1a5fa470e6bb672bcf62bf4fadab6 hash_finalizer_commits_merkle_root=0000000000000000000000000000000000000000000000000000000000000000 nTime=Tue Apr 16 13:26:06 2019 nBits=207fffff vtx=[CTransaction(nVersion=65537 vin=[CTxIn(prevout=COutPoint(hash=0000... (msg truncated)
2019-04-16T11:26:02.526000Z TestFramework.mininode (DEBUG): Received message from 127.0.0.1:11010: msg_inv(inv=[CInv(type=Block hash=fec9a1ee8636334df29f1e2fc4a75c8c227a7bac96f286e9fc73c6d62541fe03)])
2019-04-16T11:26:02.527000Z TestFramework.mininode (DEBUG): Received message from 127.0.0.1:11010: msg_inv(inv=[CInv(type=Block hash=f3257f8241debdcc29f247787e075e0843237d6adb39b9581d4dae2d863d6ce6)])
2019-04-16T11:26:02.528000Z TestFramework.mininode (DEBUG): Received message from 127.0.0.1:11010: msg_inv(inv=[CInv(type=Block hash=1e5e772c4b35f3193613d1005717981ea8a90d9e9ca1ad82162f770d09ce8940)])
2019-04-16T11:26:02.551000Z TestFramework.mininode (DEBUG): Received message from 127.0.0.1:11010: msg_inv(inv=[CInv(type=Block hash=4352852719d0e4cc8d16c88216b813508aa797f2fa19301fa1a8d92a8a809b8a)])
2019-04-16T11:26:07.529000Z TestFramework.utils (ERROR): wait_until() failed. Predicate: (['        wait_until(lambda: sorted(blocks) == sorted(list(self.nodes[2].p2p.block_receive_map.keys())), timeout=5, lock=mininode_lock)\n'], 217)
2019-04-16T11:26:07.529000Z TestFramework (ERROR): Assertion failed

To Reproduce Run the functional tests with high parallelism.