mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-03 09:56:38 -05:00
Merge bitcoin/bitcoin#26651: test: Avoid intermittent timeout in feature_assumevalid.py
fa34e5f3d3
test: Avoid intermittent timeout in feature_assumevalid.py (MarcoFalke) Pull request description: Currently the test will spin up p2p connections in the beginning, then announce the headers to all nodes, but only send the blocks sequentially. This takes a long time, so when getting to the last node, it will have already timed out, while node1 is busy eating blocks. Example: ``` node2 2022-12-06T19:31:35.419291Z [msghand] [net_processing.cpp:5783] [SendMessages] [net] Requesting block 2cfdb317b3b901f79e2d4f96339d0c0dffd8ef2685d324f62ab0e2fa3402430e (1) peer=0 node2 2022-12-06T19:31:35.424784Z [msghand] [net.cpp:2776] [PushMessage] [net] sending getdata (577 bytes) peer=0 [...] node2 2022-12-06T19:41:35.423257Z [msghand] [net_processing.cpp:5729] [SendMessages] Timeout downloading block 2cfdb317b3b901f79e2d4f96339d0c0dffd8ef2685d324f62ab0e2fa3402430e from peer=0, disconnecting node1 2022-12-06T19:41:35.438706Z [msghand] [net_processing.cpp:5783] [SendMessages] [net] Requesting block 6575919043306ed309014d0bd79814b4fab8afaa281e026d8cc3a1c4c2336fbc (1748) peer=0 node2 2022-12-06T19:41:35.521253Z [net] [net.cpp:573] [CloseSocketDisconnect] [net] disconnecting peer=0 node2 2022-12-06T19:41:35.630417Z [net] [net_processing.cpp:1532] [FinalizeNode] [net] Cleared nodestate for peer=0 ``` Fix this by only spinning up the p2p connection right before they are needed. ACKs for top commit: jamesob: ACKfa34e5f3d3
([`jamesob/ackr/26651.1.MarcoFalke.test_avoid_intermittent`](https://github.com/jamesob/bitcoin/tree/ackr/26651.1.MarcoFalke.test_avoid_intermittent)) Tree-SHA512: 7a1b114c07dfa30237c8cd8637dd6646c5c2dc2530c9de61db231738fddc800b620c31dc664237e33d35e951cf161f015fda593162efc9d85c5f68c6e37217d4
This commit is contained in:
commit
9a72119e7e
1 changed files with 7 additions and 11 deletions
|
@ -83,8 +83,6 @@ class AssumeValidTest(BitcoinTestFramework):
|
||||||
break
|
break
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
p2p0 = self.nodes[0].add_p2p_connection(BaseNode())
|
|
||||||
|
|
||||||
# Build the blockchain
|
# Build the blockchain
|
||||||
self.tip = int(self.nodes[0].getbestblockhash(), 16)
|
self.tip = int(self.nodes[0].getbestblockhash(), 16)
|
||||||
self.block_time = self.nodes[0].getblock(self.nodes[0].getbestblockhash())['time'] + 1
|
self.block_time = self.nodes[0].getblock(self.nodes[0].getbestblockhash())['time'] + 1
|
||||||
|
@ -139,28 +137,23 @@ class AssumeValidTest(BitcoinTestFramework):
|
||||||
self.block_time += 1
|
self.block_time += 1
|
||||||
height += 1
|
height += 1
|
||||||
|
|
||||||
self.nodes[0].disconnect_p2ps()
|
|
||||||
|
|
||||||
# Start node1 and node2 with assumevalid so they accept a block with a bad signature.
|
# Start node1 and node2 with assumevalid so they accept a block with a bad signature.
|
||||||
self.start_node(1, extra_args=["-assumevalid=" + hex(block102.sha256)])
|
self.start_node(1, extra_args=["-assumevalid=" + hex(block102.sha256)])
|
||||||
self.start_node(2, extra_args=["-assumevalid=" + hex(block102.sha256)])
|
self.start_node(2, extra_args=["-assumevalid=" + hex(block102.sha256)])
|
||||||
|
|
||||||
p2p0 = self.nodes[0].add_p2p_connection(BaseNode())
|
p2p0 = self.nodes[0].add_p2p_connection(BaseNode())
|
||||||
p2p1 = self.nodes[1].add_p2p_connection(BaseNode())
|
|
||||||
p2p2 = self.nodes[2].add_p2p_connection(BaseNode())
|
|
||||||
|
|
||||||
# send header lists to all three nodes
|
|
||||||
p2p0.send_header_for_blocks(self.blocks[0:2000])
|
p2p0.send_header_for_blocks(self.blocks[0:2000])
|
||||||
p2p0.send_header_for_blocks(self.blocks[2000:])
|
p2p0.send_header_for_blocks(self.blocks[2000:])
|
||||||
p2p1.send_header_for_blocks(self.blocks[0:2000])
|
|
||||||
p2p1.send_header_for_blocks(self.blocks[2000:])
|
|
||||||
p2p2.send_header_for_blocks(self.blocks[0:200])
|
|
||||||
|
|
||||||
# Send blocks to node0. Block 102 will be rejected.
|
# Send blocks to node0. Block 102 will be rejected.
|
||||||
self.send_blocks_until_disconnected(p2p0)
|
self.send_blocks_until_disconnected(p2p0)
|
||||||
self.wait_until(lambda: self.nodes[0].getblockcount() >= COINBASE_MATURITY + 1)
|
self.wait_until(lambda: self.nodes[0].getblockcount() >= COINBASE_MATURITY + 1)
|
||||||
assert_equal(self.nodes[0].getblockcount(), COINBASE_MATURITY + 1)
|
assert_equal(self.nodes[0].getblockcount(), COINBASE_MATURITY + 1)
|
||||||
|
|
||||||
|
p2p1 = self.nodes[1].add_p2p_connection(BaseNode())
|
||||||
|
p2p1.send_header_for_blocks(self.blocks[0:2000])
|
||||||
|
p2p1.send_header_for_blocks(self.blocks[2000:])
|
||||||
|
|
||||||
# Send all blocks to node1. All blocks will be accepted.
|
# Send all blocks to node1. All blocks will be accepted.
|
||||||
for i in range(2202):
|
for i in range(2202):
|
||||||
p2p1.send_message(msg_block(self.blocks[i]))
|
p2p1.send_message(msg_block(self.blocks[i]))
|
||||||
|
@ -168,6 +161,9 @@ class AssumeValidTest(BitcoinTestFramework):
|
||||||
p2p1.sync_with_ping(960)
|
p2p1.sync_with_ping(960)
|
||||||
assert_equal(self.nodes[1].getblock(self.nodes[1].getbestblockhash())['height'], 2202)
|
assert_equal(self.nodes[1].getblock(self.nodes[1].getbestblockhash())['height'], 2202)
|
||||||
|
|
||||||
|
p2p2 = self.nodes[2].add_p2p_connection(BaseNode())
|
||||||
|
p2p2.send_header_for_blocks(self.blocks[0:200])
|
||||||
|
|
||||||
# Send blocks to node2. Block 102 will be rejected.
|
# Send blocks to node2. Block 102 will be rejected.
|
||||||
self.send_blocks_until_disconnected(p2p2)
|
self.send_blocks_until_disconnected(p2p2)
|
||||||
self.wait_until(lambda: self.nodes[2].getblockcount() >= COINBASE_MATURITY + 1)
|
self.wait_until(lambda: self.nodes[2].getblockcount() >= COINBASE_MATURITY + 1)
|
||||||
|
|
Loading…
Add table
Reference in a new issue