Skip to content

Commit

Permalink
SCP: update tests
Browse files Browse the repository at this point in the history
additional tests setting p'
  • Loading branch information
MonsieurNicolas committed Nov 18, 2015
1 parent 73b5238 commit 443b4a4
Showing 1 changed file with 194 additions and 11 deletions.
205 changes: 194 additions & 11 deletions src/scp/SCPTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,14 @@ TEST_CASE("ballot protocol core5", "[scp][ballotprotocol]")
verifyConfirm(scp.mEnvs[6], v0SecretKey,
qSetHash0, 0, 3, A3, 2, 2);
}
SECTION("v-blocking prepared A3+B3")
{
recvVBlocking(makePrepareGen(qSetHash, A3, &B3,
2, 2, &A3));
REQUIRE(scp.mEnvs.size() == 7);
verifyConfirm(scp.mEnvs[6], v0SecretKey,
qSetHash0, 0, 3, A3, 2, 2);
}
SECTION("v-blocking confirm A3")
{
recvVBlocking(
Expand Down Expand Up @@ -1027,12 +1035,66 @@ TEST_CASE("ballot protocol core5", "[scp][ballotprotocol]")
}
}
}
SECTION("get conflicting prepared B2")
SECTION("get conflicting prepared B")
{
recvVBlocking(makePrepareGen(qSetHash, B2, &B2));
SECTION("same counter")
{
recvVBlocking(makePrepareGen(qSetHash, B2, &B2));
REQUIRE(scp.mEnvs.size() == 6);
verifyPrepare(scp.mEnvs[5], v0SecretKey, qSetHash0,
0, A2, &B2, 0, 2, &A2);
}
SECTION("higher counter")
{
recvVBlocking(
makePrepareGen(qSetHash, B3, &B2, 2, 2));
REQUIRE(scp.mEnvs.size() == 6);
verifyPrepare(scp.mEnvs[5], v0SecretKey, qSetHash0,
0, A3, &B2, 0, 2, &A2);

recvQuorumChecks(makePrepareGen(qSetHash, B3, &B2, 2, 2), false);
REQUIRE(scp.mEnvs.size() == 6);
}
}
}
SECTION("Confirm prepared mixed")
{
// a few nodes prepared B2
recvVBlocking(makePrepareGen(qSetHash, B2, &B2, 0, 0, &A2));
REQUIRE(scp.mEnvs.size() == 5);
verifyPrepare(scp.mEnvs[4], v0SecretKey, qSetHash0, 0, A2,
&B2, 0, 0, &A2);

SECTION("mixed A2")
{
// causes h=A2
// but c = 0, as p >!~ h
scp.receiveEnvelope(
makePrepare(v3SecretKey, qSetHash, 0, A2, &A2));

REQUIRE(scp.mEnvs.size() == 6);
verifyPrepare(scp.mEnvs[5], v0SecretKey, qSetHash0, 0,
A2, &B2, 0, 2, &A2);

scp.receiveEnvelope(
makePrepare(v4SecretKey, qSetHash, 0, A2, &A2));

REQUIRE(scp.mEnvs.size() == 6);
}
SECTION("mixed B2")
{
// causes h=B2, c=B2
scp.receiveEnvelope(
makePrepare(v3SecretKey, qSetHash, 0, B2, &B2));

REQUIRE(scp.mEnvs.size() == 6);
verifyPrepare(scp.mEnvs[5], v0SecretKey, qSetHash0, 0,
B2, &B2, 2, 2, &A2);

scp.receiveEnvelope(
makePrepare(v4SecretKey, qSetHash, 0, B2, &B2));

REQUIRE(scp.mEnvs.size() == 6);
}
}
}
Expand Down Expand Up @@ -1212,6 +1274,14 @@ TEST_CASE("ballot protocol core5", "[scp][ballotprotocol]")
verifyConfirm(scp.mEnvs[6], v0SecretKey,
qSetHash0, 0, 3, A3, 2, 2);
}
SECTION("v-blocking prepared A3+B3")
{
recvVBlocking(makePrepareGen(qSetHash, A3, &A3,
2, 2, &B3));
REQUIRE(scp.mEnvs.size() == 7);
verifyConfirm(scp.mEnvs[6], v0SecretKey,
qSetHash0, 0, 3, A3, 2, 2);
}
SECTION("v-blocking confirm A3")
{
recvVBlocking(
Expand Down Expand Up @@ -1298,10 +1368,11 @@ TEST_CASE("ballot protocol core5", "[scp][ballotprotocol]")
}
SECTION("CONFIRM B2")
{
recvVBlockingChecks(
makeConfirmGen(qSetHash, 2, B2, 2, 2),
false);
REQUIRE(scp.mEnvs.size() == 5);
recvVBlocking(
makeConfirmGen(qSetHash, 2, B2, 2, 2));
REQUIRE(scp.mEnvs.size() == 6);
verifyConfirm(scp.mEnvs[5], v0SecretKey,
qSetHash0, 0, 2, B2, 2, 2);
}
}
SECTION("EXTERNALIZE")
Expand Down Expand Up @@ -1329,12 +1400,78 @@ TEST_CASE("ballot protocol core5", "[scp][ballotprotocol]")
}
}
}
SECTION("get conflicting prepared B2")
SECTION("get conflicting prepared B")
{
SECTION("same counter")
{
// messages are ignored as B2 < A2
recvQuorumChecks(makePrepareGen(qSetHash, B2, &B2),
false);
REQUIRE(scp.mEnvs.size() == 5);
}
SECTION("higher counter")
{
recvVBlocking(
makePrepareGen(qSetHash, B3, &B2, 2, 2));
REQUIRE(scp.mEnvs.size() == 6);
// A2 > B2 -> p = A2, p'=B2
verifyPrepare(scp.mEnvs[5], v0SecretKey, qSetHash0,
0, A3, &A2, 2, 2, &B2);

// node is stuck as it's trying to
// commit A2=<2,y> but rest of its quorum is
// trying to commit B2
recvQuorumChecks(
makePrepareGen(qSetHash, B3, &B2, 2, 2), false);
REQUIRE(scp.mEnvs.size() == 6);

// accept c=B2 ; also bumps counter to 3
recvVBlocking(
makeConfirmGen(qSetHash, 2, B3, 2, 2));
REQUIRE(scp.mEnvs.size() == 7);
verifyConfirm(scp.mEnvs[6], v0SecretKey, qSetHash0,
0, 2, B3, 2, 2);
}
}
}
SECTION("Confirm prepared mixed")
{
// a few nodes prepared B2
recvVBlocking(makePrepareGen(qSetHash, A2, &A2, 0, 0, &B2));
REQUIRE(scp.mEnvs.size() == 5);
verifyPrepare(scp.mEnvs[4], v0SecretKey, qSetHash0, 0, A2,
&A2, 0, 0, &B2);

SECTION("mixed A2")
{
// can't switch to B2
recvQuorumChecks(makePrepareGen(qSetHash, B2, &B2),
false);
REQUIRE(scp.mEnvs.size() == 5);
// causes h=A2, c=A2
scp.receiveEnvelope(
makePrepare(v3SecretKey, qSetHash, 0, A2, &A2));

REQUIRE(scp.mEnvs.size() == 6);
verifyPrepare(scp.mEnvs[5], v0SecretKey, qSetHash0, 0,
A2, &A2, 2, 2, &B2);

scp.receiveEnvelope(
makePrepare(v4SecretKey, qSetHash, 0, A2, &A2));

REQUIRE(scp.mEnvs.size() == 6);
}
SECTION("mixed B2")
{
// causes h=B2
// but c = 0, as p >!~ h
scp.receiveEnvelope(
makePrepare(v3SecretKey, qSetHash, 0, A2, &B2));

REQUIRE(scp.mEnvs.size() == 6);
verifyPrepare(scp.mEnvs[5], v0SecretKey, qSetHash0, 0,
A2, &A2, 0, 2, &B2);

scp.receiveEnvelope(
makePrepare(v4SecretKey, qSetHash, 0, B2, &B2));

REQUIRE(scp.mEnvs.size() == 6);
}
}
}
Expand Down Expand Up @@ -1487,6 +1624,52 @@ TEST_CASE("ballot protocol core5", "[scp][ballotprotocol]")
}
}
}
SECTION("Confirm prepared mixed")
{
// a few nodes prepared A2
// causes p=A2
recvVBlockingChecks(makePrepareGen(qSetHash, A2, &A2),
false);
REQUIRE(scp.mEnvs.size() == 0);

// a few nodes prepared B2
// causes p=B2, p'=A2
recvVBlockingChecks(
makePrepareGen(qSetHash, A2, &B2, 0, 0, &A2), false);
REQUIRE(scp.mEnvs.size() == 0);

SECTION("mixed A2")
{
// causes h=A2
// but c = 0, as p >!~ h
scp.receiveEnvelope(
makePrepare(v3SecretKey, qSetHash, 0, A2, &A2));

REQUIRE(scp.mEnvs.size() == 1);
verifyPrepare(scp.mEnvs[0], v0SecretKey, qSetHash0, 0,
A2, &B2, 0, 2, &A2);

scp.receiveEnvelope(
makePrepare(v4SecretKey, qSetHash, 0, A2, &A2));

REQUIRE(scp.mEnvs.size() == 1);
}
SECTION("mixed B2")
{
// causes h=B2, c=B2
scp.receiveEnvelope(
makePrepare(v3SecretKey, qSetHash, 0, B2, &B2));

REQUIRE(scp.mEnvs.size() == 1);
verifyPrepare(scp.mEnvs[0], v0SecretKey, qSetHash0, 0,
B2, &B2, 2, 2, &A2);

scp.receiveEnvelope(
makePrepare(v4SecretKey, qSetHash, 0, B2, &B2));

REQUIRE(scp.mEnvs.size() == 1);
}
}
}
SECTION("switch prepared B1")
{
Expand Down

5 comments on commit 443b4a4

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from jedmccaleb
at MonsieurNicolas@443b4a4

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging MonsieurNicolas/stellar-core/scpFixupNovember17 = 443b4a4 into auto

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MonsieurNicolas/stellar-core/scpFixupNovember17 = 443b4a4 merged ok, testing candidate = f5b9f4e

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = f5b9f4e

Please sign in to comment.