Skip to content

Commit c9e14a1

Browse files
bboston7marta-lokhova
authored andcommitted
Copilot test suggestions
1 parent 0cb29ab commit c9e14a1

1 file changed

Lines changed: 30 additions & 11 deletions

File tree

src/scp/test/SCPTests.cpp

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@ class TestSCP : public SCPDriver
4343
uint32_t mIncrementBallotTimeoutMS = 1000;
4444
uint32_t mInitialNominationTimeoutMS = 1000;
4545
uint32_t mIncrementNominationTimeoutMS = 1000;
46+
bool const mProtocolAllowsEmptyTxSetValues;
4647

4748
TestSCP(NodeID const& nodeID, SCPQuorumSet const& qSetLocal,
48-
bool isValidator = true)
49+
bool isValidator = true, bool protocolAllowsEmptyTxSetValues = true)
4950
: mSCP(*this, nodeID, isValidator, qSetLocal)
51+
, mProtocolAllowsEmptyTxSetValues(protocolAllowsEmptyTxSetValues)
5052
{
5153
mPriorityLookup = [&](NodeID const& n) {
5254
return (n == mSCP.getLocalNodeID()) ? 1000 : 1;
@@ -163,13 +165,17 @@ class TestSCP : public SCPDriver
163165
bool
164166
isParallelTxSetDownloadEnabled() const override
165167
{
166-
return true;
168+
// Leave unimplemented. A node's parallel downloading setting only
169+
// affects higher level systems (such as PendingEnvelopes).
170+
// NominationProtocol and BallotProtocol only reason about whether the
171+
// protocol supports empty-tx-set values
172+
releaseAssert(false);
167173
}
168174

169175
bool
170176
protocolAllowsEmptyTxSetValues() const override
171177
{
172-
return true;
178+
return mProtocolAllowsEmptyTxSetValues;
173179
}
174180

175181
void
@@ -859,7 +865,9 @@ TEST_CASE("ballot protocol core5", "[scp][ballotprotocol]")
859865

860866
uint256 qSetHash = sha256(xdr::xdr_to_opaque(qSet));
861867

862-
TestSCP scp(v0SecretKey.getPublicKey(), qSet);
868+
bool const protocolAllowsEmptyTxSetValues = GENERATE(false, true);
869+
TestSCP scp(v0SecretKey.getPublicKey(), qSet, /*isValidator*/ true,
870+
protocolAllowsEmptyTxSetValues);
863871

864872
auto test = [&](TestSCP& scp) {
865873
scp.storeQuorumSet(std::make_shared<SCPQuorumSet>(qSet));
@@ -2649,7 +2657,8 @@ TEST_CASE("ballot protocol core5", "[scp][ballotprotocol]")
26492657
SECTION("non validator watching the network")
26502658
{
26512659
SIMULATION_CREATE_NODE(NV);
2652-
TestSCP scpNV(vNVSecretKey.getPublicKey(), qSet, false);
2660+
TestSCP scpNV(vNVSecretKey.getPublicKey(), qSet, false,
2661+
protocolAllowsEmptyTxSetValues);
26532662
scpNV.storeQuorumSet(std::make_shared<SCPQuorumSet>(qSet));
26542663
uint256 qSetHashNV = scpNV.mSCP.getLocalNode()->getQuorumSetHash();
26552664

@@ -2678,7 +2687,8 @@ TEST_CASE("ballot protocol core5", "[scp][ballotprotocol]")
26782687

26792688
SECTION("restore ballot protocol")
26802689
{
2681-
TestSCP scp2(v0SecretKey.getPublicKey(), qSet);
2690+
TestSCP scp2(v0SecretKey.getPublicKey(), qSet, /*isValidator*/ true,
2691+
protocolAllowsEmptyTxSetValues);
26822692
scp2.storeQuorumSet(std::make_shared<SCPQuorumSet>(qSet));
26832693
SCPBallot b(2, xValue);
26842694
SECTION("prepare")
@@ -2723,7 +2733,9 @@ TEST_CASE("ballot protocol core3", "[scp][ballotprotocol]")
27232733

27242734
uint256 qSetHash = sha256(xdr::xdr_to_opaque(qSet));
27252735

2726-
TestSCP scp(v0SecretKey.getPublicKey(), qSet);
2736+
bool const protocolAllowsEmptyTxSetValues = GENERATE(false, true);
2737+
TestSCP scp(v0SecretKey.getPublicKey(), qSet, /*isValidator*/ true,
2738+
protocolAllowsEmptyTxSetValues);
27272739

27282740
auto test = [&](TestSCP& scp) {
27292741
scp.storeQuorumSet(std::make_shared<SCPQuorumSet>(qSet));
@@ -2870,7 +2882,9 @@ TEST_CASE("ballot protocol core3", "[scp][ballotprotocol]")
28702882
SECTION("node without self - quorum timeout")
28712883
{
28722884
SIMULATION_CREATE_NODE(NodeNS);
2873-
TestSCP scpNNS(vNodeNSSecretKey.getPublicKey(), qSet);
2885+
TestSCP scpNNS(vNodeNSSecretKey.getPublicKey(), qSet,
2886+
/*isValidator*/ true,
2887+
protocolAllowsEmptyTxSetValues);
28742888
scpNNS.storeQuorumSet(std::make_shared<SCPQuorumSet>(qSet));
28752889
uint256 qSetHashNodeNS =
28762890
scpNNS.mSCP.getLocalNode()->getQuorumSetHash();
@@ -2927,9 +2941,11 @@ TEST_CASE("nomination tests core5", "[scp][nominationprotocol]")
29272941
expectedLeaders.end()));
29282942
};
29292943

2944+
bool const protocolAllowsEmptyTxSetValues = GENERATE(false, true);
29302945
SECTION("nomination - v0 is top")
29312946
{
2932-
TestSCP scp(v0SecretKey.getPublicKey(), qSet);
2947+
TestSCP scp(v0SecretKey.getPublicKey(), qSet, /*isValidator*/ true,
2948+
protocolAllowsEmptyTxSetValues);
29332949

29342950
auto test = [&](TestSCP& scp) {
29352951
uint256 qSetHash0 = scp.mSCP.getLocalNode()->getQuorumSetHash();
@@ -3043,7 +3059,9 @@ TEST_CASE("nomination tests core5", "[scp][nominationprotocol]")
30433059
}
30443060
SECTION("nomination - restored state")
30453061
{
3046-
TestSCP scp2(v0SecretKey.getPublicKey(), qSet);
3062+
TestSCP scp2(v0SecretKey.getPublicKey(), qSet,
3063+
/*isValidator*/ true,
3064+
protocolAllowsEmptyTxSetValues);
30473065
scp2.storeQuorumSet(
30483066
std::make_shared<SCPQuorumSet>(qSet));
30493067

@@ -3280,7 +3298,8 @@ TEST_CASE("nomination tests core5", "[scp][nominationprotocol]")
32803298
}
32813299
SECTION("v1 is top node")
32823300
{
3283-
TestSCP scp(v0SecretKey.getPublicKey(), qSet);
3301+
TestSCP scp(v0SecretKey.getPublicKey(), qSet, /*isValidator*/ true,
3302+
protocolAllowsEmptyTxSetValues);
32843303

32853304
auto test = [&](TestSCP& scp) {
32863305
uint256 qSetHash0 = scp.mSCP.getLocalNode()->getQuorumSetHash();

0 commit comments

Comments
 (0)