Skip to content

Commit

Permalink
Tidy up naming
Browse files Browse the repository at this point in the history
  • Loading branch information
antonydenyer committed Jul 12, 2022
1 parent d201621 commit 95c6d71
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 36 deletions.
18 changes: 9 additions & 9 deletions src/test/java/com/quorum/gauge/AccumulatorSmartContract.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public void setupAccumulatorPublicContract(String source, int initVal, String co
DataStoreFactory.getScenarioDataStore().put(contractName, contract);
}

@Step("Deploy a <privacyFlags> accumulator contract in <source>'s default account with initial value <initVal> and it's private for <privateFor>, name this contract as <contractName>")
public void setupAccumulatorContract(String privacyFlags, String source, int initVal, String privateFor, String contractName) {
@Step("Deploy a <privacyFlag> accumulator contract in <source>'s default account with initial value <initVal> and it's private for <privateFor>, name this contract as <contractName>")
public void setupAccumulatorContract(String privacyFlag, String source, int initVal, String privateFor, String contractName) {
saveCurrentBlockNumber();
logger.debug("Setting up storage master from {} to {}", source, privateFor);

Expand All @@ -75,7 +75,7 @@ public void setupAccumulatorContract(String privacyFlags, String source, int ini
networkProperty.getNode(source),
privateForList,
AbstractService.DEFAULT_GAS_LIMIT, initVal,
privacyService.parsePrivacyFlag(privacyFlags)
privacyService.parsePrivacyFlag(privacyFlag)
).blockingFirst();

DataStoreFactory.getSpecDataStore().put(contractName, contract);
Expand Down Expand Up @@ -151,8 +151,8 @@ public void incAccumulatorPublicContract(int value, String contract, String sour
DataStoreFactory.getScenarioDataStore().put(txReference, receipt.getTransactionHash());
}

@Step("Invoke a <privacyFlags> accumulator.inc with value <value> in contract <contract> in <source>'s default account and it's private for <privateFor>, file transaction hash as <txReference>")
public void incAccumulatorPrivateContract(String privacyFlags, int value, String contract, String source, String privateFor, String txReference) {
@Step("Invoke a <privacyFlag> accumulator.inc with value <value> in contract <contract> in <source>'s default account and it's private for <privateFor>, file transaction hash as <txReference>")
public void incAccumulatorPrivateContract(String privacyFlag, int value, String contract, String source, String privateFor, String txReference) {
Contract c = mustHaveValue(DataStoreFactory.getSpecDataStore(), contract, Contract.class);
saveCurrentBlockNumber();
List<QuorumNetworkProperty.Node> privateForList = Arrays.stream(privateFor.split(","))
Expand All @@ -162,14 +162,14 @@ public void incAccumulatorPrivateContract(String privacyFlags, int value, String
TransactionReceipt receipt = accumulatorService.incAccumulatorPrivate(
networkProperty.getNode(source), privateForList, c.getContractAddress(), AbstractService.DEFAULT_GAS_LIMIT,
value,
privacyService.parsePrivacyFlag(privacyFlags)
privacyService.parsePrivacyFlag(privacyFlag)
).blockingFirst();
DataStoreFactory.getSpecDataStore().put(txReference, receipt.getTransactionHash());
DataStoreFactory.getScenarioDataStore().put(txReference, receipt.getTransactionHash());
}

@Step("Invoking a <privacyFlags> accumulator.inc with value <value> in contract <contract> in <source>'s default account and it's private for <privateFor> fails with error <error>")
public void incAccumulatorPrivateContractFailsWithError(String privacyFlags, int value, String contract, String source, String privateFor, String error) {
@Step("Invoking a <privacyFlag> accumulator.inc with value <value> in contract <contract> in <source>'s default account and it's private for <privateFor> fails with error <error>")
public void incAccumulatorPrivateContractFailsWithError(String privacyFlag, int value, String contract, String source, String privateFor, String error) {
Contract c = mustHaveValue(DataStoreFactory.getSpecDataStore(), contract, Contract.class);
saveCurrentBlockNumber();
List<QuorumNetworkProperty.Node> privateForList = Arrays.stream(privateFor.split(","))
Expand All @@ -180,7 +180,7 @@ public void incAccumulatorPrivateContractFailsWithError(String privacyFlags, int
() -> accumulatorService.incAccumulatorPrivate(
networkProperty.getNode(source), privateForList, c.getContractAddress(), AbstractService.DEFAULT_GAS_LIMIT,
value,
privacyService.parsePrivacyFlag(privacyFlags))
privacyService.parsePrivacyFlag(privacyFlag))
.blockingFirst()
).as("Expected exception thrown")
.hasMessageContaining(error);
Expand Down
18 changes: 9 additions & 9 deletions src/test/java/com/quorum/gauge/NestedPrivateContract.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ public void setupC1Contract(int initialValue, QuorumNode source, QuorumNode targ
DataStoreFactory.getScenarioDataStore().put(contractName, contract);
}

@Step("Deploy a <privacyFlags> C1 contract with initial value <initialValue> in <source>'s default account and it's private for <target>, named this contract as <contractName>")
public void setupC1Contract(String privacyFlags, int initialValue, QuorumNode source, QuorumNode target, String contractName) {
@Step("Deploy a <privacyFlag> C1 contract with initial value <initialValue> in <source>'s default account and it's private for <target>, named this contract as <contractName>")
public void setupC1Contract(String privacyFlag, int initialValue, QuorumNode source, QuorumNode target, String contractName) {
logger.debug("Setting up contract from {} to {}", source, target);
saveCurrentBlockNumber();
Contract contract = nestedContractService.createC1Contract(
initialValue,
source,
Arrays.asList(target),
privacyService.parsePrivacyFlag(privacyFlags)
privacyService.parsePrivacyFlag(privacyFlag)
).blockingFirst();

DataStoreFactory.getSpecDataStore().put(contractName, contract);
Expand All @@ -75,31 +75,31 @@ public void setupC2Contract(String c1Address, QuorumNode source, QuorumNode targ
DataStoreFactory.getScenarioDataStore().put(contractName, contract);
}

@Step("Deploy a <privacyFlags> C2 contract with initial value <c1Address> in <source>'s default account and it's private for <target>, named this contract as <contractName>")
public void setupC2Contract(String privacyFlags, String c1Address, QuorumNode source, QuorumNode target, String contractName) {
@Step("Deploy a <privacyFlag> C2 contract with initial value <c1Address> in <source>'s default account and it's private for <target>, named this contract as <contractName>")
public void setupC2Contract(String privacyFlag, String c1Address, QuorumNode source, QuorumNode target, String contractName) {
logger.debug("Setting up contract from {} to {}", source, target);
Contract c1 = (Contract) DataStoreFactory.getSpecDataStore().get(c1Address);
Contract contract = nestedContractService.createC2Contract(
c1.getContractAddress(),
source,
Arrays.asList(target),
privacyService.parsePrivacyFlag(privacyFlags)
privacyService.parsePrivacyFlag(privacyFlag)
).blockingFirst();

DataStoreFactory.getSpecDataStore().put(contractName, contract);
DataStoreFactory.getScenarioDataStore().put(contractName, contract);
}

@Step("Execute <privacyFlags> <contractName>'s `newContractC2()` function with new value <newValue> in <source> and it's private for <target>")
public void callNewContractC2(String privacyFlags, String contractName, int newValue, QuorumNode source, String target) {
@Step("Execute <privacyFlag> <contractName>'s `newContractC2()` function with new value <newValue> in <source> and it's private for <target>")
public void callNewContractC2(String privacyFlag, String contractName, int newValue, QuorumNode source, String target) {
Contract c1 = mustHaveValue(contractName, Contract.class);

TransactionReceipt receipt = nestedContractService.newContractC2(
source,
Arrays.stream(target.split(",")).map(s -> QuorumNode.valueOf(s)).collect(Collectors.toList()),
c1.getContractAddress(),
BigInteger.valueOf(newValue),
privacyService.parsePrivacyFlag(privacyFlags)).blockingFirst();
privacyService.parsePrivacyFlag(privacyFlag)).blockingFirst();
Gauge.writeMessage("Transaction Hash %s", receipt.getTransactionHash());
DataStoreFactory.getScenarioDataStore().put("transactionHash", receipt.getTransactionHash());
}
Expand Down
12 changes: 6 additions & 6 deletions src/test/java/com/quorum/gauge/PrivateSmartContract.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,27 +68,27 @@ public void setupContract(int initialValue, QuorumNode source, QuorumNode target
setupContract("STANDARD_PRIVATE", initialValue, source, target, contractName);
}

@Step("Deploy a <privacyFlags> simple smart contract with initial value <initialValue> in <source>'s default account and it's private for <target>, named this contract as <contractName>")
public void setupContract(String privacyFlags, int initialValue, QuorumNode source, QuorumNode target, String contractName) {
@Step("Deploy a <privacyFlag> simple smart contract with initial value <initialValue> in <source>'s default account and it's private for <target>, named this contract as <contractName>")
public void setupContract(String privacyFlag, int initialValue, QuorumNode source, QuorumNode target, String contractName) {
saveCurrentBlockNumber();
logger.debug("Setting up contract from {} to {}", source, target);
Contract contract = contractService.createSimpleContract(
initialValue,
source,
null, Arrays.asList(target),
AbstractService.DEFAULT_GAS_LIMIT,
privacyService.parsePrivacyFlag(privacyFlags)
privacyService.parsePrivacyFlag(privacyFlag)
).blockingFirst();

DataStoreFactory.getSpecDataStore().put(contractName, contract);
DataStoreFactory.getScenarioDataStore().put(contractName, contract);
DataStoreFactory.getScenarioDataStore().put("transactionHash", contract.getTransactionReceipt().get().getTransactionHash());
}

@Step("Deploying a <privacyFlags> simple smart contract with initial value <initialValue> in <source>'s default account and it's private for <target> fails with message <failureMessage>")
public void setupContractFailsWithMessage(String privacyFlags, int initialValue, QuorumNode source, QuorumNode target, String failureMessage) {
@Step("Deploying a <privacyFlag> simple smart contract with initial value <initialValue> in <source>'s default account and it's private for <target> fails with message <failureMessage>")
public void setupContractFailsWithMessage(String privacyFlag, int initialValue, QuorumNode source, QuorumNode target, String failureMessage) {
saveCurrentBlockNumber();
var flags = privacyService.parsePrivacyFlag(privacyFlags);
var flags = privacyService.parsePrivacyFlag(privacyFlag);
logger.debug("Setting up contract from {} to {} with {}", source, target, flags);
try {
contractService.createSimpleContract(
Expand Down
24 changes: 12 additions & 12 deletions src/test/java/com/quorum/gauge/StorageMasterSmartContract.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,59 +63,59 @@ public void setupSimpleStorageFromStorageMasterPublicContract(String storageMast
DataStoreFactory.getScenarioDataStore().put(contractName, ssChild);
}

@Step("Deploy a <privacyFlags> storage master contract in <source>'s default account and it's private for <target>, named this contract as <contractName>")
public void setupStorageMasterContract(String privacyFlags, QuorumNode source, QuorumNode target, String contractName) {
@Step("Deploy a <privacyFlag> storage master contract in <source>'s default account and it's private for <target>, named this contract as <contractName>")
public void setupStorageMasterContract(String privacyFlag, QuorumNode source, QuorumNode target, String contractName) {
saveCurrentBlockNumber();
logger.debug("Setting up storage master from {} to {}", source, target);
Contract contract = storageMasterService.createStorageMasterContract(
source,
Collections.singletonList(target),
AbstractService.DEFAULT_GAS_LIMIT,
privacyService.parsePrivacyFlag(privacyFlags)
privacyService.parsePrivacyFlag(privacyFlag)
).blockingFirst();

DataStoreFactory.getSpecDataStore().put(contractName, contract);
DataStoreFactory.getScenarioDataStore().put(contractName, contract);
}

@Step("Deploy a <privacyFlags> simple storage from master storage contract <storageMaster> in <source>'s default account and it's private for <target>, named this contract as <contractName>")
public void setupSimpleStorageFromStorageMasterContract(String privacyFlags, String storageMaster, QuorumNode source, QuorumNode target, String contractName) {
@Step("Deploy a <privacyFlag> simple storage from master storage contract <storageMaster> in <source>'s default account and it's private for <target>, named this contract as <contractName>")
public void setupSimpleStorageFromStorageMasterContract(String privacyFlag, String storageMaster, QuorumNode source, QuorumNode target, String contractName) {
Contract c = mustHaveValue(DataStoreFactory.getSpecDataStore(), storageMaster, Contract.class);
saveCurrentBlockNumber();
logger.debug("Setting up simple storage from storage master contract from {}", source);
Contract ssChild = storageMasterService.createSimpleStorageFromStorageMaster(
source, Collections.singletonList(target), c.getContractAddress(), AbstractService.DEFAULT_GAS_LIMIT,
10,
privacyService.parsePrivacyFlag(privacyFlags)
privacyService.parsePrivacyFlag(privacyFlag)
).blockingFirst();

DataStoreFactory.getSpecDataStore().put(contractName, ssChild);
DataStoreFactory.getScenarioDataStore().put(contractName, ssChild);
}

@Step("Deploy a <privacyFlags> simple storage C2C3 with value <value> from master storage contract <storageMaster> in <source>'s default account and it's private for <target>")
public void setupSimpleStorageC2C3FromStorageMasterContract(String privacyFlags, int value, String storageMaster, QuorumNode source, QuorumNode target) {
@Step("Deploy a <privacyFlag> simple storage C2C3 with value <value> from master storage contract <storageMaster> in <source>'s default account and it's private for <target>")
public void setupSimpleStorageC2C3FromStorageMasterContract(String privacyFlag, int value, String storageMaster, QuorumNode source, QuorumNode target) {
Contract c = mustHaveValue(DataStoreFactory.getSpecDataStore(), storageMaster, Contract.class);
saveCurrentBlockNumber();
logger.debug("Setting up simple storage C2C3 from storage master contract from {}", source);
TransactionReceipt receipt = storageMasterService.createSimpleStorageC2C3FromStorageMaster(
source, Collections.singletonList(target), c.getContractAddress(), AbstractService.DEFAULT_GAS_LIMIT,
value,
privacyService.parsePrivacyFlag(privacyFlags)
privacyService.parsePrivacyFlag(privacyFlag)
).blockingFirst();

assertThat(receipt.isStatusOK()).isTrue();
}

@Step("Invoke a <privacyFlags> setC2C3Value with value <value> in master storage contract <storageMaster> in <source>'s default account and it's private for <target>")
public void setC2C3FromStorageMasterPublicContract(String privacyFlags, int value, String storageMaster, QuorumNode source, QuorumNode target) {
@Step("Invoke a <privacyFlag> setC2C3Value with value <value> in master storage contract <storageMaster> in <source>'s default account and it's private for <target>")
public void setC2C3FromStorageMasterPublicContract(String privacyFlag, int value, String storageMaster, QuorumNode source, QuorumNode target) {
Contract c = mustHaveValue(DataStoreFactory.getSpecDataStore(), storageMaster, Contract.class);
saveCurrentBlockNumber();
logger.debug("Invoking setC2V3Value in storage master contract from {}", source);
TransactionReceipt receipt = storageMasterService.setC2C3ValueFromStorageMaster(
source, Collections.singletonList(target), c.getContractAddress(), AbstractService.DEFAULT_GAS_LIMIT,
value,
privacyService.parsePrivacyFlag(privacyFlags)
privacyService.parsePrivacyFlag(privacyFlag)
).blockingFirst();
}

Expand Down

0 comments on commit 95c6d71

Please sign in to comment.