use of com.thoughtworks.gauge.datastore.DataStore in project quorum-acceptance-tests by ConsenSys.
the class ContractExtension method acceptExtension.
@Step("<newNode> accepts the offer to extend the contract <contractName>")
public void acceptExtension(final QuorumNetworkProperty.Node newNode, final String contractName) {
final DataStore store = DataStoreFactory.getScenarioDataStore();
final PrivacyFlag privacyFlag = mustHaveValue(store, "privacyFlag", PrivacyFlag.class);
final String contractAddress = mustHaveValue(store, contractName + "extensionAddress", String.class);
final Set<QuorumNetworkProperty.Node> allNodes = mustHaveValue(store, "extensionAllNodes", Set.class);
final QuorumVoteOnContract result = this.extensionService.acceptExtension(newNode, true, contractAddress, allNodes, privacyFlag).blockingFirst();
if (result.getError() != null) {
logger.error(result.getError().toString());
}
assertThat(result.getError()).isNull();
final Optional<TransactionReceipt> transactionReceipt = transactionService.pollTransactionReceipt(newNode, result.getResult());
assertThat(transactionReceipt.isPresent()).isTrue();
assertThat(transactionReceipt.get().getStatus()).isEqualTo("0x1");
}
use of com.thoughtworks.gauge.datastore.DataStore in project quorum-acceptance-tests by ConsenSys.
the class ContractExtension method updatePartiesForContract.
@Step("<node> requests parties are updated for contract <contractName>")
public void updatePartiesForContract(final QuorumNetworkProperty.Node node, final String contractName) {
final DataStore store = DataStoreFactory.getScenarioDataStore();
final PrivacyFlag privacyFlag = mustHaveValue(store, "privacyFlag", PrivacyFlag.class);
final String contractAddress = mustHaveValue(store, contractName + "extensionAddress", String.class);
final Set<QuorumNetworkProperty.Node> allNodes = mustHaveValue(store, "extensionAllNodes", Set.class);
final QuorumUpdateParties result = this.extensionService.updateParties(node, contractAddress, allNodes, privacyFlag).blockingFirst();
assertThat(result.getError()).isNull();
final Optional<TransactionReceipt> transactionReceipt = transactionService.pollTransactionReceipt(node, result.getResult());
assertThat(transactionReceipt.isPresent()).isTrue();
assertThat(transactionReceipt.get().getStatus()).isEqualTo("0x1");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
use of com.thoughtworks.gauge.datastore.DataStore in project quorum-acceptance-tests by ConsenSys.
the class ContractExtension method rejectExtension.
@Step("<node> rejects contract extension of <contractName>")
public void rejectExtension(final QuorumNetworkProperty.Node node, final String contractName) {
final DataStore store = DataStoreFactory.getScenarioDataStore();
final PrivacyFlag privacyFlag = mustHaveValue(store, "privacyFlag", PrivacyFlag.class);
final String contractAddress = mustHaveValue(store, contractName + "extensionAddress", String.class);
final Set<QuorumNetworkProperty.Node> allNodes = mustHaveValue(store, "extensionAllNodes", Set.class);
final QuorumVoteOnContract voteResult = this.extensionService.acceptExtension(node, false, contractAddress, allNodes, privacyFlag).blockingFirst();
assertThat(voteResult.getError()).isNull();
final Optional<TransactionReceipt> transactionReceipt = transactionService.pollTransactionReceipt(node, voteResult.getResult());
assertThat(transactionReceipt.isPresent()).isTrue();
assertThat(transactionReceipt.get().getStatus()).isEqualTo("0x1");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
use of com.thoughtworks.gauge.datastore.DataStore in project quorum-acceptance-tests by ConsenSys.
the class ContractExtension method extensionCompleted.
@Step("Wait for <contractName> to disappear from active extension in <node>")
public void extensionCompleted(final String contractName, final QuorumNetworkProperty.Node node) {
final Contract contract = mustHaveValue(contractName, Contract.class);
Optional<String> accessToken = haveValue(DataStoreFactory.getScenarioDataStore(), "access_token", String.class);
accessToken.ifPresent(Context::storeAccessToken);
try {
int count = 0;
while (true) {
count++;
final QuorumActiveExtensionContracts result = this.extensionService.getExtensionContracts(node).blockingFirst();
final Optional<Map<Object, Object>> first = result.getResult().stream().filter(contractStatus -> contractStatus.containsValue(contract.getContractAddress())).findFirst();
if ((!first.isPresent()) || (count > 25)) {
break;
} else {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
final DataStore store = DataStoreFactory.getScenarioDataStore();
final String contractAddress = mustHaveValue(store, contractName + "extensionAddress", String.class);
String status = extensionService.getExtensionStatus(node, contractAddress);
int i = 0;
if (!status.equals("DONE")) {
while (true) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
i++;
status = extensionService.getExtensionStatus(node, contractAddress);
if ((i > 25) || status.equals("DONE")) {
break;
}
}
}
assertThat(status).describedAs("Extension must be successfully completed").isEqualTo("DONE");
} finally {
Context.removeAccessToken();
}
}
use of com.thoughtworks.gauge.datastore.DataStore in project quorum-acceptance-tests by ConsenSys.
the class EstimateGas method updateContractUsingEstimatedGas.
@Step("Update contract <contractName> with value <value>, from <from> to <privateFor> using estimated gas")
public void updateContractUsingEstimatedGas(final String contractName, final int value, final QuorumNode from, final QuorumNode privateFor) {
final DataStore specStore = DataStoreFactory.getSpecDataStore();
final DataStore scenarioStore = DataStoreFactory.getScenarioDataStore();
final Contract contract = mustHaveValue(specStore, contractName, Contract.class);
final String contractAddress = contract.getContractAddress();
final EthEstimateGas estimatedGasResult = mustHaveValue(scenarioStore, "estimatedValue", EthEstimateGas.class);
final BigInteger estimatedGasLimit = estimatedGasResult.getAmountUsed();
final TransactionReceipt receipt = contractService.updateSimpleContractWithGasLimit(from, Arrays.asList(privateFor), contractAddress, estimatedGasLimit, value, Arrays.asList(PrivacyFlag.StandardPrivate)).blockingFirst();
assertThat(receipt.isStatusOK()).isTrue();
}
Aggregations