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

Commit

Permalink
Wait for private Tx receipt in acceptance tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Puneetha17 committed Mar 4, 2019
1 parent 2979d66 commit cbb9ca5
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import tech.pegasys.pantheon.tests.acceptance.dsl.contract.ContractVerifier;
import tech.pegasys.pantheon.tests.acceptance.dsl.jsonrpc.Admin;
import tech.pegasys.pantheon.tests.acceptance.dsl.jsonrpc.Clique;
import tech.pegasys.pantheon.tests.acceptance.dsl.jsonrpc.Eea;
import tech.pegasys.pantheon.tests.acceptance.dsl.jsonrpc.Eth;
import tech.pegasys.pantheon.tests.acceptance.dsl.jsonrpc.Ibft;
import tech.pegasys.pantheon.tests.acceptance.dsl.jsonrpc.Login;
Expand All @@ -27,6 +28,7 @@
import tech.pegasys.pantheon.tests.acceptance.dsl.node.factory.PantheonNodeFactory;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transactions;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.clique.CliqueTransactions;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.eea.EeaTransactions;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.eth.EthTransactions;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.ibft.IbftTransactions;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.net.NetTransactions;
Expand All @@ -47,6 +49,7 @@ public class AcceptanceTestBase {
protected final Ibft ibft;
protected final Web3 web3;
protected final Eth eth;
protected final Eea eea;
protected final Login login;
protected final Net net;
protected final Perm perm;
Expand All @@ -57,9 +60,11 @@ public class AcceptanceTestBase {

protected AcceptanceTestBase() {
final EthTransactions ethTransactions = new EthTransactions();
final EeaTransactions eeaTransactions = new EeaTransactions();
accounts = new Accounts(ethTransactions);
blockchain = new Blockchain(ethTransactions);
eth = new Eth(ethTransactions);
eea = new Eea(eeaTransactions);
cliqueTransactions = new CliqueTransactions();
ibftTransactions = new IbftTransactions();

Expand Down
Original file line number Diff line number Diff line change
@@ -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.eea;

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.ResponseTypes;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.eea.EeaGetTransactionReceiptTransaction;

public class ExpectSuccessfulEeaGetTransactionReceipt implements Condition {

private final EeaGetTransactionReceiptTransaction transaction;

public ExpectSuccessfulEeaGetTransactionReceipt(
final EeaGetTransactionReceiptTransaction transaction) {
this.transaction = transaction;
}

@Override
public void verify(final Node node) {
final ResponseTypes.PrivateTransactionReceipt response = node.execute(transaction);
assertThat(response.getContractAddress()).isNotEqualTo("0x");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2019 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.jsonrpc;

import tech.pegasys.pantheon.tests.acceptance.dsl.condition.Condition;
import tech.pegasys.pantheon.tests.acceptance.dsl.condition.eea.ExpectSuccessfulEeaGetTransactionReceipt;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.eea.EeaTransactions;

public class Eea {

EeaTransactions transactions;

public Eea(final EeaTransactions transactions) {
this.transactions = transactions;
}

public Condition expectSuccessfulTransactionReceipt(
final String transactionHash, final String publicKey) {
return new ExpectSuccessfulEeaGetTransactionReceipt(
transactions.getTransactionReceipt(transactionHash, publicKey));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright 2019 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.eea;

public class EeaTransactions {

public EeaGetTransactionReceiptTransaction getTransactionReceipt(
final String transactionHash, final String pubKey) {
return new EeaGetTransactionReceiptTransaction(transactionHash, pubKey);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,10 @@ public void deployingMustGiveValidReceipt() {
final String signedRawDeployTransaction = toRlp(DEPLOY_CONTRACT);
final String transactionHash =
minerNode.execute(transactions.createPrivateRawTransaction(signedRawDeployTransaction));
minerNode.waitUntil(wait.chainHeadHasProgressedByAtLeast(minerNode, 2));
waitFor(() -> minerNode.verify(eth.expectSuccessfulTransactionReceipt(transactionHash)));
waitFor(
90,
() ->
minerNode.verify(eea.expectSuccessfulTransactionReceipt(transactionHash, PUBLIC_KEY)));
TransactionReceipt txReceipt =
minerNode.execute(transactions.getTransactionReceipt(transactionHash)).get();

Expand All @@ -184,8 +186,11 @@ public void deployingMustGiveValidReceipt() {
final String transactionHashSet =
minerNode.execute(
transactions.createPrivateRawTransaction(signedRawSetFunctionTransaction));
minerNode.waitUntil(wait.chainHeadHasProgressedByAtLeast(minerNode, 2));
waitFor(() -> minerNode.verify(eth.expectSuccessfulTransactionReceipt(transactionHashSet)));
waitFor(
90,
() ->
minerNode.verify(
eea.expectSuccessfulTransactionReceipt(transactionHashSet, PUBLIC_KEY)));
PrivateTransactionReceipt privateTxReceiptSet =
minerNode.execute(
transactions.getPrivateTransactionReceipt(transactionHashSet, PUBLIC_KEY));
Expand All @@ -196,8 +201,11 @@ public void deployingMustGiveValidReceipt() {
final String transactionHashGet =
minerNode.execute(
transactions.createPrivateRawTransaction(signedRawGetFunctionTransaction));
minerNode.waitUntil(wait.chainHeadHasProgressedByAtLeast(minerNode, 2));
waitFor(() -> minerNode.verify(eth.expectSuccessfulTransactionReceipt(transactionHashGet)));
waitFor(
90,
() ->
minerNode.verify(
eea.expectSuccessfulTransactionReceipt(transactionHashGet, PUBLIC_KEY)));
PrivateTransactionReceipt privateTxReceiptGet =
minerNode.execute(
transactions.getPrivateTransactionReceipt(transactionHashGet, PUBLIC_KEY));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.JsonRpcMethod;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.parameters.JsonRpcParameter;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.queries.BlockchainQueries;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcError;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcErrorResponse;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcResponse;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.results.privacy.PrivateTransactionReceiptResult;
Expand Down Expand Up @@ -115,6 +117,10 @@ public JsonRpcResponse response(final JsonRpcRequest request) {
}
})
.orElse(null);
if (result == null) {
return new JsonRpcErrorResponse(
request.getId(), JsonRpcError.PRIVATE_TRANSACTION_RECEIPT_ERROR);
}
return new JsonRpcSuccessResponse(request.getId(), result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ public enum JsonRpcError {

// Private transaction errors
ENCLAVE_IS_DOWN(-50100, "Enclave is down"),
UNIMPLEMENTED_PRIVATE_TRANSACTION_TYPE(-50100, "Unimplemented private transaction type");
UNIMPLEMENTED_PRIVATE_TRANSACTION_TYPE(-50100, "Unimplemented private transaction type"),
PRIVATE_TRANSACTION_RECEIPT_ERROR(-50100, "Error generating the private transaction receipt");

private final int code;
private final String message;
Expand Down

0 comments on commit cbb9ca5

Please sign in to comment.