use of com.hedera.services.bdd.spec.keys.KeyShape in project hedera-services by hashgraph.
the class CryptoCreateSuite method createAnAccountEmptyThresholdKey.
private HapiApiSpec createAnAccountEmptyThresholdKey() {
KeyShape shape = threshOf(0, 0);
long initialBalance = 10_000L;
return defaultHapiSpec("createAnAccountEmptyThresholdKey").given().when().then(cryptoCreate("noKeys").keyShape(shape).balance(initialBalance).logged().hasPrecheck(KEY_REQUIRED));
}
use of com.hedera.services.bdd.spec.keys.KeyShape in project hedera-services by hashgraph.
the class CryptoGetInfoRegression method succeedsNormally.
private HapiApiSpec succeedsNormally() {
long balance = 1_234_567L;
long autoRenew = 5_555_555L;
long sendThresh = 1_111L;
long receiveThresh = 2_222L;
long expiry = Instant.now().getEpochSecond() + autoRenew;
KeyShape misc = listOf(SIMPLE, listOf(2));
return defaultHapiSpec("SucceedsNormally").given(newKeyNamed("misc").shape(misc)).when(cryptoCreate("target").key("misc").proxy("1.2.3").balance(balance).sendThreshold(sendThresh).receiveThreshold(receiveThresh).receiverSigRequired(true).autoRenewSecs(autoRenew)).then(getAccountInfo("target").has(accountWith().accountId("target").solidityId("target").proxy("1.2.3").key("misc").balance(balance).sendThreshold(sendThresh).receiveThreshold(receiveThresh).expiry(expiry, 5L).autoRenew(autoRenew)).logged());
}
use of com.hedera.services.bdd.spec.keys.KeyShape in project hedera-services by hashgraph.
the class CreateAndUpdateOps method variousCryptoMutations.
HapiApiSpec variousCryptoMutations() {
KeyShape smallKey = SIMPLE;
KeyShape largeKey = listOf(3);
long shortExpiry = 100_000L;
long mediumExpiry = 10 * shortExpiry;
long eternalExpiry = 10 * mediumExpiry;
AtomicLong consensusNow = new AtomicLong();
return customHapiSpec("VariousCryptoMutations").withProperties(Map.of("cost.snapshot.mode", costSnapshotMode.toString())).given(newKeyNamed("sk").shape(smallKey), newKeyNamed("lk").shape(largeKey), cryptoCreate("payer").via("payerCreation").fee(feeToOffer).balance(payerBalance), withOpContext((spec, opLog) -> {
var lookup = getTxnRecord("payerCreation").nodePayment(paymentToOffer);
allRunFor(spec, lookup);
var record = lookup.getResponseRecord();
consensusNow.set(record.getConsensusTimestamp().getSeconds());
}), cryptoCreate("proxy").fee(feeToOffer)).when(cryptoCreate("sksenp").fee(feeToOffer).payingWith("payer").key("sk").autoRenewSecs(shortExpiry), cryptoCreate("sksep").fee(feeToOffer).payingWith("payer").proxy("0.0.2").key("sk").autoRenewSecs(shortExpiry), cryptoCreate("skmenp").fee(feeToOffer).payingWith("payer").key("sk").autoRenewSecs(mediumExpiry), cryptoCreate("skmep").fee(feeToOffer).payingWith("payer").proxy("0.0.2").key("sk").autoRenewSecs(mediumExpiry), cryptoCreate("skeenp").fee(feeToOffer).payingWith("payer").key("sk").autoRenewSecs(eternalExpiry), cryptoCreate("skeep").fee(feeToOffer).payingWith("payer").proxy("0.0.2").key("sk").autoRenewSecs(eternalExpiry)).then(sourcing(() -> cryptoUpdate("sksenp").fee(feeToOffer).payingWith("payer").newProxy("proxy").key("lk").expiring(consensusNow.get() + mediumExpiry)), sourcing(() -> cryptoUpdate("skmenp").fee(feeToOffer).payingWith("payer").newProxy("proxy").key("lk").expiring(consensusNow.get() + eternalExpiry)), sourcing(() -> cryptoUpdate("skeenp").fee(feeToOffer).payingWith("payer").newProxy("proxy").key("lk")), getAccountInfo("sksenp"), getAccountInfo("skmenp"), getAccountInfo("skeenp"));
}
use of com.hedera.services.bdd.spec.keys.KeyShape in project hedera-services by hashgraph.
the class KeyExport method exportGenesisKey.
private HapiApiSpec exportGenesisKey() {
final var r = new Random();
final int passphraseLength = 24;
final char[] choices = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toCharArray();
final KeyShape listOfSizeOne = listOf(1);
KeyFactory.PEM_PASSPHRASE = IntStream.range(0, passphraseLength).map(ignore -> r.nextInt(choices.length)).mapToObj(i -> Character.valueOf(choices[i]).toString()).collect(Collectors.joining(""));
return defaultHapiSpec("ExportGenesisKey").given(newKeyNamed("ab-initio").shape(listOfSizeOne)).when().then(withOpContext((spec, opLog) -> {
opLog.info("Passphrase is: {}", KeyFactory.PEM_PASSPHRASE);
spec.keys().exportSimpleWacl(PEM_FILE_NAME, "ab-initio");
}));
}
use of com.hedera.services.bdd.spec.keys.KeyShape in project hedera-services by hashgraph.
the class R5BugChecks method enforcesSigRequirements.
private HapiApiSpec enforcesSigRequirements() {
KeyShape complexSrShape = listOf(SIMPLE, threshOf(1, 3));
SigControl activeSig = complexSrShape.signedWith(sigs(ON, sigs(OFF, OFF, ON)));
SigControl inactiveSig = complexSrShape.signedWith(sigs(OFF, sigs(ON, ON, ON)));
return defaultHapiSpec("EnforcesSigRequirements").given(newKeyNamed("srKey").shape(complexSrShape), fileCreate("bytecode").path(ContractResources.LAST_TRACKING_SENDER_BYTECODE_PATH), contractCreate("sponsor").bytecode("bytecode").balance(10), cryptoCreate("noSr").balance(0L), cryptoCreate("sr").key("srKey").balance(0L).receiverSigRequired(true)).when(contractCall("sponsor", ContractResources.TRACKING_SEND_ABI, spec -> new Object[] { (int) spec.registry().getAccountID("sr").getAccountNum(), 5 }).hasKnownStatus(INVALID_SIGNATURE), contractCall("sponsor", ContractResources.TRACKING_SEND_ABI, spec -> new Object[] { (int) spec.registry().getAccountID("sr").getAccountNum(), 5 }).signedBy(GENESIS, "sr").sigControl(ControlForKey.forKey("sr", inactiveSig)).hasKnownStatus(INVALID_SIGNATURE), contractCallLocal("sponsor", ContractResources.HOW_MUCH_ABI).has(resultWith().resultThruAbi(ContractResources.HOW_MUCH_ABI, isLiteralResult(new Object[] { BigInteger.valueOf(0) }))), getAccountBalance("sr").hasTinyBars(0L)).then(contractCall("sponsor", ContractResources.TRACKING_SEND_ABI, spec -> new Object[] { (int) spec.registry().getAccountID("noSr").getAccountNum(), 1 }), contractCall("sponsor", ContractResources.TRACKING_SEND_ABI, spec -> new Object[] { (int) spec.registry().getAccountID("sr").getAccountNum(), 5 }).signedBy(GENESIS, "sr").sigControl(ControlForKey.forKey("sr", activeSig)), contractCallLocal("sponsor", ContractResources.HOW_MUCH_ABI).has(resultWith().resultThruAbi(ContractResources.HOW_MUCH_ABI, isLiteralResult(new Object[] { BigInteger.valueOf(5) }))), getAccountBalance("sr").hasTinyBars(5L), getAccountBalance("noSr").hasTinyBars(1L));
}
Aggregations