Skip to content

Commit 5f5862f

Browse files
committed
Merge bitcoin/bitcoin#30468: test: bump mocktime only after node has received and sent bytes
c322bdd test: bump mocktime after node has received and sent bytes (stratospher) Pull request description: Fixes an intermittent failure for `p2p_v2_misbehaving.py` reported in bitcoin/bitcoin#30420 (comment). A [different error message](https://github.com/bitcoin/bitcoin/blob/262260ce1e919613ba60194a5861b0b0a51dfe01/src/net.cpp#L1970) `"socket no message in first %i seconds"` will be displayed if `m_last_send=0` or if `m_last_recv is 0`. Fix this by: 1. mocktime bump is done after all the bytes are received. (`m_last_recv is not 0 now`) 2. wait until bytes are sent by `TestNode`/`bitcoind` (`m_last_send is not 0 now`) See https://cirrus-ci.com/task/5359619151757312?logs=ci#L3935 for an example failure (I wasn't able to reproduce the intermittent failure locally but I think the fix is logical) ACKs for top commit: maflcko: reACK c322bdd Tree-SHA512: 1c05524c2819041eb2001c2baf2c912d4f812a39347f784f212634e8c53131357a73116a46b4b7542bc7fc8c1370c4d36fc9898a2cbdb40bcee61105123c4a35
2 parents bfce85d + c322bdd commit 5f5862f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

test/functional/p2p_v2_misbehaving.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@ def test_earlykeyresponse(self):
147147
peer1.v2_state.can_data_be_received = True
148148
self.wait_until(lambda: peer1.v2_state.ellswift_ours)
149149
peer1.send_raw_message(peer1.v2_state.ellswift_ours[4:] + peer1.v2_state.sent_garbage)
150-
node0.bumpmocktime(3)
151150
# Ensure that the bytes sent after 4 bytes network magic are actually received.
152151
self.wait_until(lambda: node0.getpeerinfo()[-1]["bytesrecv"] > 4)
152+
self.wait_until(lambda: node0.getpeerinfo()[-1]["bytessent"] > 0)
153153
with node0.assert_debug_log(['V2 handshake timeout peer=0']):
154-
node0.bumpmocktime(1) # `InactivityCheck()` triggers now
154+
node0.bumpmocktime(4) # `InactivityCheck()` triggers now
155155
peer1.wait_for_disconnect(timeout=1)
156156
self.log.info('successful disconnection since modified ellswift was sent as response')
157157

0 commit comments

Comments
 (0)