Search in sources :

Example 16 with KeyShape

use of com.hedera.services.bdd.spec.keys.KeyShape in project hedera-services by hashgraph.

the class PermissionSemanticsSpec method allowsDeleteWithOneTopLevelSig.

private HapiApiSpec allowsDeleteWithOneTopLevelSig() {
    KeyShape wacl = KeyShape.listOf(KeyShape.SIMPLE, KeyShape.listOf(2));
    var deleteSig = wacl.signedWith(sigs(ON, sigs(OFF, OFF)));
    var failedDeleteSig = wacl.signedWith(sigs(OFF, sigs(OFF, ON)));
    var updateSig = wacl.signedWith(sigs(ON, sigs(ON, ON)));
    var failedUpdateSig = wacl.signedWith(sigs(ON, sigs(OFF, ON)));
    return defaultHapiSpec("AllowsDeleteWithOneTopLevelSig").given(newKeyNamed("wacl").shape(wacl)).when(fileCreate("tbd").key("wacl")).then(fileUpdate("tbd").contents("Some more contents!").signedBy(GENESIS, "wacl").sigControl(ControlForKey.forKey("wacl", failedUpdateSig)).hasKnownStatus(INVALID_SIGNATURE), fileUpdate("tbd").contents("Some new contents!").signedBy(GENESIS, "wacl").sigControl(ControlForKey.forKey("wacl", updateSig)), fileDelete("tbd").signedBy(GENESIS, "wacl").sigControl(ControlForKey.forKey("wacl", failedDeleteSig)).hasKnownStatus(INVALID_SIGNATURE), fileDelete("tbd").signedBy(GENESIS, "wacl").sigControl(ControlForKey.forKey("wacl", deleteSig)));
}
Also used : KeyShape(com.hedera.services.bdd.spec.keys.KeyShape)

Example 17 with KeyShape

use of com.hedera.services.bdd.spec.keys.KeyShape in project hedera-services by hashgraph.

the class CryptoCreateSuite method createAnAccountEmptyKeyList.

private HapiApiSpec createAnAccountEmptyKeyList() {
    KeyShape shape = listOf(0);
    long initialBalance = 10_000L;
    return defaultHapiSpec("createAnAccountEmptyKeyList").given().when().then(cryptoCreate("noKeys").keyShape(shape).balance(initialBalance).logged().hasPrecheck(KEY_REQUIRED));
}
Also used : KeyShape(com.hedera.services.bdd.spec.keys.KeyShape)

Example 18 with KeyShape

use of com.hedera.services.bdd.spec.keys.KeyShape in project hedera-services by hashgraph.

the class CryptoCreateSuite method createAnAccountEmptyNestedKey.

private HapiApiSpec createAnAccountEmptyNestedKey() {
    KeyShape emptyThresholdShape = threshOf(0, 0);
    KeyShape emptyListShape = listOf(0);
    KeyShape shape = threshOf(2, emptyThresholdShape, emptyListShape);
    long initialBalance = 10_000L;
    return defaultHapiSpec("createAnAccountEmptyThresholdKey").given().when().then(cryptoCreate("noKeys").keyShape(shape).balance(initialBalance).logged().hasPrecheck(KEY_REQUIRED));
}
Also used : KeyShape(com.hedera.services.bdd.spec.keys.KeyShape)

Example 19 with KeyShape

use of com.hedera.services.bdd.spec.keys.KeyShape in project hedera-services by hashgraph.

the class CryptoCreateSuite method createAnAccountInvalidNestedKeyList.

// One of element in nested key list is not valid
private HapiApiSpec createAnAccountInvalidNestedKeyList() {
    KeyShape invalidListShape = listOf(SIMPLE, SIMPLE, listOf(0));
    KeyShape shape = listOf(SIMPLE, SIMPLE, invalidListShape);
    long initialBalance = 10_000L;
    return defaultHapiSpec("createAnAccountInvalidNestedKeyList").given().when().then(cryptoCreate("noKeys").keyShape(shape).balance(initialBalance).logged().hasPrecheck(BAD_ENCODING));
}
Also used : KeyShape(com.hedera.services.bdd.spec.keys.KeyShape)

Example 20 with KeyShape

use of com.hedera.services.bdd.spec.keys.KeyShape in project hedera-services by hashgraph.

the class CryptoCreateSuite method createAnAccountThresholdKeyWithInvalidThreshold.

private HapiApiSpec createAnAccountThresholdKeyWithInvalidThreshold() {
    KeyShape thresholdShape0 = threshOf(0, SIMPLE, SIMPLE, SIMPLE);
    KeyShape thresholdShape4 = threshOf(4, SIMPLE, SIMPLE, SIMPLE);
    long initialBalance = 10_000L;
    return defaultHapiSpec("createAnAccountThresholdKeyWithInvalidThreshold").given().when().then(cryptoCreate("badThresholdKeyAccount1").keyShape(thresholdShape0).balance(initialBalance).logged().hasPrecheck(BAD_ENCODING), cryptoCreate("badThresholdKeyAccount2").keyShape(thresholdShape4).balance(initialBalance).logged().hasPrecheck(BAD_ENCODING));
}
Also used : KeyShape(com.hedera.services.bdd.spec.keys.KeyShape)

Aggregations

KeyShape (com.hedera.services.bdd.spec.keys.KeyShape)30 SigControl (com.hedera.services.bdd.spec.keys.SigControl)11 HapiApiSpec (com.hedera.services.bdd.spec.HapiApiSpec)9 KeyShape.listOf (com.hedera.services.bdd.spec.keys.KeyShape.listOf)9 List (java.util.List)9 LogManager (org.apache.logging.log4j.LogManager)9 Logger (org.apache.logging.log4j.Logger)9 SIMPLE (com.hedera.services.bdd.spec.keys.KeyShape.SIMPLE)8 UtilVerbs.withOpContext (com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext)8 HapiApiSuite (com.hedera.services.bdd.suites.HapiApiSuite)8 HapiApiSpec.defaultHapiSpec (com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec)7 KeyShape.threshOf (com.hedera.services.bdd.spec.keys.KeyShape.threshOf)6 UtilVerbs.newKeyNamed (com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyNamed)6 Map (java.util.Map)6 TxnVerbs.cryptoCreate (com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate)5 TxnVerbs.fileCreate (com.hedera.services.bdd.spec.transactions.TxnVerbs.fileCreate)5 TxnVerbs.fileUpdate (com.hedera.services.bdd.spec.transactions.TxnVerbs.fileUpdate)5 HapiApiSpec.customHapiSpec (com.hedera.services.bdd.spec.HapiApiSpec.customHapiSpec)4 QueryVerbs.getAccountInfo (com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountInfo)4 QueryVerbs.getFileInfo (com.hedera.services.bdd.spec.queries.QueryVerbs.getFileInfo)4