From 9789fc97b702316086eeb82dbd70ebfaf9e6bad9 Mon Sep 17 00:00:00 2001 From: Jason Frame Date: Wed, 8 May 2019 13:34:44 +1000 Subject: [PATCH 1/3] Change AT discard RPC tests to be more reliable by checking discard using proposals rpc --- .../CliqueDiscardRpcAcceptanceTest.java | 34 +++++++------------ .../ibft/IbftDiscardRpcAcceptanceTest.java | 19 +++-------- 2 files changed, 16 insertions(+), 37 deletions(-) diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/clique/CliqueDiscardRpcAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/clique/CliqueDiscardRpcAcceptanceTest.java index e981ebda98..8b9bf7c72e 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/clique/CliqueDiscardRpcAcceptanceTest.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/clique/CliqueDiscardRpcAcceptanceTest.java @@ -23,27 +23,17 @@ public class CliqueDiscardRpcAcceptanceTest extends AcceptanceTestBase { @Test public void shouldDiscardVotes() throws IOException { - final String[] initialValidators = {"miner1", "miner2"}; - final PantheonNode minerNode1 = - pantheon.createCliqueNodeWithValidators("miner1", initialValidators); - final PantheonNode minerNode2 = - pantheon.createCliqueNodeWithValidators("miner2", initialValidators); - final PantheonNode minerNode3 = - pantheon.createCliqueNodeWithValidators("miner3", initialValidators); - cluster.start(minerNode1, minerNode2, minerNode3); - - minerNode1.execute(cliqueTransactions.createRemoveProposal(minerNode2)); - minerNode2.execute(cliqueTransactions.createRemoveProposal(minerNode2)); - minerNode1.execute(cliqueTransactions.createAddProposal(minerNode3)); - minerNode2.execute(cliqueTransactions.createAddProposal(minerNode3)); - minerNode1.execute(cliqueTransactions.createDiscardProposal(minerNode2)); - minerNode1.execute(cliqueTransactions.createDiscardProposal(minerNode3)); - - minerNode1.waitUntil(wait.chainHeadHasProgressedByAtLeast(minerNode1, 2)); - - cluster.verify(clique.validatorsEqual(minerNode1, minerNode2)); - minerNode1.verify(clique.noProposals()); - minerNode2.verify( - clique.proposalsEqual().removeProposal(minerNode2).addProposal(minerNode3).build()); + final String[] validators = {"validator1", "validator2"}; + final PantheonNode validator1 = + pantheon.createCliqueNodeWithValidators("validator1", validators); + final PantheonNode validator2 = + pantheon.createCliqueNodeWithValidators("validator2", validators); + cluster.start(validator1, validator2); + + validator1.execute(cliqueTransactions.createAddProposal(validator2)); + validator1.verify(clique.proposalsEqual().addProposal(validator2).build()); + + validator1.execute(cliqueTransactions.createDiscardProposal(validator2)); + cluster.verify(clique.noProposals()); } } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ibft/IbftDiscardRpcAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ibft/IbftDiscardRpcAcceptanceTest.java index 71ad809cd7..18ab49f977 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ibft/IbftDiscardRpcAcceptanceTest.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ibft/IbftDiscardRpcAcceptanceTest.java @@ -26,23 +26,12 @@ public void shouldDiscardVotes() throws IOException { final String[] validators = {"validator1", "validator2"}; final PantheonNode validator1 = pantheon.createIbftNodeWithValidators("validator1", validators); final PantheonNode validator2 = pantheon.createIbftNodeWithValidators("validator2", validators); - final PantheonNode validator3 = pantheon.createIbftNodeWithValidators("validator3", validators); - cluster.start(validator1, validator2, validator3); + cluster.start(validator1, validator2); - validator1.execute(ibftTransactions.createRemoveProposal(validator2)); - validator1.execute(ibftTransactions.createAddProposal(validator3)); - - validator2.execute(ibftTransactions.createRemoveProposal(validator2)); - validator2.execute(ibftTransactions.createAddProposal(validator3)); + validator1.execute(ibftTransactions.createAddProposal(validator2)); + validator1.verify(ibft.pendingVotesEqual().addProposal(validator2).build()); validator1.execute(ibftTransactions.createDiscardProposal(validator2)); - validator1.execute(ibftTransactions.createDiscardProposal(validator3)); - - validator1.waitUntil(wait.chainHeadHasProgressedByAtLeast(validator1, 2)); - - cluster.verify(ibft.validatorsEqual(validator1, validator2)); - validator1.verify(ibft.noProposals()); - validator2.verify( - ibft.pendingVotesEqual().removeProposal(validator2).addProposal(validator3).build()); + cluster.verify(ibft.noProposals()); } } From 7e542c55c1a6a9ee59b9190605e87f7637b8ca6d Mon Sep 17 00:00:00 2001 From: Jason Frame <909467+jframe@users.noreply.github.com> Date: Thu, 9 May 2019 15:33:06 +1000 Subject: [PATCH 2/3] only need single initial validator --- .../tests/acceptance/clique/CliqueDiscardRpcAcceptanceTest.java | 2 +- .../tests/acceptance/ibft/IbftDiscardRpcAcceptanceTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/clique/CliqueDiscardRpcAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/clique/CliqueDiscardRpcAcceptanceTest.java index 8b9bf7c72e..247b250086 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/clique/CliqueDiscardRpcAcceptanceTest.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/clique/CliqueDiscardRpcAcceptanceTest.java @@ -23,7 +23,7 @@ public class CliqueDiscardRpcAcceptanceTest extends AcceptanceTestBase { @Test public void shouldDiscardVotes() throws IOException { - final String[] validators = {"validator1", "validator2"}; + final String[] validators = {"validator1"}; final PantheonNode validator1 = pantheon.createCliqueNodeWithValidators("validator1", validators); final PantheonNode validator2 = diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ibft/IbftDiscardRpcAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ibft/IbftDiscardRpcAcceptanceTest.java index 18ab49f977..5ba1e9dde7 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ibft/IbftDiscardRpcAcceptanceTest.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ibft/IbftDiscardRpcAcceptanceTest.java @@ -23,7 +23,7 @@ public class IbftDiscardRpcAcceptanceTest extends AcceptanceTestBase { @Test public void shouldDiscardVotes() throws IOException { - final String[] validators = {"validator1", "validator2"}; + final String[] validators = {"validator1"}; final PantheonNode validator1 = pantheon.createIbftNodeWithValidators("validator1", validators); final PantheonNode validator2 = pantheon.createIbftNodeWithValidators("validator2", validators); cluster.start(validator1, validator2); From d471e36cfe03b4e6883f38131aadc79f603b6842 Mon Sep 17 00:00:00 2001 From: Jason Frame <909467+jframe@users.noreply.github.com> Date: Thu, 9 May 2019 15:46:03 +1000 Subject: [PATCH 3/3] check both add and remove with discard --- .../clique/CliqueDiscardRpcAcceptanceTest.java | 13 ++++++++++--- .../ibft/IbftDiscardRpcAcceptanceTest.java | 12 +++++++++--- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/clique/CliqueDiscardRpcAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/clique/CliqueDiscardRpcAcceptanceTest.java index 247b250086..68a5ba47d7 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/clique/CliqueDiscardRpcAcceptanceTest.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/clique/CliqueDiscardRpcAcceptanceTest.java @@ -23,17 +23,24 @@ public class CliqueDiscardRpcAcceptanceTest extends AcceptanceTestBase { @Test public void shouldDiscardVotes() throws IOException { - final String[] validators = {"validator1"}; + final String[] validators = {"validator1", "validator3"}; final PantheonNode validator1 = pantheon.createCliqueNodeWithValidators("validator1", validators); final PantheonNode validator2 = pantheon.createCliqueNodeWithValidators("validator2", validators); - cluster.start(validator1, validator2); + final PantheonNode validator3 = + pantheon.createCliqueNodeWithValidators("validator3", validators); + cluster.start(validator1, validator2, validator3); validator1.execute(cliqueTransactions.createAddProposal(validator2)); - validator1.verify(clique.proposalsEqual().addProposal(validator2).build()); + validator1.execute(cliqueTransactions.createRemoveProposal(validator3)); + validator1.verify( + clique.proposalsEqual().addProposal(validator2).removeProposal(validator3).build()); validator1.execute(cliqueTransactions.createDiscardProposal(validator2)); + validator1.verify(clique.proposalsEqual().removeProposal(validator3).build()); + + validator1.execute(cliqueTransactions.createDiscardProposal(validator3)); cluster.verify(clique.noProposals()); } } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ibft/IbftDiscardRpcAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ibft/IbftDiscardRpcAcceptanceTest.java index 5ba1e9dde7..3b1dcd7fa2 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ibft/IbftDiscardRpcAcceptanceTest.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ibft/IbftDiscardRpcAcceptanceTest.java @@ -23,15 +23,21 @@ public class IbftDiscardRpcAcceptanceTest extends AcceptanceTestBase { @Test public void shouldDiscardVotes() throws IOException { - final String[] validators = {"validator1"}; + final String[] validators = {"validator1", "validator3"}; final PantheonNode validator1 = pantheon.createIbftNodeWithValidators("validator1", validators); final PantheonNode validator2 = pantheon.createIbftNodeWithValidators("validator2", validators); - cluster.start(validator1, validator2); + final PantheonNode validator3 = pantheon.createIbftNodeWithValidators("validator3", validators); + cluster.start(validator1, validator2, validator3); validator1.execute(ibftTransactions.createAddProposal(validator2)); - validator1.verify(ibft.pendingVotesEqual().addProposal(validator2).build()); + validator1.execute(ibftTransactions.createRemoveProposal(validator3)); + validator1.verify( + ibft.pendingVotesEqual().addProposal(validator2).removeProposal(validator3).build()); validator1.execute(ibftTransactions.createDiscardProposal(validator2)); + validator1.verify(ibft.pendingVotesEqual().removeProposal(validator3).build()); + + validator1.execute(ibftTransactions.createDiscardProposal(validator3)); cluster.verify(ibft.noProposals()); } }