Skip to content

Commit 372e7b6

Browse files
committed
Merge bitcoin/bitcoin#28489: tests: fix incorrect assumption in v2transport_test
3f4e1bb 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 bitcoin/bitcoin#27495 (comment). ACKs for top commit: theStack: ACK 3f4e1bb Tree-SHA512: faa90bf91996cbaaef62d764e746cb222eaf6796316b0d0e13709e528750b7c0ef09172f7fecfe814dbb8c136c5259f65ca1ac79318e6768a0bfc4e626a63249
2 parents 5c7cdda + 3f4e1bb commit 372e7b6

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/test/net_tests.cpp

+11-3
Original file line numberDiff line numberDiff line change
@@ -1357,11 +1357,19 @@ BOOST_AUTO_TEST_CASE(v2transport_test)
13571357
BOOST_CHECK(!(*ret)[1]);
13581358
BOOST_CHECK((*ret)[2] && (*ret)[2]->m_type == "tx" && Span{(*ret)[2]->m_recv} == MakeByteSpan(msg_data_2));
13591359

1360-
// Then send a message with a bit error, expecting failure.
1360+
// Then send a message with a bit error, expecting failure. It's possible this failure does
1361+
// not occur immediately (when the length descriptor was modified), but it should come
1362+
// eventually, and no messages can be delivered anymore.
13611363
tester.SendMessage("bad", msg_data_1);
13621364
tester.Damage();
1363-
ret = tester.Interact();
1364-
BOOST_CHECK(!ret);
1365+
while (true) {
1366+
ret = tester.Interact();
1367+
if (!ret) break; // failure
1368+
BOOST_CHECK(ret->size() == 0); // no message can be delivered
1369+
// Send another message.
1370+
auto msg_data_3 = g_insecure_rand_ctx.randbytes<uint8_t>(InsecureRandRange(10000));
1371+
tester.SendMessage(uint8_t(12), msg_data_3); // getheaders short id
1372+
}
13651373
}
13661374

13671375
// Normal scenario, with a transport in responder node.

0 commit comments

Comments
 (0)