Skip to content

Commit a3bf440

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

2 files changed

Lines changed: 11 additions & 7 deletions

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: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ TEST_CASE("TCPPeer read malformed messages", "[overlay][tcppeer]")
133133
// Slow down the main thread to delay drops
134134
cfg.ARTIFICIALLY_SLEEP_MAIN_THREAD_FOR_TESTING =
135135
std::chrono::milliseconds(300);
136+
// Don't run SCP: this test counts messages received by each
137+
// peer, and SCP traffic between the nodes would pollute the
138+
// counts nondeterministically
139+
cfg.FORCE_SCP = false;
136140
return cfg;
137141
});
138142

@@ -157,9 +161,9 @@ TEST_CASE("TCPPeer read malformed messages", "[overlay][tcppeer]")
157161
n0->getOverlayManager().getOverlayMetrics().mRecvErrorTimer;
158162
auto p0recvErrorCount = p0recvError.count();
159163

160-
auto const& msgRead =
161-
n1->getOverlayManager().getOverlayMetrics().mMessageRead;
162-
auto msgReadPrev = msgRead.count();
164+
auto const& recvTx =
165+
n1->getOverlayManager().getOverlayMetrics().mRecvTransactionTimer;
166+
auto recvTxPrev = recvTx.count();
163167

164168
auto msg = makeStellarMessage(1);
165169

@@ -173,9 +177,7 @@ TEST_CASE("TCPPeer read malformed messages", "[overlay][tcppeer]")
173177
{
174178
// p0 received ERROR from p1
175179
REQUIRE(p0recvErrorCount + 1 == p0recvError.count());
176-
// p1 did not read the next message in the socket after receiving a
177-
// malformed message
178-
REQUIRE(msgReadPrev + 1 == msgRead.count());
180+
REQUIRE(recvTx.count() == recvTxPrev);
179181
}
180182
};
181183

0 commit comments

Comments
 (0)