mirror of https://github.com/hyperledger/besu
Nc 1145 Acceptance test for getTransactionReceipt JSON-RPC method (#278)
* EthGetTransactionReceipt Acceptance test added * GetTransactionReceipt Acceptance Test updated to conform to new dsl * Update to new dsl * Update to new dsl * Update to new dsl - spotless applied * Naming convention corrected * Naming convention corrected Deleted obsolete test cases added assertion for status code * Naming convention corrected Deleted obsolete test cases added assertion for status code * Naming convention corrected * Removed sender field to make test more efficient * Removed sender field to make test more efficient
parent
33ac7e1ec9
commit
c555993648
@ -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(); |
||||
} |
||||
} |
@ -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"); |
||||
} |
||||
} |
@ -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); |
||||
} |
||||
} |
||||
} |
@ -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)); |
||||
cluster.verify(recipient.balanceEquals(5)); |
||||
minerNode.verify(eth.expectSuccessfulTransactionReceipt(transactionHash)); |
||||
} |
||||
|
||||
@Test |
||||
public void imaginaryTransactionMustHaveNoReceipt() { |
||||
minerNode.verify( |
||||
eth.expectNoTransactionReceipt( |
||||
"0x0000000000000000000000000000000000000000000000000000000000000000")); |
||||
} |
||||
} |
Loading…
Reference in new issue