Search in sources :

Example 1 with PrivateFillTransaction

use of com.quorum.gauge.ext.filltx.PrivateFillTransaction in project quorum-acceptance-tests by ConsenSys.

the class FillTransaction method sendFillTransaction.

@Step("Deploy Simple Storage contract using fillTransaction api with an initial value of <initValue> called from <from> private for <to>. Name this contract as <contractName>")
public void sendFillTransaction(int initValue, QuorumNode from, QuorumNode to, String contractName) {
    com.quorum.gauge.ext.filltx.FillTransaction filledTx = rawContractService.fillTransaction(from, to, initValue).blockingFirst().getResponseObject();
    if (filledTx == null) {
        // possible that tessera is older version which is leading to test case failure. skip
        // further filltx tests.
        DataStoreFactory.getSpecDataStore().put("skipFillTXTests", true);
    } else {
        assertThat(!filledTx.getRaw().isEmpty());
        DataStoreFactory.getSpecDataStore().put("skipFillTXTests", false);
        PrivateFillTransaction tx = filledTx.getPrivateTransaction(accountService.getDefaultAccountAddress(from).blockingFirst(), Arrays.asList(privacyService.id(to)));
        com.quorum.gauge.ext.filltx.FillTransaction fTx = rawContractService.signTransaction(from, tx).blockingFirst().getResponseObject();
        assertThat(!fTx.getRaw().isEmpty());
        String txHash = rawContractService.sendRawPrivateTransaction(from, fTx.getRaw(), to).blockingFirst().getTransactionHash();
        assertThat(!txHash.isEmpty());
        // if the transaction is accepted, its receipt must be available in any node
        Predicate<? super EthGetTransactionReceipt> isReceiptPresent = ethGetTransactionReceipt -> ethGetTransactionReceipt.getTransactionReceipt().isPresent();
        Optional<TransactionReceipt> receipt = transactionService.getTransactionReceipt(QuorumNode.Node1, txHash).repeatWhen(completed -> completed.delay(2, TimeUnit.SECONDS)).takeUntil(isReceiptPresent).timeout(10, TimeUnit.SECONDS).blockingLast().getTransactionReceipt();
        assertThat(receipt.isPresent()).isTrue();
        assertThat(receipt.get().getBlockNumber()).isNotEqualTo(currentBlockNumber());
        assertThat(!receipt.get().getContractAddress().isEmpty());
        Contract c = loadSimpleStorageContract(receipt.get().getContractAddress(), receipt.get());
        DataStoreFactory.getSpecDataStore().put(contractName, c);
    }
}
Also used : Contract(org.web3j.tx.Contract) AbstractSpecImplementation(com.quorum.gauge.core.AbstractSpecImplementation) Arrays(java.util.Arrays) Step(com.thoughtworks.gauge.Step) Logger(org.slf4j.Logger) QuorumNode(com.quorum.gauge.common.QuorumNode) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) AssertionsForClassTypes(org.assertj.core.api.AssertionsForClassTypes) LoggerFactory(org.slf4j.LoggerFactory) PrivateFillTransaction(com.quorum.gauge.ext.filltx.PrivateFillTransaction) Predicate(io.reactivex.functions.Predicate) SimpleStorage(com.quorum.gauge.sol.SimpleStorage) EthGetTransactionReceipt(org.web3j.protocol.core.methods.response.EthGetTransactionReceipt) TimeUnit(java.util.concurrent.TimeUnit) TransactionReceipt(org.web3j.protocol.core.methods.response.TransactionReceipt) Context(com.quorum.gauge.common.Context) Service(org.springframework.stereotype.Service) TransactionManager(org.web3j.tx.TransactionManager) Optional(java.util.Optional) EthGetQuorumPayload(com.quorum.gauge.ext.EthGetQuorumPayload) DataStoreFactory(com.thoughtworks.gauge.datastore.DataStoreFactory) EthGetTransactionReceipt(org.web3j.protocol.core.methods.response.EthGetTransactionReceipt) TransactionReceipt(org.web3j.protocol.core.methods.response.TransactionReceipt) Contract(org.web3j.tx.Contract) PrivateFillTransaction(com.quorum.gauge.ext.filltx.PrivateFillTransaction) Step(com.thoughtworks.gauge.Step)

Aggregations

Context (com.quorum.gauge.common.Context)1 QuorumNode (com.quorum.gauge.common.QuorumNode)1 AbstractSpecImplementation (com.quorum.gauge.core.AbstractSpecImplementation)1 EthGetQuorumPayload (com.quorum.gauge.ext.EthGetQuorumPayload)1 PrivateFillTransaction (com.quorum.gauge.ext.filltx.PrivateFillTransaction)1 SimpleStorage (com.quorum.gauge.sol.SimpleStorage)1 Step (com.thoughtworks.gauge.Step)1 DataStoreFactory (com.thoughtworks.gauge.datastore.DataStoreFactory)1 Predicate (io.reactivex.functions.Predicate)1 Arrays (java.util.Arrays)1 Optional (java.util.Optional)1 TimeUnit (java.util.concurrent.TimeUnit)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 AssertionsForClassTypes (org.assertj.core.api.AssertionsForClassTypes)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 Service (org.springframework.stereotype.Service)1 EthGetTransactionReceipt (org.web3j.protocol.core.methods.response.EthGetTransactionReceipt)1 TransactionReceipt (org.web3j.protocol.core.methods.response.TransactionReceipt)1 Contract (org.web3j.tx.Contract)1