Acceptance test refactoring - DSL - Node interface (#170)

* Conditions to remove the getters from Node interface

Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
pull/2/head
CJ Hare 6 years ago committed by GitHub
parent cb93cbdfd9
commit 8fa45725f2
  1. 15
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/AcceptanceTestBase.java
  2. 17
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/account/Account.java
  3. 10
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/account/Accounts.java
  4. 31
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/blockchain/Blockchain.java
  5. 10
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/ExpectAccountBalance.java
  6. 36
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/ExpectMinimumBlockNumber.java
  7. 48
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/Eth.java
  8. 5
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/Node.java
  9. 33
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNode.java
  10. 38
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/EthBlockNumberTransaction.java
  11. 47
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/EthGetBalanceTransaction.java
  12. 40
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/EthGetWorkTransaction.java
  13. 30
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/EthTransactions.java
  14. 41
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/Web3Sha3Transaction.java
  15. 20
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/Web3Transactions.java
  16. 6
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetWorkAcceptanceTest.java
  17. 2
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/Web3Sha3AcceptanceTest.java
  18. 15
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/pubsub/NewPendingTransactionAcceptanceTest.java

@ -13,23 +13,32 @@
package tech.pegasys.pantheon.tests.acceptance.dsl;
import tech.pegasys.pantheon.tests.acceptance.dsl.account.Accounts;
import tech.pegasys.pantheon.tests.acceptance.dsl.blockchain.Blockchain;
import tech.pegasys.pantheon.tests.acceptance.dsl.node.Cluster;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.EthTransactions;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transactions;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Web3Transactions;
import org.junit.After;
public class AcceptanceTestBase {
protected final Accounts accounts;
protected final Blockchain blockchain;
protected final Cluster cluster;
protected final Transactions transactions;
protected final EthTransactions eth;
protected final JsonRpc jsonRpc;
protected final Transactions transactions;
protected final Web3Transactions web3;
protected AcceptanceTestBase() {
accounts = new Accounts();
eth = new EthTransactions();
accounts = new Accounts(eth);
blockchain = new Blockchain(eth);
cluster = new Cluster();
transactions = new Transactions(accounts);
jsonRpc = new JsonRpc(cluster);
transactions = new Transactions(accounts);
web3 = new Web3Transactions();
}
@After

@ -18,6 +18,7 @@ import tech.pegasys.pantheon.ethereum.core.Address;
import tech.pegasys.pantheon.ethereum.core.Hash;
import tech.pegasys.pantheon.tests.acceptance.dsl.condition.Condition;
import tech.pegasys.pantheon.tests.acceptance.dsl.condition.ExpectAccountBalance;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.EthTransactions;
import tech.pegasys.pantheon.util.bytes.Bytes32;
import java.math.BigInteger;
@ -27,21 +28,25 @@ import org.web3j.utils.Convert.Unit;
public class Account {
private final EthTransactions eth;
private final String name;
private final KeyPair keyPair;
private long nonce = 0;
private Account(final String name, final KeyPair keyPair) {
private Account(final EthTransactions eth, final String name, final KeyPair keyPair) {
this.name = name;
this.keyPair = keyPair;
this.eth = eth;
}
public static Account create(final String name) {
return new Account(name, KeyPair.generate());
public static Account create(final EthTransactions eth, final String name) {
return new Account(eth, name, KeyPair.generate());
}
public static Account fromPrivateKey(final String name, final String privateKey) {
return new Account(name, KeyPair.create(PrivateKey.create(Bytes32.fromHexString(privateKey))));
static Account fromPrivateKey(
final EthTransactions eth, final String name, final String privateKey) {
return new Account(
eth, name, KeyPair.create(PrivateKey.create(Bytes32.fromHexString(privateKey))));
}
public Credentials web3jCredentials() {
@ -66,7 +71,7 @@ public class Account {
}
public Condition balanceEquals(final String expectedBalance, final Unit balanceUnit) {
return new ExpectAccountBalance(this, expectedBalance, balanceUnit);
return new ExpectAccountBalance(eth, this, expectedBalance, balanceUnit);
}
public Condition balanceEquals(final int expectedBalance) {

@ -12,18 +12,24 @@
*/
package tech.pegasys.pantheon.tests.acceptance.dsl.account;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.EthTransactions;
public class Accounts {
private final EthTransactions eth;
private final Account richBenefactorOne;
private final Account richBenefactorTwo;
public Accounts() {
public Accounts(final EthTransactions eth) {
this.eth = eth;
richBenefactorOne =
Account.fromPrivateKey(
eth,
"Rich Benefactor One",
"8f2a55949038a9610f50fb23b5883af3b4ecb3c3bb792cbcefbd1542c692be63");
richBenefactorTwo =
Account.fromPrivateKey(
eth,
"Rich Benefactor Two",
"c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3");
}
@ -37,6 +43,6 @@ public class Accounts {
}
public Account createAccount(final String accountName) {
return Account.create(accountName);
return Account.create(eth, accountName);
}
}

@ -0,0 +1,31 @@
/*
* Copyright 2018 ConsenSys AG.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package tech.pegasys.pantheon.tests.acceptance.dsl.blockchain;
import tech.pegasys.pantheon.tests.acceptance.dsl.condition.Condition;
import tech.pegasys.pantheon.tests.acceptance.dsl.condition.ExpectMinimumBlockNumber;
import tech.pegasys.pantheon.tests.acceptance.dsl.node.Node;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.EthTransactions;
public class Blockchain {
private final EthTransactions eth;
public Blockchain(final EthTransactions eth) {
this.eth = eth;
}
public Condition blockNumberMustBeLatest(final Node node) {
return new ExpectMinimumBlockNumber(eth, node.execute(eth.blockNumber()));
}
}

@ -18,27 +18,33 @@ import static tech.pegasys.pantheon.tests.acceptance.dsl.WaitUtils.waitFor;
import tech.pegasys.pantheon.tests.acceptance.dsl.account.Account;
import tech.pegasys.pantheon.tests.acceptance.dsl.node.Node;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.EthTransactions;
import org.web3j.utils.Convert.Unit;
public class ExpectAccountBalance implements Condition {
private final EthTransactions eth;
private final Account account;
private final String expectedBalance;
private final Unit balanceUnit;
public ExpectAccountBalance(
final Account account, final String expectedBalance, final Unit balanceUnit) {
final EthTransactions eth,
final Account account,
final String expectedBalance,
final Unit balanceUnit) {
this.expectedBalance = expectedBalance;
this.balanceUnit = balanceUnit;
this.account = account;
this.eth = eth;
}
@Override
public void verify(final Node node) {
waitFor(
() ->
assertThat(node.getAccountBalance(account))
assertThat(node.execute(eth.getBalance((account))))
.isEqualTo(toWei(expectedBalance, balanceUnit).toBigIntegerExact()));
}
}

@ -0,0 +1,36 @@
/*
* Copyright 2018 ConsenSys AG.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package tech.pegasys.pantheon.tests.acceptance.dsl.condition;
import static org.assertj.core.api.Assertions.assertThat;
import tech.pegasys.pantheon.tests.acceptance.dsl.node.Node;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.EthTransactions;
import java.math.BigInteger;
public class ExpectMinimumBlockNumber implements Condition {
private final EthTransactions eth;
private final BigInteger blockNumber;
public ExpectMinimumBlockNumber(final EthTransactions eth, final BigInteger blockNumber) {
this.blockNumber = blockNumber;
this.eth = eth;
}
@Override
public void verify(final Node node) {
assertThat(node.execute(eth.blockNumber())).isGreaterThanOrEqualTo(blockNumber);
}
}

@ -1,48 +0,0 @@
/*
* Copyright 2018 ConsenSys AG.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package tech.pegasys.pantheon.tests.acceptance.dsl.node;
import static org.assertj.core.api.Assertions.assertThat;
import java.io.IOException;
import java.math.BigInteger;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.methods.response.EthBlockNumber;
import org.web3j.protocol.core.methods.response.EthGetWork;
public class Eth {
private final Web3j web3j;
public Eth(final Web3j web3) {
this.web3j = web3;
}
public BigInteger blockNumber() throws IOException {
final EthBlockNumber result = web3j.ethBlockNumber().send();
assertThat(result).isNotNull();
assertThat(result.hasError()).isFalse();
return result.getBlockNumber();
}
public String[] getWork() throws IOException {
final EthGetWork result = web3j.ethGetWork().send();
assertThat(result).isNotNull();
return new String[] {
result.getCurrentBlockHeaderPowHash(),
result.getSeedHashForDag(),
result.getBoundaryCondition()
};
}
}

@ -12,14 +12,9 @@
*/
package tech.pegasys.pantheon.tests.acceptance.dsl.node;
import tech.pegasys.pantheon.tests.acceptance.dsl.account.Account;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;
import java.math.BigInteger;
public interface Node {
<T> T execute(Transaction<T> transaction);
BigInteger getAccountBalance(Account account);
}

@ -15,20 +15,18 @@ package tech.pegasys.pantheon.tests.acceptance.dsl.node;
import static org.apache.logging.log4j.LogManager.getLogger;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.catchThrowable;
import static org.web3j.protocol.core.DefaultBlockParameterName.LATEST;
import tech.pegasys.pantheon.controller.KeyPairUtil;
import tech.pegasys.pantheon.crypto.SECP256K1.KeyPair;
import tech.pegasys.pantheon.ethereum.core.MiningParameters;
import tech.pegasys.pantheon.ethereum.jsonrpc.JsonRpcConfiguration;
import tech.pegasys.pantheon.ethereum.jsonrpc.websocket.WebSocketConfiguration;
import tech.pegasys.pantheon.tests.acceptance.dsl.account.Account;
import tech.pegasys.pantheon.tests.acceptance.dsl.condition.Condition;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.math.BigInteger;
import java.net.ConnectException;
import java.nio.file.Files;
import java.nio.file.Path;
@ -45,7 +43,6 @@ import org.apache.logging.log4j.Logger;
import org.java_websocket.exceptions.WebsocketNotConnectedException;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.Web3jService;
import org.web3j.protocol.core.methods.response.EthGetBalance;
import org.web3j.protocol.http.HttpService;
import org.web3j.protocol.websocket.WebSocketService;
import org.web3j.utils.Async;
@ -67,7 +64,6 @@ public class PantheonNode implements Node, AutoCloseable {
private final Properties portsProperties = new Properties();
private List<String> bootnodes = new ArrayList<>();
private Eth eth;
private Web3 web3;
private Web3j web3j;
@ -145,8 +141,7 @@ public class PantheonNode implements Node, AutoCloseable {
return web3j;
}
@Deprecated
public Web3j web3j(final Web3jService web3jService) {
private Web3j web3j(final Web3jService web3jService) {
if (web3j == null) {
web3j = Web3j.build(web3jService, 2000, Async.defaultExecutorService());
}
@ -154,17 +149,6 @@ public class PantheonNode implements Node, AutoCloseable {
return web3j;
}
@Override
public BigInteger getAccountBalance(final Account account) {
try {
final EthGetBalance balanceResponse =
web3j().ethGetBalance(account.getAddress(), LATEST).send();
return balanceResponse.getBalance();
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
public int getPeerCount() {
try {
return web3j().netPeerCount().send().getQuantity().intValueExact();
@ -305,7 +289,6 @@ public class PantheonNode implements Node, AutoCloseable {
web3j = null;
}
eth = null;
web3 = null;
}
@ -327,16 +310,12 @@ public class PantheonNode implements Node, AutoCloseable {
return web3;
}
public Eth eth() {
if (eth == null) {
eth = new Eth(web3j());
}
return eth;
}
@Override
public <T> T execute(final Transaction<T> transaction) {
return transaction.execute(web3j());
}
public void verify(final Condition expected) {
expected.verify(this);
}
}

@ -0,0 +1,38 @@
/*
* Copyright 2018 ConsenSys AG.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package tech.pegasys.pantheon.tests.acceptance.dsl.transaction;
import static org.assertj.core.api.Assertions.assertThat;
import java.io.IOException;
import java.math.BigInteger;
import org.web3j.protocol.Web3j;
public class EthBlockNumberTransaction implements Transaction<BigInteger> {
EthBlockNumberTransaction() {}
@Override
public BigInteger execute(final Web3j node) {
try {
final org.web3j.protocol.core.methods.response.EthBlockNumber result =
node.ethBlockNumber().send();
assertThat(result).isNotNull();
assertThat(result.hasError()).isFalse();
return result.getBlockNumber();
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
}

@ -0,0 +1,47 @@
/*
* Copyright 2018 ConsenSys AG.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package tech.pegasys.pantheon.tests.acceptance.dsl.transaction;
import static org.assertj.core.api.Assertions.assertThat;
import static org.web3j.protocol.core.DefaultBlockParameterName.LATEST;
import tech.pegasys.pantheon.tests.acceptance.dsl.account.Account;
import java.io.IOException;
import java.math.BigInteger;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.methods.response.EthGetBalance;
public class EthGetBalanceTransaction implements Transaction<BigInteger> {
private final Account account;
EthGetBalanceTransaction(final Account account) {
this.account = account;
}
@Override
public BigInteger execute(final Web3j node) {
try {
final EthGetBalance result = node.ethGetBalance(account.getAddress(), LATEST).send();
assertThat(result).isNotNull();
assertThat(result.hasError()).isFalse();
return result.getBalance();
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
}

@ -0,0 +1,40 @@
/*
* Copyright 2018 ConsenSys AG.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package tech.pegasys.pantheon.tests.acceptance.dsl.transaction;
import static org.assertj.core.api.Assertions.assertThat;
import java.io.IOException;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.methods.response.EthGetWork;
public class EthGetWorkTransaction implements Transaction<String[]> {
EthGetWorkTransaction() {}
@Override
public String[] execute(final Web3j node) {
try {
final EthGetWork result = node.ethGetWork().send();
assertThat(result).isNotNull();
return new String[] {
result.getCurrentBlockHeaderPowHash(),
result.getSeedHashForDag(),
result.getBoundaryCondition()
};
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
}

@ -0,0 +1,30 @@
/*
* Copyright 2018 ConsenSys AG.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package tech.pegasys.pantheon.tests.acceptance.dsl.transaction;
import tech.pegasys.pantheon.tests.acceptance.dsl.account.Account;
public class EthTransactions {
public EthGetWorkTransaction getWork() {
return new EthGetWorkTransaction();
}
public EthBlockNumberTransaction blockNumber() {
return new EthBlockNumberTransaction();
}
public EthGetBalanceTransaction getBalance(final Account account) {
return new EthGetBalanceTransaction(account);
}
}

@ -0,0 +1,41 @@
/*
* Copyright 2018 ConsenSys AG.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package tech.pegasys.pantheon.tests.acceptance.dsl.transaction;
import static org.assertj.core.api.Assertions.assertThat;
import java.io.IOException;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.methods.response.Web3Sha3;
public class Web3Sha3Transaction implements Transaction<String> {
private final String input;
Web3Sha3Transaction(final String input) {
this.input = input;
}
@Override
public String execute(final Web3j node) {
try {
final Web3Sha3 result = node.web3Sha3(input).send();
assertThat(result).isNotNull();
assertThat(result.hasError()).isFalse();
return result.getResult();
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
}

@ -0,0 +1,20 @@
/*
* Copyright 2018 ConsenSys AG.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package tech.pegasys.pantheon.tests.acceptance.dsl.transaction;
public class Web3Transactions {
public Web3Sha3Transaction sha3(final String input) {
return new Web3Sha3Transaction(input);
}
}

@ -37,15 +37,15 @@ public class EthGetWorkAcceptanceTest extends AcceptanceTestBase {
}
@Test
public void shouldReturnSuccessResponseWhenMining() throws Exception {
final String[] response = minerNode.eth().getWork();
public void shouldReturnSuccessResponseWhenMining() {
final String[] response = minerNode.execute(eth.getWork());
assertThat(response).hasSize(3);
assertThat(response).doesNotContainNull();
}
@Test
public void shouldReturnErrorResponseWhenNotMining() {
final Throwable thrown = catchThrowable(() -> fullNode.eth().getWork());
final Throwable thrown = catchThrowable(() -> fullNode.execute(eth.getWork()));
assertThat(thrown).isInstanceOf(ClientConnectionException.class);
assertThat(thrown.getMessage()).contains("No mining work available yet");
}

@ -38,7 +38,7 @@ public class Web3Sha3AcceptanceTest extends AcceptanceTestBase {
final String input = "0x68656c6c6f20776f726c64";
final String sha3 = "0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad";
final String response = node.web3().web3Sha3(input);
final String response = node.execute(web3.sha3(input));
assertThat(response).isEqualTo(sha3);
}

@ -12,19 +12,17 @@
*/
package tech.pegasys.pantheon.tests.acceptance.pubsub;
import static org.assertj.core.api.Assertions.assertThat;
import static tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNodeConfig.pantheonMinerNode;
import static tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNodeConfig.pantheonNode;
import tech.pegasys.pantheon.ethereum.core.Hash;
import tech.pegasys.pantheon.tests.acceptance.dsl.AcceptanceTestBase;
import tech.pegasys.pantheon.tests.acceptance.dsl.account.Account;
import tech.pegasys.pantheon.tests.acceptance.dsl.condition.Condition;
import tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNode;
import tech.pegasys.pantheon.tests.acceptance.dsl.pubsub.Subscription;
import tech.pegasys.pantheon.tests.acceptance.dsl.pubsub.WebSocket;
import java.math.BigInteger;
import io.vertx.core.Vertx;
import org.junit.After;
import org.junit.Before;
@ -69,7 +67,7 @@ public class NewPendingTransactionAcceptanceTest extends AcceptanceTestBase {
minerWebSocket.verifyTotalEventsReceived(1);
lightForkSubscription.verifyEventReceived(lightForkEvent);
final BigInteger lighterForkBlockNumber = minerNode.eth().blockNumber();
final Condition atLeastLighterForkBlockNumber = blockchain.blockNumberMustBeLatest(minerNode);
cluster.stop();
@ -100,7 +98,8 @@ public class NewPendingTransactionAcceptanceTest extends AcceptanceTestBase {
heavyForkSubscription.verifyEventReceived(heavyForkEventTwo);
heavyForkSubscription.verifyEventReceived(heavyForkEventThree);
final BigInteger heavierForkBlockNumber = minerNodeTwo.eth().blockNumber();
final Condition atLeastHeavierForkBlockNumber =
blockchain.blockNumberMustBeLatest(minerNodeTwo);
cluster.stop();
@ -115,9 +114,9 @@ public class NewPendingTransactionAcceptanceTest extends AcceptanceTestBase {
final Subscription archiveMergedForksSubscription = archiveMergedForksWebSocket.subscribe();
// Check that all node have loaded their respective forks, i.e. not begin new chains
assertThat(minerNode.eth().blockNumber()).isGreaterThanOrEqualTo(lighterForkBlockNumber);
assertThat(archiveNode.eth().blockNumber()).isGreaterThanOrEqualTo(lighterForkBlockNumber);
assertThat(minerNodeTwo.eth().blockNumber()).isGreaterThanOrEqualTo(heavierForkBlockNumber);
minerNode.verify(atLeastLighterForkBlockNumber);
archiveNode.verify(atLeastLighterForkBlockNumber);
minerNodeTwo.verify(atLeastHeavierForkBlockNumber);
// This publish give time needed for heavy fork to be chosen
final Hash mergedForksEventOne =

Loading…
Cancel
Save