Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Nc 1145 Acceptance test for getTransactionReceipt JSON-RPC method #278

Merged
merged 20 commits into from
Nov 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
1ff064a
EthGetTransactionReceipt Acceptance test added
Shinabyss Nov 4, 2018
2146a6a
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss Nov 4, 2018
ef0db70
GetTransactionReceipt Acceptance Test updated to conform to new dsl
Shinabyss Nov 4, 2018
85d70a3
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss Nov 18, 2018
7c46e78
Update to new dsl
Shinabyss Nov 18, 2018
984dd7d
Update to new dsl
Shinabyss Nov 19, 2018
5f9135b
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss Nov 19, 2018
a3ec974
Update to new dsl - spotless applied
Shinabyss Nov 19, 2018
4549355
Naming convention corrected
Shinabyss Nov 20, 2018
8f1193d
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss Nov 20, 2018
90ffc61
Naming convention corrected
Shinabyss Nov 20, 2018
e404973
Naming convention corrected
Shinabyss Nov 20, 2018
4929caf
Merge remote-tracking branch 'origin/NC-1145' into NC-1145
Shinabyss Nov 20, 2018
1a581a4
Merge branch 'master' into NC-1145
Shinabyss Nov 20, 2018
41c6026
Naming convention corrected
Shinabyss Nov 20, 2018
b4c1054
Removed sender field to make test more efficient
Shinabyss Nov 20, 2018
e07ef34
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
Shinabyss Nov 20, 2018
01f3339
Merge remote-tracking branch 'origin/NC-1145' into NC-1145
Shinabyss Nov 20, 2018
d0653fc
Removed sender field to make test more efficient
Shinabyss Nov 20, 2018
42beaf4
Merge branch 'master' into NC-1145
Shinabyss Nov 20, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +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.condition.eth;

import static org.assertj.core.api.Assertions.assertThat;

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 ExpectEthGetTransactionReceiptIsAbsent implements Condition {

private final EthGetTransactionReceiptTransaction transaction;

public ExpectEthGetTransactionReceiptIsAbsent(
final EthGetTransactionReceiptTransaction transaction) {
this.transaction = transaction;
}

@Override
public void verify(final Node node) {
final Optional<TransactionReceipt> response = node.execute(transaction);
assertThat(response.isPresent()).isFalse();
}
}
Original file line number Diff line number Diff line change
@@ -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.condition.eth;

import static org.assertj.core.api.Assertions.assertThat;

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 ExpectSuccessfulEthGetTransactionReceipt implements Condition {

private final EthGetTransactionReceiptTransaction transaction;

public ExpectSuccessfulEthGetTransactionReceipt(
final EthGetTransactionReceiptTransaction transaction) {
this.transaction = transaction;
}

@Override
public void verify(final Node node) {
final Optional<TransactionReceipt> response = node.execute(transaction);
assertThat(response.isPresent()).isTrue();
assertThat(response.get().getStatus()).isEqualToIgnoringCase("0x1");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +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.ExpectEthGetTransactionReceiptIsAbsent;
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;

Expand All @@ -37,4 +40,14 @@ public Condition getWorkExceptional(final String expectedMessage) {
public Condition accountsExceptional(final String expectedMessage) {
return new ExpectEthAccountsException(transactions.accounts(), expectedMessage);
}

public Condition expectSuccessfulTransactionReceipt(final Hash transactionHash) {
return new ExpectSuccessfulEthGetTransactionReceipt(
transactions.getTransactionReceipt(transactionHash.toString()));
}

public Condition expectNoTransactionReceipt(final String transactionHash) {
return new ExpectEthGetTransactionReceiptIsAbsent(
transactions.getTransactionReceipt(transactionHash));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* 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;

public class EthGetTransactionReceiptTransaction
implements Transaction<Optional<TransactionReceipt>> {

private final String input;

EthGetTransactionReceiptTransaction(final String input) {
this.input = input;
}

@Override
public Optional<TransactionReceipt> 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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@ public EthGetBalanceTransaction getBalance(final Account account) {
public EthAccountsTransaction accounts() {
return new EthAccountsTransaction();
}

public EthGetTransactionReceiptTransaction getTransactionReceipt(final String transactionHash) {
return new EthGetTransactionReceiptTransaction(transactionHash);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* 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 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;
private Account recipient;

@Before
public void setUp() throws Exception {
recipient = accounts.createAccount("recipient");
minerNode = pantheon.createMinerNode("node");
cluster.start(minerNode);
}

@Test
public void transactionMustHaveReceipt() {
final Hash transactionHash = minerNode.execute(transactions.createTransfer(recipient, 5));
Shinabyss marked this conversation as resolved.
Show resolved Hide resolved
cluster.verify(recipient.balanceEquals(5));
minerNode.verify(eth.expectSuccessfulTransactionReceipt(transactionHash));
}

@Test
public void imaginaryTransactionMustHaveNoReceipt() {
minerNode.verify(
eth.expectNoTransactionReceipt(
"0x0000000000000000000000000000000000000000000000000000000000000000"));
}
}