From 1ff064afcdcef0c09afeaf08389abab806ddf81d Mon Sep 17 00:00:00 2001 From: Shinabyss Date: Sun, 4 Nov 2018 11:18:45 +0400 Subject: [PATCH 01/11] EthGetTransactionReceipt Acceptance test added --- .../EthGetTransactionReceiptTransaction.java | 27 ++++++++ .../dsl/transaction/EthTransactions.java | 4 ++ ...thGetTransactionReceiptAcceptanceTest.java | 61 +++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/EthGetTransactionReceiptTransaction.java create mode 100644 acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/EthGetTransactionReceiptTransaction.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/EthGetTransactionReceiptTransaction.java new file mode 100644 index 0000000000..5bc4aa00ee --- /dev/null +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/EthGetTransactionReceiptTransaction.java @@ -0,0 +1,27 @@ +package tech.pegasys.pantheon.tests.acceptance.dsl.transaction; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.IOException; +import java.util.Optional; +import org.web3j.protocol.Web3j; +import org.web3j.protocol.core.methods.response.EthGetTransactionReceipt; +import org.web3j.protocol.core.methods.response.TransactionReceipt; + +public class EthGetTransactionReceiptTransaction implements Transaction> { + + private final String input; + + EthGetTransactionReceiptTransaction(final String input) {this.input = input; } + + @Override public Optional execute(final Web3j node) { + try { + final EthGetTransactionReceipt result = node.ethGetTransactionReceipt(input).send(); + assertThat(result.hasError()).isFalse(); + return result.getTransactionReceipt(); + } catch (final IOException e) { + throw new RuntimeException(e); + } + } + +} diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/EthTransactions.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/EthTransactions.java index d0087c8cdc..1e8928a709 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/EthTransactions.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/EthTransactions.java @@ -27,4 +27,8 @@ public EthBlockNumberTransaction blockNumber() { public EthGetBalanceTransaction getBalance(final Account account) { return new EthGetBalanceTransaction(account); } + + public EthGetTransactionReceiptTransaction getTransactionReceipt(final String param) { + return new EthGetTransactionReceiptTransaction(param); + } } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java new file mode 100644 index 0000000000..ce6526fed6 --- /dev/null +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java @@ -0,0 +1,61 @@ +package tech.pegasys.pantheon.tests.acceptance.jsonrpc; + +import static tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNodeConfig.pantheonMinerNode; +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.Optional; +import org.web3j.protocol.core.methods.response.TransactionReceipt; +import tech.pegasys.pantheon.ethereum.core.Hash; + +import org.junit.Before; +import org.junit.Test; +import tech.pegasys.pantheon.tests.acceptance.dsl.AcceptanceTestBase; +import tech.pegasys.pantheon.tests.acceptance.dsl.account.Account; +import tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNode; + +public class EthGetTransactionReceiptAcceptanceTest extends AcceptanceTestBase { + + private PantheonNode minerNode; + private Account sender; + private Account recipient; + + @Before + public void setUp() throws Exception { + sender = accounts.createAccount("sender"); + recipient = accounts.createAccount("recipient"); + minerNode = cluster.create(pantheonMinerNode("node")); + cluster.start(minerNode); + minerNode.execute(transactions.createTransfer(sender, 10)); + cluster.verify(sender.balanceEquals(10)); + } + + @Test + public void mustCorrectlyQueryTransactionReceiptFromContractCreationTransaction() { + final Hash transactionHash + = minerNode.execute(transactions.createTransfer(recipient, 5)); + cluster.verify(recipient.balanceEquals(5)); + final Optional response + = minerNode.execute(eth.getTransactionReceipt(transactionHash.toString())); + assertThat(response.isPresent()).isTrue(); + } + + @Test + public void mustCorrectlyQueryTransactionReceiptFromNormalTransaction() { + final Hash transactionHash + = minerNode.execute(transactions.createTransfer(sender, recipient, 5)); + cluster.verify(recipient.balanceEquals(10)); + cluster.verify(sender.balanceEquals(5)); + final Optional response + = minerNode.execute(eth.getTransactionReceipt(transactionHash.toString())); + assertThat(response.isPresent()).isTrue(); + } + + @Test + public void mustReturnNullWhenTransactionDoesNotExist() { + final Optional response + = minerNode.execute(eth.getTransactionReceipt( + "0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238")); + assertThat(response.isPresent()).isFalse(); + } + +} From ef0db70fe5fe3b2781316f1a522bb787eb8b055e Mon Sep 17 00:00:00 2001 From: Shinabyss Date: Sun, 4 Nov 2018 12:08:28 +0400 Subject: [PATCH 02/11] GetTransactionReceipt Acceptance Test updated to conform to new dsl --- .../ExpectEthGetTransactionRecieptNull.java | 22 ++++++++++++++++++- ...tyCheckEthGetTransactionReceiptValues.java | 22 ++++++++++++++++++- .../tests/acceptance/dsl/jsonrpc/Eth.java | 10 +++++++++ .../EthGetTransactionReceiptTransaction.java | 6 +++-- .../dsl/transaction/eth/EthTransactions.java | 5 +++++ ...thGetTransactionReceiptAcceptanceTest.java | 17 ++++---------- 6 files changed, 65 insertions(+), 17 deletions(-) diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/ExpectEthGetTransactionRecieptNull.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/ExpectEthGetTransactionRecieptNull.java index f2166fefd1..2499f17589 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/ExpectEthGetTransactionRecieptNull.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/ExpectEthGetTransactionRecieptNull.java @@ -1,5 +1,25 @@ package tech.pegasys.pantheon.tests.acceptance.dsl.condition.eth; -public class ExpectEthGetTransactionRecieptNull { +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.Optional; +import org.web3j.protocol.core.methods.response.TransactionReceipt; +import tech.pegasys.pantheon.tests.acceptance.dsl.condition.Condition; +import tech.pegasys.pantheon.tests.acceptance.dsl.node.Node; +import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.eth.EthGetTransactionReceiptTransaction; + +public class ExpectEthGetTransactionRecieptNull implements Condition { + + private final EthGetTransactionReceiptTransaction transaction; + + public ExpectEthGetTransactionRecieptNull(final EthGetTransactionReceiptTransaction transaction) { + this.transaction = transaction; + } + + @Override + public void verify(final Node node) { + final Optional response = node.execute(transaction); + assertThat(response.isPresent()).isFalse(); + } } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/SanityCheckEthGetTransactionReceiptValues.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/SanityCheckEthGetTransactionReceiptValues.java index 9d5dc5f461..583f77cf6d 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/SanityCheckEthGetTransactionReceiptValues.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/SanityCheckEthGetTransactionReceiptValues.java @@ -1,5 +1,25 @@ package tech.pegasys.pantheon.tests.acceptance.dsl.condition.eth; -public class SanityCheckEthGetTransactionReceiptValues { +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.Optional; +import org.web3j.protocol.core.methods.response.TransactionReceipt; +import tech.pegasys.pantheon.tests.acceptance.dsl.condition.Condition; +import tech.pegasys.pantheon.tests.acceptance.dsl.node.Node; +import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.eth.EthGetTransactionReceiptTransaction; + +public class SanityCheckEthGetTransactionReceiptValues implements Condition { + + private final EthGetTransactionReceiptTransaction transaction; + + public SanityCheckEthGetTransactionReceiptValues(final EthGetTransactionReceiptTransaction transaction) { + this.transaction = transaction; + } + + @Override + public void verify(final Node node) { + final Optional response = node.execute(transaction); + assertThat(response.isPresent()).isTrue(); + } } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Eth.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Eth.java index 82a24a26aa..5d76edf644 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Eth.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Eth.java @@ -14,7 +14,9 @@ import tech.pegasys.pantheon.tests.acceptance.dsl.condition.Condition; import tech.pegasys.pantheon.tests.acceptance.dsl.condition.eth.ExpectEthAccountsException; +import tech.pegasys.pantheon.tests.acceptance.dsl.condition.eth.ExpectEthGetTransactionRecieptNull; import tech.pegasys.pantheon.tests.acceptance.dsl.condition.eth.ExpectEthGetWorkException; +import tech.pegasys.pantheon.tests.acceptance.dsl.condition.eth.SanityCheckEthGetTransactionReceiptValues; import tech.pegasys.pantheon.tests.acceptance.dsl.condition.eth.SanityCheckEthGetWorkValues; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.eth.EthTransactions; @@ -37,4 +39,12 @@ public Condition getWorkExceptional(final String expectedMessage) { public Condition accountsExceptional(final String expectedMessage) { return new ExpectEthAccountsException(transactions.accounts(), expectedMessage); } + + public Condition getTransactionReceipt(final String param) { + return new SanityCheckEthGetTransactionReceiptValues(transactions.getTransactionReceipt(param)); + } + + public Condition getTransactionReceiptNull(final String param) { + return new ExpectEthGetTransactionRecieptNull(transactions.getTransactionReceipt(param)); + } } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/eth/EthGetTransactionReceiptTransaction.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/eth/EthGetTransactionReceiptTransaction.java index 5bc4aa00ee..e687a4c067 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/eth/EthGetTransactionReceiptTransaction.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/eth/EthGetTransactionReceiptTransaction.java @@ -1,4 +1,4 @@ -package tech.pegasys.pantheon.tests.acceptance.dsl.transaction; +package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.eth; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +7,10 @@ import org.web3j.protocol.Web3j; import org.web3j.protocol.core.methods.response.EthGetTransactionReceipt; import org.web3j.protocol.core.methods.response.TransactionReceipt; +import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; -public class EthGetTransactionReceiptTransaction implements Transaction> { +public class EthGetTransactionReceiptTransaction implements + Transaction> { private final String input; diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/eth/EthTransactions.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/eth/EthTransactions.java index 80dec048c0..cc02563a0f 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/eth/EthTransactions.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/eth/EthTransactions.java @@ -12,6 +12,7 @@ */ package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.eth; +import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.EthGetTransactionReceipt; import tech.pegasys.pantheon.tests.acceptance.dsl.account.Account; public class EthTransactions { @@ -31,4 +32,8 @@ public EthGetBalanceTransaction getBalance(final Account account) { public EthAccountsTransaction accounts() { return new EthAccountsTransaction(); } + + public EthGetTransactionReceiptTransaction getTransactionReceipt(final String param) { + return new EthGetTransactionReceiptTransaction(param); + } } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java index ce6526fed6..b7bc8a67ea 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java @@ -1,10 +1,7 @@ package tech.pegasys.pantheon.tests.acceptance.jsonrpc; import static tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNodeConfig.pantheonMinerNode; -import static org.assertj.core.api.Assertions.assertThat; -import java.util.Optional; -import org.web3j.protocol.core.methods.response.TransactionReceipt; import tech.pegasys.pantheon.ethereum.core.Hash; import org.junit.Before; @@ -34,9 +31,7 @@ public void mustCorrectlyQueryTransactionReceiptFromContractCreationTransaction( final Hash transactionHash = minerNode.execute(transactions.createTransfer(recipient, 5)); cluster.verify(recipient.balanceEquals(5)); - final Optional response - = minerNode.execute(eth.getTransactionReceipt(transactionHash.toString())); - assertThat(response.isPresent()).isTrue(); + minerNode.verify(eth.getTransactionReceipt(transactionHash.toString())); } @Test @@ -45,17 +40,13 @@ public void mustCorrectlyQueryTransactionReceiptFromNormalTransaction() { = minerNode.execute(transactions.createTransfer(sender, recipient, 5)); cluster.verify(recipient.balanceEquals(10)); cluster.verify(sender.balanceEquals(5)); - final Optional response - = minerNode.execute(eth.getTransactionReceipt(transactionHash.toString())); - assertThat(response.isPresent()).isTrue(); + minerNode.verify(eth.getTransactionReceipt(transactionHash.toString())); } @Test public void mustReturnNullWhenTransactionDoesNotExist() { - final Optional response - = minerNode.execute(eth.getTransactionReceipt( - "0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238")); - assertThat(response.isPresent()).isFalse(); + minerNode.verify(eth.getTransactionReceiptNull( + "0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238")); } } From 7c46e7832de646d86fc76c9eb7d5f3615f5cf847 Mon Sep 17 00:00:00 2001 From: Shinabyss Date: Mon, 19 Nov 2018 04:30:02 +1000 Subject: [PATCH 03/11] Update to new dsl --- .../jsonrpc/EthGetTransactionReceiptAcceptanceTest.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java index b7bc8a67ea..35fa9c0f36 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java @@ -1,7 +1,5 @@ package tech.pegasys.pantheon.tests.acceptance.jsonrpc; -import static tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNodeConfig.pantheonMinerNode; - import tech.pegasys.pantheon.ethereum.core.Hash; import org.junit.Before; @@ -20,7 +18,7 @@ public class EthGetTransactionReceiptAcceptanceTest extends AcceptanceTestBase { public void setUp() throws Exception { sender = accounts.createAccount("sender"); recipient = accounts.createAccount("recipient"); - minerNode = cluster.create(pantheonMinerNode("node")); + minerNode = pantheon.createMinerNode("node"); cluster.start(minerNode); minerNode.execute(transactions.createTransfer(sender, 10)); cluster.verify(sender.balanceEquals(10)); @@ -38,7 +36,7 @@ public void mustCorrectlyQueryTransactionReceiptFromContractCreationTransaction( public void mustCorrectlyQueryTransactionReceiptFromNormalTransaction() { final Hash transactionHash = minerNode.execute(transactions.createTransfer(sender, recipient, 5)); - cluster.verify(recipient.balanceEquals(10)); + cluster.verify(recipient.balanceEquals(5)); //should this be 10 due to prev test? cluster.verify(sender.balanceEquals(5)); minerNode.verify(eth.getTransactionReceipt(transactionHash.toString())); } From 984dd7d2ac0bdc90660aa79c920504c0a055774e Mon Sep 17 00:00:00 2001 From: Shinabyss Date: Mon, 19 Nov 2018 16:35:17 +1000 Subject: [PATCH 04/11] Update to new dsl --- .../tests/acceptance/dsl/transaction/eth/EthTransactions.java | 1 - .../jsonrpc/EthGetTransactionReceiptAcceptanceTest.java | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/eth/EthTransactions.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/eth/EthTransactions.java index cc02563a0f..43d4b00a92 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/eth/EthTransactions.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/eth/EthTransactions.java @@ -12,7 +12,6 @@ */ package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.eth; -import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.EthGetTransactionReceipt; import tech.pegasys.pantheon.tests.acceptance.dsl.account.Account; public class EthTransactions { diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java index 35fa9c0f36..3421ff2893 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java @@ -36,8 +36,7 @@ public void mustCorrectlyQueryTransactionReceiptFromContractCreationTransaction( public void mustCorrectlyQueryTransactionReceiptFromNormalTransaction() { final Hash transactionHash = minerNode.execute(transactions.createTransfer(sender, recipient, 5)); - cluster.verify(recipient.balanceEquals(5)); //should this be 10 due to prev test? - cluster.verify(sender.balanceEquals(5)); + cluster.verify(recipient.balanceEquals(5)); minerNode.verify(eth.getTransactionReceipt(transactionHash.toString())); } From a3ec97498f7e2e5fd217b97a19a826a5fee22938 Mon Sep 17 00:00:00 2001 From: Shinabyss Date: Mon, 19 Nov 2018 17:07:28 +1000 Subject: [PATCH 05/11] Update to new dsl - spotless applied --- .../ExpectEthGetTransactionRecieptNull.java | 19 ++++++++++-- ...tyCheckEthGetTransactionReceiptValues.java | 22 ++++++++++--- .../EthGetTransactionReceiptTransaction.java | 28 +++++++++++++---- ...thGetTransactionReceiptAcceptanceTest.java | 31 +++++++++++++------ 4 files changed, 77 insertions(+), 23 deletions(-) diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/ExpectEthGetTransactionRecieptNull.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/ExpectEthGetTransactionRecieptNull.java index 2499f17589..abd9cdaba9 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/ExpectEthGetTransactionRecieptNull.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/ExpectEthGetTransactionRecieptNull.java @@ -1,13 +1,27 @@ +/* + * 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.eth; import static org.assertj.core.api.Assertions.assertThat; -import java.util.Optional; -import org.web3j.protocol.core.methods.response.TransactionReceipt; import tech.pegasys.pantheon.tests.acceptance.dsl.condition.Condition; import tech.pegasys.pantheon.tests.acceptance.dsl.node.Node; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.eth.EthGetTransactionReceiptTransaction; +import java.util.Optional; + +import org.web3j.protocol.core.methods.response.TransactionReceipt; + public class ExpectEthGetTransactionRecieptNull implements Condition { private final EthGetTransactionReceiptTransaction transaction; @@ -21,5 +35,4 @@ public void verify(final Node node) { final Optional response = node.execute(transaction); assertThat(response.isPresent()).isFalse(); } - } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/SanityCheckEthGetTransactionReceiptValues.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/SanityCheckEthGetTransactionReceiptValues.java index 583f77cf6d..b64d6f4c9a 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/SanityCheckEthGetTransactionReceiptValues.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/SanityCheckEthGetTransactionReceiptValues.java @@ -1,18 +1,33 @@ +/* + * 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.eth; import static org.assertj.core.api.Assertions.assertThat; -import java.util.Optional; -import org.web3j.protocol.core.methods.response.TransactionReceipt; import tech.pegasys.pantheon.tests.acceptance.dsl.condition.Condition; import tech.pegasys.pantheon.tests.acceptance.dsl.node.Node; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.eth.EthGetTransactionReceiptTransaction; +import java.util.Optional; + +import org.web3j.protocol.core.methods.response.TransactionReceipt; + public class SanityCheckEthGetTransactionReceiptValues implements Condition { private final EthGetTransactionReceiptTransaction transaction; - public SanityCheckEthGetTransactionReceiptValues(final EthGetTransactionReceiptTransaction transaction) { + public SanityCheckEthGetTransactionReceiptValues( + final EthGetTransactionReceiptTransaction transaction) { this.transaction = transaction; } @@ -21,5 +36,4 @@ public void verify(final Node node) { final Optional response = node.execute(transaction); assertThat(response.isPresent()).isTrue(); } - } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/eth/EthGetTransactionReceiptTransaction.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/eth/EthGetTransactionReceiptTransaction.java index e687a4c067..085f02ba93 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/eth/EthGetTransactionReceiptTransaction.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/eth/EthGetTransactionReceiptTransaction.java @@ -1,22 +1,39 @@ +/* + * 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.eth; import static org.assertj.core.api.Assertions.assertThat; +import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; + import java.io.IOException; import java.util.Optional; + import org.web3j.protocol.Web3j; import org.web3j.protocol.core.methods.response.EthGetTransactionReceipt; import org.web3j.protocol.core.methods.response.TransactionReceipt; -import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; -public class EthGetTransactionReceiptTransaction implements - Transaction> { +public class EthGetTransactionReceiptTransaction + implements Transaction> { private final String input; - EthGetTransactionReceiptTransaction(final String input) {this.input = input; } + EthGetTransactionReceiptTransaction(final String input) { + this.input = input; + } - @Override public Optional execute(final Web3j node) { + @Override + public Optional execute(final Web3j node) { try { final EthGetTransactionReceipt result = node.ethGetTransactionReceipt(input).send(); assertThat(result.hasError()).isFalse(); @@ -25,5 +42,4 @@ public class EthGetTransactionReceiptTransaction implements throw new RuntimeException(e); } } - } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java index 3421ff2893..1ff00464ab 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java @@ -1,13 +1,25 @@ +/* + * 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.jsonrpc; import tech.pegasys.pantheon.ethereum.core.Hash; - -import org.junit.Before; -import org.junit.Test; import tech.pegasys.pantheon.tests.acceptance.dsl.AcceptanceTestBase; import tech.pegasys.pantheon.tests.acceptance.dsl.account.Account; import tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNode; +import org.junit.Before; +import org.junit.Test; + public class EthGetTransactionReceiptAcceptanceTest extends AcceptanceTestBase { private PantheonNode minerNode; @@ -26,24 +38,23 @@ public void setUp() throws Exception { @Test public void mustCorrectlyQueryTransactionReceiptFromContractCreationTransaction() { - final Hash transactionHash - = minerNode.execute(transactions.createTransfer(recipient, 5)); + final Hash transactionHash = minerNode.execute(transactions.createTransfer(recipient, 5)); cluster.verify(recipient.balanceEquals(5)); minerNode.verify(eth.getTransactionReceipt(transactionHash.toString())); } @Test public void mustCorrectlyQueryTransactionReceiptFromNormalTransaction() { - final Hash transactionHash - = minerNode.execute(transactions.createTransfer(sender, recipient, 5)); + final Hash transactionHash = + minerNode.execute(transactions.createTransfer(sender, recipient, 5)); cluster.verify(recipient.balanceEquals(5)); minerNode.verify(eth.getTransactionReceipt(transactionHash.toString())); } @Test public void mustReturnNullWhenTransactionDoesNotExist() { - minerNode.verify(eth.getTransactionReceiptNull( - "0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238")); + minerNode.verify( + eth.getTransactionReceiptNull( + "0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238")); } - } From 4549355208aa5a48b1547a0ea91deb10fb9fbb65 Mon Sep 17 00:00:00 2001 From: Shinabyss Date: Tue, 20 Nov 2018 11:09:13 +1000 Subject: [PATCH 06/11] Naming convention corrected --- ...> ExpectEthGetTransactionReceiptIsAbsent.java} | 5 +++-- ... ExpectEthGetTransactionReceiptIsPresent.java} | 4 ++-- .../tests/acceptance/dsl/jsonrpc/Eth.java | 15 +++++++++------ .../EthGetTransactionReceiptAcceptanceTest.java | 8 ++++---- 4 files changed, 18 insertions(+), 14 deletions(-) rename acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/{ExpectEthGetTransactionRecieptNull.java => ExpectEthGetTransactionReceiptIsAbsent.java} (87%) rename acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/{SanityCheckEthGetTransactionReceiptValues.java => ExpectEthGetTransactionReceiptIsPresent.java} (91%) diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/ExpectEthGetTransactionRecieptNull.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/ExpectEthGetTransactionReceiptIsAbsent.java similarity index 87% rename from acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/ExpectEthGetTransactionRecieptNull.java rename to acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/ExpectEthGetTransactionReceiptIsAbsent.java index abd9cdaba9..6ea5ffca35 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/ExpectEthGetTransactionRecieptNull.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/ExpectEthGetTransactionReceiptIsAbsent.java @@ -22,11 +22,12 @@ import org.web3j.protocol.core.methods.response.TransactionReceipt; -public class ExpectEthGetTransactionRecieptNull implements Condition { +public class ExpectEthGetTransactionReceiptIsAbsent implements Condition { private final EthGetTransactionReceiptTransaction transaction; - public ExpectEthGetTransactionRecieptNull(final EthGetTransactionReceiptTransaction transaction) { + public ExpectEthGetTransactionReceiptIsAbsent( + final EthGetTransactionReceiptTransaction transaction) { this.transaction = transaction; } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/SanityCheckEthGetTransactionReceiptValues.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/ExpectEthGetTransactionReceiptIsPresent.java similarity index 91% rename from acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/SanityCheckEthGetTransactionReceiptValues.java rename to acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/ExpectEthGetTransactionReceiptIsPresent.java index b64d6f4c9a..543769359b 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/SanityCheckEthGetTransactionReceiptValues.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/ExpectEthGetTransactionReceiptIsPresent.java @@ -22,11 +22,11 @@ import org.web3j.protocol.core.methods.response.TransactionReceipt; -public class SanityCheckEthGetTransactionReceiptValues implements Condition { +public class ExpectEthGetTransactionReceiptIsPresent implements Condition { private final EthGetTransactionReceiptTransaction transaction; - public SanityCheckEthGetTransactionReceiptValues( + public ExpectEthGetTransactionReceiptIsPresent( final EthGetTransactionReceiptTransaction transaction) { this.transaction = transaction; } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Eth.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Eth.java index 5d76edf644..3ecc789bb1 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Eth.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Eth.java @@ -12,11 +12,12 @@ */ package tech.pegasys.pantheon.tests.acceptance.dsl.jsonrpc; +import tech.pegasys.pantheon.ethereum.core.Hash; import tech.pegasys.pantheon.tests.acceptance.dsl.condition.Condition; import tech.pegasys.pantheon.tests.acceptance.dsl.condition.eth.ExpectEthAccountsException; -import tech.pegasys.pantheon.tests.acceptance.dsl.condition.eth.ExpectEthGetTransactionRecieptNull; +import tech.pegasys.pantheon.tests.acceptance.dsl.condition.eth.ExpectEthGetTransactionReceiptIsAbsent; +import tech.pegasys.pantheon.tests.acceptance.dsl.condition.eth.ExpectEthGetTransactionReceiptIsPresent; import tech.pegasys.pantheon.tests.acceptance.dsl.condition.eth.ExpectEthGetWorkException; -import tech.pegasys.pantheon.tests.acceptance.dsl.condition.eth.SanityCheckEthGetTransactionReceiptValues; import tech.pegasys.pantheon.tests.acceptance.dsl.condition.eth.SanityCheckEthGetWorkValues; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.eth.EthTransactions; @@ -40,11 +41,13 @@ public Condition accountsExceptional(final String expectedMessage) { return new ExpectEthAccountsException(transactions.accounts(), expectedMessage); } - public Condition getTransactionReceipt(final String param) { - return new SanityCheckEthGetTransactionReceiptValues(transactions.getTransactionReceipt(param)); + public Condition getTransactionReceipt(final Hash transactionHash) { + return new ExpectEthGetTransactionReceiptIsPresent( + transactions.getTransactionReceipt(transactionHash.toString())); } - public Condition getTransactionReceiptNull(final String param) { - return new ExpectEthGetTransactionRecieptNull(transactions.getTransactionReceipt(param)); + public Condition getTransactionReceiptNotAvailable(final String transactionHash) { + return new ExpectEthGetTransactionReceiptIsAbsent( + transactions.getTransactionReceipt(transactionHash)); } } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java index 1ff00464ab..7f85ca768c 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java @@ -40,7 +40,7 @@ public void setUp() throws Exception { public void mustCorrectlyQueryTransactionReceiptFromContractCreationTransaction() { final Hash transactionHash = minerNode.execute(transactions.createTransfer(recipient, 5)); cluster.verify(recipient.balanceEquals(5)); - minerNode.verify(eth.getTransactionReceipt(transactionHash.toString())); + minerNode.verify(eth.getTransactionReceipt(transactionHash)); } @Test @@ -48,13 +48,13 @@ public void mustCorrectlyQueryTransactionReceiptFromNormalTransaction() { final Hash transactionHash = minerNode.execute(transactions.createTransfer(sender, recipient, 5)); cluster.verify(recipient.balanceEquals(5)); - minerNode.verify(eth.getTransactionReceipt(transactionHash.toString())); + minerNode.verify(eth.getTransactionReceipt(transactionHash)); } @Test public void mustReturnNullWhenTransactionDoesNotExist() { minerNode.verify( - eth.getTransactionReceiptNull( - "0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238")); + eth.getTransactionReceiptNotAvailable( + "0x0000000000000000000000000000000000000000000000000000000000000000")); } } From 90ffc61ca3f36dc7c24716fb21387ecc7d52c9de Mon Sep 17 00:00:00 2001 From: Shinabyss Date: Tue, 20 Nov 2018 15:06:18 +1000 Subject: [PATCH 07/11] Naming convention corrected Deleted obsolete test cases added assertion for status code --- .../ExpectEthGetTransactionReceiptIsPresent.java | 1 + .../tests/acceptance/dsl/jsonrpc/Eth.java | 4 ++-- .../EthGetTransactionReceiptAcceptanceTest.java | 15 ++++----------- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/ExpectEthGetTransactionReceiptIsPresent.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/ExpectEthGetTransactionReceiptIsPresent.java index 543769359b..5083359430 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/ExpectEthGetTransactionReceiptIsPresent.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/ExpectEthGetTransactionReceiptIsPresent.java @@ -35,5 +35,6 @@ public ExpectEthGetTransactionReceiptIsPresent( public void verify(final Node node) { final Optional response = node.execute(transaction); assertThat(response.isPresent()).isTrue(); + assertThat(response.get().getStatus()).isEqualToIgnoringCase("0x1"); } } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Eth.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Eth.java index 3ecc789bb1..08e45be1de 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Eth.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Eth.java @@ -41,12 +41,12 @@ public Condition accountsExceptional(final String expectedMessage) { return new ExpectEthAccountsException(transactions.accounts(), expectedMessage); } - public Condition getTransactionReceipt(final Hash transactionHash) { + public Condition expectTransactionReceipt(final Hash transactionHash) { return new ExpectEthGetTransactionReceiptIsPresent( transactions.getTransactionReceipt(transactionHash.toString())); } - public Condition getTransactionReceiptNotAvailable(final String transactionHash) { + public Condition expectNoTransactionReceipt(final String transactionHash) { return new ExpectEthGetTransactionReceiptIsAbsent( transactions.getTransactionReceipt(transactionHash)); } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java index 7f85ca768c..3ffee45827 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java @@ -37,24 +37,17 @@ public void setUp() throws Exception { } @Test - public void mustCorrectlyQueryTransactionReceiptFromContractCreationTransaction() { - final Hash transactionHash = minerNode.execute(transactions.createTransfer(recipient, 5)); - cluster.verify(recipient.balanceEquals(5)); - minerNode.verify(eth.getTransactionReceipt(transactionHash)); - } - - @Test - public void mustCorrectlyQueryTransactionReceiptFromNormalTransaction() { + public void transactionMustHaveReceipt() { final Hash transactionHash = minerNode.execute(transactions.createTransfer(sender, recipient, 5)); cluster.verify(recipient.balanceEquals(5)); - minerNode.verify(eth.getTransactionReceipt(transactionHash)); + minerNode.verify(eth.expectTransactionReceipt(transactionHash)); } @Test - public void mustReturnNullWhenTransactionDoesNotExist() { + public void mustHaveNoTransactionReceiptForImaginaryTransaction() { minerNode.verify( - eth.getTransactionReceiptNotAvailable( + eth.expectNoTransactionReceipt( "0x0000000000000000000000000000000000000000000000000000000000000000")); } } From e404973d8c723471d4c329732c524aa894546bd2 Mon Sep 17 00:00:00 2001 From: Shinabyss Date: Tue, 20 Nov 2018 15:06:18 +1000 Subject: [PATCH 08/11] Naming convention corrected Deleted obsolete test cases added assertion for status code --- .../ExpectEthGetTransactionReceiptIsPresent.java | 1 + .../tests/acceptance/dsl/jsonrpc/Eth.java | 4 ++-- .../EthGetTransactionReceiptAcceptanceTest.java | 15 ++++----------- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/ExpectEthGetTransactionReceiptIsPresent.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/ExpectEthGetTransactionReceiptIsPresent.java index 543769359b..5083359430 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/ExpectEthGetTransactionReceiptIsPresent.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/ExpectEthGetTransactionReceiptIsPresent.java @@ -35,5 +35,6 @@ public ExpectEthGetTransactionReceiptIsPresent( public void verify(final Node node) { final Optional response = node.execute(transaction); assertThat(response.isPresent()).isTrue(); + assertThat(response.get().getStatus()).isEqualToIgnoringCase("0x1"); } } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Eth.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Eth.java index 3ecc789bb1..08e45be1de 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Eth.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Eth.java @@ -41,12 +41,12 @@ public Condition accountsExceptional(final String expectedMessage) { return new ExpectEthAccountsException(transactions.accounts(), expectedMessage); } - public Condition getTransactionReceipt(final Hash transactionHash) { + public Condition expectTransactionReceipt(final Hash transactionHash) { return new ExpectEthGetTransactionReceiptIsPresent( transactions.getTransactionReceipt(transactionHash.toString())); } - public Condition getTransactionReceiptNotAvailable(final String transactionHash) { + public Condition expectNoTransactionReceipt(final String transactionHash) { return new ExpectEthGetTransactionReceiptIsAbsent( transactions.getTransactionReceipt(transactionHash)); } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java index 7f85ca768c..2c1bc84f39 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java @@ -37,24 +37,17 @@ public void setUp() throws Exception { } @Test - public void mustCorrectlyQueryTransactionReceiptFromContractCreationTransaction() { - final Hash transactionHash = minerNode.execute(transactions.createTransfer(recipient, 5)); - cluster.verify(recipient.balanceEquals(5)); - minerNode.verify(eth.getTransactionReceipt(transactionHash)); - } - - @Test - public void mustCorrectlyQueryTransactionReceiptFromNormalTransaction() { + public void transactionMustHaveReceipt() { final Hash transactionHash = minerNode.execute(transactions.createTransfer(sender, recipient, 5)); cluster.verify(recipient.balanceEquals(5)); - minerNode.verify(eth.getTransactionReceipt(transactionHash)); + minerNode.verify(eth.expectTransactionReceipt(transactionHash)); } @Test - public void mustReturnNullWhenTransactionDoesNotExist() { + public void imaginaryTransactionMustHaveNoReceipt() { minerNode.verify( - eth.getTransactionReceiptNotAvailable( + eth.expectNoTransactionReceipt( "0x0000000000000000000000000000000000000000000000000000000000000000")); } } From 41c6026cf144140c5d67445e3ba56284dc85d586 Mon Sep 17 00:00:00 2001 From: Shinabyss Date: Tue, 20 Nov 2018 15:53:13 +1000 Subject: [PATCH 09/11] Naming convention corrected --- ...t.java => ExpectSuccessfulEthGetTransactionReceipt.java} | 4 ++-- .../pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Eth.java | 6 +++--- .../acceptance/dsl/transaction/eth/EthTransactions.java | 4 ++-- .../jsonrpc/EthGetTransactionReceiptAcceptanceTest.java | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) rename acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/{ExpectEthGetTransactionReceiptIsPresent.java => ExpectSuccessfulEthGetTransactionReceipt.java} (91%) diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/ExpectEthGetTransactionReceiptIsPresent.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/ExpectSuccessfulEthGetTransactionReceipt.java similarity index 91% rename from acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/ExpectEthGetTransactionReceiptIsPresent.java rename to acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/ExpectSuccessfulEthGetTransactionReceipt.java index 5083359430..de435048a5 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/ExpectEthGetTransactionReceiptIsPresent.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/condition/eth/ExpectSuccessfulEthGetTransactionReceipt.java @@ -22,11 +22,11 @@ import org.web3j.protocol.core.methods.response.TransactionReceipt; -public class ExpectEthGetTransactionReceiptIsPresent implements Condition { +public class ExpectSuccessfulEthGetTransactionReceipt implements Condition { private final EthGetTransactionReceiptTransaction transaction; - public ExpectEthGetTransactionReceiptIsPresent( + public ExpectSuccessfulEthGetTransactionReceipt( final EthGetTransactionReceiptTransaction transaction) { this.transaction = transaction; } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Eth.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Eth.java index 08e45be1de..6d55255da6 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Eth.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Eth.java @@ -16,7 +16,7 @@ import tech.pegasys.pantheon.tests.acceptance.dsl.condition.Condition; import tech.pegasys.pantheon.tests.acceptance.dsl.condition.eth.ExpectEthAccountsException; import tech.pegasys.pantheon.tests.acceptance.dsl.condition.eth.ExpectEthGetTransactionReceiptIsAbsent; -import tech.pegasys.pantheon.tests.acceptance.dsl.condition.eth.ExpectEthGetTransactionReceiptIsPresent; +import tech.pegasys.pantheon.tests.acceptance.dsl.condition.eth.ExpectSuccessfulEthGetTransactionReceipt; import tech.pegasys.pantheon.tests.acceptance.dsl.condition.eth.ExpectEthGetWorkException; import tech.pegasys.pantheon.tests.acceptance.dsl.condition.eth.SanityCheckEthGetWorkValues; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.eth.EthTransactions; @@ -41,8 +41,8 @@ public Condition accountsExceptional(final String expectedMessage) { return new ExpectEthAccountsException(transactions.accounts(), expectedMessage); } - public Condition expectTransactionReceipt(final Hash transactionHash) { - return new ExpectEthGetTransactionReceiptIsPresent( + public Condition expectSuccessfulTransactionReceipt(final Hash transactionHash) { + return new ExpectSuccessfulEthGetTransactionReceipt( transactions.getTransactionReceipt(transactionHash.toString())); } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/eth/EthTransactions.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/eth/EthTransactions.java index 43d4b00a92..9cf73a95e1 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/eth/EthTransactions.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/transaction/eth/EthTransactions.java @@ -32,7 +32,7 @@ public EthAccountsTransaction accounts() { return new EthAccountsTransaction(); } - public EthGetTransactionReceiptTransaction getTransactionReceipt(final String param) { - return new EthGetTransactionReceiptTransaction(param); + public EthGetTransactionReceiptTransaction getTransactionReceipt(final String transactionHash) { + return new EthGetTransactionReceiptTransaction(transactionHash); } } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java index 2c1bc84f39..c3e2c37521 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java @@ -41,7 +41,7 @@ public void transactionMustHaveReceipt() { final Hash transactionHash = minerNode.execute(transactions.createTransfer(sender, recipient, 5)); cluster.verify(recipient.balanceEquals(5)); - minerNode.verify(eth.expectTransactionReceipt(transactionHash)); + minerNode.verify(eth.expectSuccessfulTransactionReceipt(transactionHash)); } @Test From b4c1054de0936cd598ea24cdf7a7fb7124614fa8 Mon Sep 17 00:00:00 2001 From: Shinabyss Date: Tue, 20 Nov 2018 15:55:56 +1000 Subject: [PATCH 10/11] Removed sender field to make test more efficient --- .../jsonrpc/EthGetTransactionReceiptAcceptanceTest.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java index c3e2c37521..2fcd2402fc 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java @@ -23,23 +23,19 @@ public class EthGetTransactionReceiptAcceptanceTest extends AcceptanceTestBase { private PantheonNode minerNode; - private Account sender; private Account recipient; @Before public void setUp() throws Exception { - sender = accounts.createAccount("sender"); recipient = accounts.createAccount("recipient"); minerNode = pantheon.createMinerNode("node"); cluster.start(minerNode); - minerNode.execute(transactions.createTransfer(sender, 10)); - cluster.verify(sender.balanceEquals(10)); } @Test public void transactionMustHaveReceipt() { final Hash transactionHash = - minerNode.execute(transactions.createTransfer(sender, recipient, 5)); + minerNode.execute(transactions.createTransfer(recipient, 5)); cluster.verify(recipient.balanceEquals(5)); minerNode.verify(eth.expectSuccessfulTransactionReceipt(transactionHash)); } From d0653fc340efae1cd9c76bb5671eec2fc79c2591 Mon Sep 17 00:00:00 2001 From: Shinabyss Date: Tue, 20 Nov 2018 16:10:51 +1000 Subject: [PATCH 11/11] Removed sender field to make test more efficient --- .../pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Eth.java | 2 +- .../jsonrpc/EthGetTransactionReceiptAcceptanceTest.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Eth.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Eth.java index 6d55255da6..10ee67b239 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Eth.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/jsonrpc/Eth.java @@ -16,8 +16,8 @@ import tech.pegasys.pantheon.tests.acceptance.dsl.condition.Condition; import tech.pegasys.pantheon.tests.acceptance.dsl.condition.eth.ExpectEthAccountsException; import tech.pegasys.pantheon.tests.acceptance.dsl.condition.eth.ExpectEthGetTransactionReceiptIsAbsent; -import tech.pegasys.pantheon.tests.acceptance.dsl.condition.eth.ExpectSuccessfulEthGetTransactionReceipt; import tech.pegasys.pantheon.tests.acceptance.dsl.condition.eth.ExpectEthGetWorkException; +import tech.pegasys.pantheon.tests.acceptance.dsl.condition.eth.ExpectSuccessfulEthGetTransactionReceipt; import tech.pegasys.pantheon.tests.acceptance.dsl.condition.eth.SanityCheckEthGetWorkValues; import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.eth.EthTransactions; diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java index 2fcd2402fc..638c57db94 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/jsonrpc/EthGetTransactionReceiptAcceptanceTest.java @@ -34,8 +34,7 @@ public void setUp() throws Exception { @Test public void transactionMustHaveReceipt() { - final Hash transactionHash = - minerNode.execute(transactions.createTransfer(recipient, 5)); + final Hash transactionHash = minerNode.execute(transactions.createTransfer(recipient, 5)); cluster.verify(recipient.balanceEquals(5)); minerNode.verify(eth.expectSuccessfulTransactionReceipt(transactionHash)); }