Skip to content

Commit

Permalink
Add overlay test to check that Floodgate::updateRecord prevents re-br…
Browse files Browse the repository at this point in the history
…oadcast
  • Loading branch information
jonjove committed Mar 25, 2020
1 parent 430f849 commit e8ca927
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/overlay/test/OverlayManagerTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,24 +245,30 @@ class OverlayManagerTests
auto c = TestAccount{*app, getAccount("c")};
auto d = TestAccount{*app, getAccount("d")};

StellarMessage AtoC = a.tx({payment(b, 10)})->toStellarMessage();
StellarMessage AtoB = a.tx({payment(b, 10)})->toStellarMessage();
auto i = 0;
for (auto p : pm.mOutboundPeers.mAuthenticated)
{
if (i++ == 2)
{
pm.recvFloodedMsg(AtoC, p.second);
pm.recvFloodedMsg(AtoB, p.second);
}
}
pm.broadcastMessage(AtoC);
pm.broadcastMessage(AtoB);
std::vector<int> expected{1, 1, 0, 1, 1};
REQUIRE(sentCounts(pm) == expected);
pm.broadcastMessage(AtoC);
pm.broadcastMessage(AtoB);
REQUIRE(sentCounts(pm) == expected);
StellarMessage CtoD = c.tx({payment(d, 10)})->toStellarMessage();
pm.broadcastMessage(CtoD);
std::vector<int> expectedFinal{2, 2, 1, 2, 2};
REQUIRE(sentCounts(pm) == expectedFinal);

// Test that we updating a flood record actually prevents re-broadcast
StellarMessage AtoC = a.tx({payment(c, 10)})->toStellarMessage();
pm.updateFloodRecord(AtoB, AtoC);
pm.broadcastMessage(AtoC);
REQUIRE(sentCounts(pm) == expectedFinal);
}
};

Expand Down

0 comments on commit e8ca927

Please sign in to comment.