mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 10:43:19 -03:00
Merge bitcoin/bitcoin#28489: tests: fix incorrect assumption in v2transport_test
3f4e1bb9ae
tests: fix incorrect assumption in v2transport_test (Pieter Wuille) Pull request description: One part of the current `v2transport_test` introduced in #28196 assumes that if a bit gets modified in a message, failure should instantly be detected after sending that message. This is not correct in case the length descriptor is modified, as that may cause the receiver to need more data first. Fix this by sending more messages until failure actually occurs. Discovered in https://github.com/bitcoin/bitcoin/pull/27495#issuecomment-1719934041. ACKs for top commit: theStack: ACK3f4e1bb9ae
Tree-SHA512: faa90bf91996cbaaef62d764e746cb222eaf6796316b0d0e13709e528750b7c0ef09172f7fecfe814dbb8c136c5259f65ca1ac79318e6768a0bfc4e626a63249
This commit is contained in:
commit
372e7b6510
1 changed files with 11 additions and 3 deletions
|
@ -1357,11 +1357,19 @@ BOOST_AUTO_TEST_CASE(v2transport_test)
|
|||
BOOST_CHECK(!(*ret)[1]);
|
||||
BOOST_CHECK((*ret)[2] && (*ret)[2]->m_type == "tx" && Span{(*ret)[2]->m_recv} == MakeByteSpan(msg_data_2));
|
||||
|
||||
// Then send a message with a bit error, expecting failure.
|
||||
// Then send a message with a bit error, expecting failure. It's possible this failure does
|
||||
// not occur immediately (when the length descriptor was modified), but it should come
|
||||
// eventually, and no messages can be delivered anymore.
|
||||
tester.SendMessage("bad", msg_data_1);
|
||||
tester.Damage();
|
||||
ret = tester.Interact();
|
||||
BOOST_CHECK(!ret);
|
||||
while (true) {
|
||||
ret = tester.Interact();
|
||||
if (!ret) break; // failure
|
||||
BOOST_CHECK(ret->size() == 0); // no message can be delivered
|
||||
// Send another message.
|
||||
auto msg_data_3 = g_insecure_rand_ctx.randbytes<uint8_t>(InsecureRandRange(10000));
|
||||
tester.SendMessage(uint8_t(12), msg_data_3); // getheaders short id
|
||||
}
|
||||
}
|
||||
|
||||
// Normal scenario, with a transport in responder node.
|
||||
|
|
Loading…
Add table
Reference in a new issue