Skip to content

Commit

Permalink
Merge bitcoin#30468: test: bump mocktime only after node has received…
Browse files Browse the repository at this point in the history
… 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#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
  • Loading branch information
fanquake committed Jul 17, 2024
2 parents bfce85d + c322bdd commit 5f5862f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/functional/p2p_v2_misbehaving.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ def test_earlykeyresponse(self):
peer1.v2_state.can_data_be_received = True
self.wait_until(lambda: peer1.v2_state.ellswift_ours)
peer1.send_raw_message(peer1.v2_state.ellswift_ours[4:] + peer1.v2_state.sent_garbage)
node0.bumpmocktime(3)
# Ensure that the bytes sent after 4 bytes network magic are actually received.
self.wait_until(lambda: node0.getpeerinfo()[-1]["bytesrecv"] > 4)
self.wait_until(lambda: node0.getpeerinfo()[-1]["bytessent"] > 0)
with node0.assert_debug_log(['V2 handshake timeout peer=0']):
node0.bumpmocktime(1) # `InactivityCheck()` triggers now
node0.bumpmocktime(4) # `InactivityCheck()` triggers now
peer1.wait_for_disconnect(timeout=1)
self.log.info('successful disconnection since modified ellswift was sent as response')

Expand Down

0 comments on commit 5f5862f

Please sign in to comment.