fix: flaky eth/62 test#12096
Conversation
|
Claude finished @alexb5dh's task in 3m 45s —— View job Code Review
Root cause analysis: Each transaction is signed with a fresh random private key ( The fixThe rewrite correctly trades exact-count prediction for semantic-invariant verification: // Before: brittle — one tx's size as oracle for all 512
int sizeOfOneTx = txs[0].GetLength();
int numberOfTxsInOneMsg = Math.Max(TransactionsMessage.MaxPacketSize / sizeOfOneTx, 1);
// ... predict messagesCount, assert exact counts match
// After: robust — verify the contract, not the implementation detail
Assert.That(deliveries.Sum(d => d.Count), Is.EqualTo(txCount)); // no tx lost or doubled
Assert.That(deliveries, Is.All.Matches(
d => d.Count == 1 || d.SerializedSize <= TransactionsMessage.MaxPacketSize)); // packing invariantThis is the right approach. The semantic contract is clear:
The Low — two adjacent tests retain the same class of fragility (pre-existing, not introduced here)
txs[i] = Build.A.Transaction.SignedAndResolved(Build.A.PrivateKey.TestObject).TestObject;
// ...
_session.Received(1).DeliverMessage(Arg.Is<TransactionsMessage>(m => m.Transactions.Count == txCount));The
int sizeOfOneTestTransaction = Build.A.Transaction.SignedAndResolved().TestObject.GetLength(); // deterministic key
// ...
txs[i] = Build.A.Transaction.SignedAndResolved(Build.A.PrivateKey.TestObject).TestObject; // random keysThe These are pre-existing and out of scope for this PR, but worth a follow-up. SummaryThe fix is correct and well-targeted. The new test logic is robust, readable, and correctly captures the production invariant. No issues that block merge. 0 Critical · 0 High · 0 Medium · 1 Low (pre-existing, not introduced here) |
Changes
should_send_single_transaction_even_if_exceed_MaxPacketSizeThe test assumed all 512 transactions had the same serialized size, so it predicted how many would fit per message by measuring only the first one. This was wrong as each tx is signed with a different random key, and ECDSA signatures vary in length by a byte or two (leading zeros get stripped). Test was failing approximately once per 256 runs.
Assertions are changed a bit, but total count and packet size validation are included.
Types of changes
What types of changes does your code introduce?
Testing
Requires testing