mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Partial merge #14700: qa: Avoid race in p2p_invalid_block by waiting for the block request
fa21568208 qa: Avoid race in p2p_invalid_block by waiting for the block request (MarcoFalke) 6c787d340c tests: Make feature_block pass on centos (MarcoFalke) Pull request description: This hopefully fixes #14661, which I believe is caused by a race in `send_blocks_and_test`. By setting `request_block=False` we only effectively check `node.getbestblockhash() != blocks[-1].hash` before returning and checking the debug.log. By setting `request_block=True` (the default) we make sure that we send the block, then sync with a ping before asserting on the debug.log. Even if this patch doesn't fix the issue, it is good cleanup: There is no reason to not wait for the blocks to be requested, since in all these cases the header gives no indication that the block is consensus invalid. So this patch makes the test also a bit stricter and more useful. Unrelated to this, I also include a fix that makes the tests pass on latest CentOS. Tree-SHA512: c7abee3b7dc790a8af6c289159a7751bd962f6fa16c1537e7e21a0a0ef05b9596d1f4eb75319614603c05cb803e021314fa3596508ba443edd03046b25527e0f
This commit is contained in:
parent
701e16ba5b
commit
5bda9afcf6
@ -78,9 +78,9 @@ class InvalidBlockRequestTest(BitcoinTestFramework):
|
||||
block2.vtx.append(tx2)
|
||||
assert_equal(block2.hashMerkleRoot, block2.calc_merkle_root())
|
||||
assert_equal(orig_hash, block2.rehash())
|
||||
assert(block2_orig.vtx != block2.vtx)
|
||||
assert block2_orig.vtx != block2.vtx
|
||||
|
||||
node.p2p.send_blocks_and_test([block2], node, success=False, request_block=False, reject_code=16, reject_reason=b'bad-txns-duplicate')
|
||||
node.p2p.send_blocks_and_test([block2], node, success=False, reject_code=16, reject_reason=b'bad-txns-duplicate')
|
||||
|
||||
# Check transactions for duplicate inputs
|
||||
self.log.info("Test duplicate input block.")
|
||||
@ -90,7 +90,7 @@ class InvalidBlockRequestTest(BitcoinTestFramework):
|
||||
block2_orig.hashMerkleRoot = block2_orig.calc_merkle_root()
|
||||
block2_orig.rehash()
|
||||
block2_orig.solve()
|
||||
node.p2p.send_blocks_and_test([block2_orig], node, success=False, request_block=False, reject_reason='bad-txns-inputs-duplicate')
|
||||
node.p2p.send_blocks_and_test([block2_orig], node, success=False, reject_code=16, reject_reason=b'bad-txns-inputs-duplicate')
|
||||
|
||||
self.log.info("Test very broken block.")
|
||||
|
||||
@ -103,7 +103,7 @@ class InvalidBlockRequestTest(BitcoinTestFramework):
|
||||
block3.rehash()
|
||||
block3.solve()
|
||||
|
||||
node.p2p.send_blocks_and_test([block3], node, success=False, request_block=False, reject_code=16, reject_reason=b'bad-cb-amount')
|
||||
node.p2p.send_blocks_and_test([block3], node, success=False, reject_code=16, reject_reason=b'bad-cb-amount')
|
||||
|
||||
if __name__ == '__main__':
|
||||
InvalidBlockRequestTest().main()
|
||||
|
Loading…
Reference in New Issue
Block a user