use of com.hedera.services.bdd.spec.keys.KeyShape in project hedera-services by hashgraph.
the class CryptoCreateSuite method createAnAccountInvalidNestedThresholdKey.
// createAnAccountInvalidNestedThresholdKey
private HapiApiSpec createAnAccountInvalidNestedThresholdKey() {
KeyShape goodShape = threshOf(2, 3);
KeyShape thresholdShape0 = threshOf(0, SIMPLE, SIMPLE, SIMPLE);
KeyShape thresholdShape4 = threshOf(4, SIMPLE, SIMPLE, SIMPLE);
KeyShape badShape0 = threshOf(1, thresholdShape0, SIMPLE, SIMPLE);
KeyShape badShape4 = threshOf(1, SIMPLE, thresholdShape4, SIMPLE);
KeyShape shape0 = threshOf(3, badShape0, goodShape, goodShape, goodShape);
KeyShape shape4 = threshOf(3, goodShape, badShape4, goodShape, goodShape);
long initialBalance = 10_000L;
return defaultHapiSpec("createAnAccountInvalidNestedKeyList").given().when().then(cryptoCreate("noKeys").keyShape(shape0).balance(initialBalance).logged().hasPrecheck(BAD_ENCODING), cryptoCreate("noKeys").keyShape(shape4).balance(initialBalance).logged().hasPrecheck(BAD_ENCODING));
}
use of com.hedera.services.bdd.spec.keys.KeyShape in project hedera-services by hashgraph.
the class CryptoCreateSuite method createAnAccountInvalidKeyList.
// One of element in key list is not valid
private HapiApiSpec createAnAccountInvalidKeyList() {
KeyShape emptyThresholdShape = threshOf(0, 0);
KeyShape shape = listOf(SIMPLE, SIMPLE, emptyThresholdShape);
long initialBalance = 10_000L;
return defaultHapiSpec("createAnAccountInvalidKeyList").given().when().then(cryptoCreate("noKeys").keyShape(shape).balance(initialBalance).logged().hasPrecheck(BAD_ENCODING));
}
use of com.hedera.services.bdd.spec.keys.KeyShape in project hedera-services by hashgraph.
the class CryptoCreateSuite method createAnAccountInvalidThresholdKey.
// One of element in threshold key is not valid
private HapiApiSpec createAnAccountInvalidThresholdKey() {
KeyShape emptyListShape = listOf(0);
KeyShape thresholdShape = threshOf(1, SIMPLE, SIMPLE, emptyListShape);
long initialBalance = 10_000L;
// build a threshold key with one of key is invalid
Key randomKey1 = Key.newBuilder().setEd25519(ByteString.copyFrom(randomUtf8Bytes(32))).build();
Key randomKey2 = Key.newBuilder().setEd25519(ByteString.copyFrom(randomUtf8Bytes(32))).build();
Key shortKey = Key.newBuilder().setEd25519(ByteString.copyFrom(new byte[10])).build();
KeyList invalidKeyList = KeyList.newBuilder().addKeys(randomKey1).addKeys(randomKey2).addKeys(shortKey).build();
ThresholdKey invalidThresholdKey = ThresholdKey.newBuilder().setThreshold(2).setKeys(invalidKeyList).build();
Key regKey1 = Key.newBuilder().setThresholdKey(invalidThresholdKey).build();
Key regKey2 = Key.newBuilder().setKeyList(invalidKeyList).build();
return defaultHapiSpec("createAnAccountInvalidThresholdKey").given().when().then(withOpContext((spec, opLog) -> {
spec.registry().saveKey("regKey1", regKey1);
spec.registry().saveKey("regKey2", regKey2);
}), cryptoCreate("badThresholdKeyAccount").keyShape(thresholdShape).balance(initialBalance).logged().hasPrecheck(BAD_ENCODING), cryptoCreate("badThresholdKeyAccount2").key("regKey1").balance(initialBalance).logged().signedBy(GENESIS).hasPrecheck(BAD_ENCODING), cryptoCreate("badThresholdKeyAccount3").key("regKey2").balance(initialBalance).logged().signedBy(GENESIS).hasPrecheck(BAD_ENCODING));
}
use of com.hedera.services.bdd.spec.keys.KeyShape in project hedera-services by hashgraph.
the class CostOfEverythingSuite method cryptoGetAccountInfoHappyPath.
HapiApiSpec cryptoGetAccountInfoHappyPath() {
KeyShape smallKey = threshOf(1, 3);
KeyShape midsizeKey = listOf(SIMPLE, listOf(2), threshOf(1, 2));
KeyShape hugeKey = threshOf(4, SIMPLE, SIMPLE, listOf(4), listOf(3), listOf(2));
return customHapiSpec("CryptoGetAccountInfoHappyPath").withProperties(Map.of("cost.snapshot.mode", costSnapshotMode.toString())).given(newKeyNamed("smallKey").shape(smallKey), newKeyNamed("midsizeKey").shape(midsizeKey), newKeyNamed("hugeKey").shape(hugeKey)).when(cryptoCreate("small").key("smallKey"), cryptoCreate("midsize").key("midsizeKey"), cryptoCreate("huge").key("hugeKey")).then(getAccountInfo("small"), getAccountInfo("midsize"), getAccountInfo("huge"));
}
use of com.hedera.services.bdd.spec.keys.KeyShape in project hedera-services by hashgraph.
the class GuidedTourRemoteSuite method topLevelListBehavesAsRevocationService.
/* Feature is pending; top-level KeyList should allow deletion with an active
signature for any ONE of its child keys active. (I.e. a top-level KeyList
behaves as a revocation service.)
NOTE: KeyLists lower in the key hierarchy still require all child keys
to have active signatures.
*/
private HapiApiSpec topLevelListBehavesAsRevocationService() {
KeyShape waclShape = listOf(SIMPLE, threshOf(2, 3));
SigControl deleteSigControl = waclShape.signedWith(sigs(OFF, sigs(ON, ON, OFF)));
return customFailingHapiSpec("TopLevelListBehavesAsRevocationService").withProperties(Map.of("host", "34.74.191.8")).given(fileCreate("target").waclShape(waclShape)).when().then(fileDelete("target").sigControl(ControlForKey.forKey("target", deleteSigControl)));
}
Aggregations