Skip to content

Commit b182899

Browse files
committed
Fix timing issue in tests
1 parent 11f38d3 commit b182899

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/herder/test/HerderTests.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5068,7 +5068,9 @@ herderExternalizesValuesWithProtocol(uint32_t version,
50685068
REQUIRE(lcl == currentCLedger());
50695069

50705070
waitForAB(fewLedgers, false);
5071-
REQUIRE(currentALedger() == nextLedger);
5071+
// waitForAB stops once A reaches nextLedger, but A may close one
5072+
// more ledger before crankUntil's periodic check observes it
5073+
REQUIRE(currentALedger() >= nextLedger);
50725074
// C is at most a ledger behind
50735075
REQUIRE(currentCLedger() >= nextLedger - 1);
50745076
}

src/overlay/test/TCPPeerTests.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,13 @@ TEST_CASE("TCPPeer read malformed messages", "[overlay][tcppeer]")
159159

160160
auto const& msgRead =
161161
n1->getOverlayManager().getOverlayMetrics().mMessageRead;
162+
163+
// crankUntilAuthenticated returns as soon as both peers reach GOT_AUTH,
164+
// but n0 still sends SEND_MORE_EXTENDED and GET_SCP_STATE right after
165+
// auth. Wait for p1 to read those (HELLO, AUTH, plus the two control
166+
// messages = 4) so the baseline snapshot below is stable.
167+
s->crankUntil([&]() { return msgRead.count() >= 4; },
168+
std::chrono::seconds(10), false);
162169
auto msgReadPrev = msgRead.count();
163170

164171
auto msg = makeStellarMessage(1);

0 commit comments

Comments
 (0)