Skip to content

Commit b98b34d

Browse files
committed
Fix spurious failure in the unsupported_message test in p2p
1 parent 340d985 commit b98b34d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

p2p/src/tests/unsupported_message.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,12 @@ async fn unsupported_message_impl(seed: Seed, make_msg_too_big: bool) {
120120
);
121121

122122
let msg_data = if make_msg_too_big {
123-
gen_random_bytes(&mut rng, max_message_size, max_message_size_for_peer)
123+
// Note: the max bytes count we can generate here is max_message_size_for_peer minus
124+
// the encoding overhead, which is 1 for the TestMessage's enum discriminant plus
125+
// the encoded length of the byte vector.
126+
// Since we don't need the exact maximum sizes in this test, we just subtract some number
127+
// that should be enough to cover any possible overhead.
128+
gen_random_bytes(&mut rng, max_message_size, max_message_size_for_peer - 10)
124129
} else {
125130
gen_random_bytes(&mut rng, 1, max_message_size / 2)
126131
};

0 commit comments

Comments
 (0)