Search in sources :

Example 6 with KeyShape

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));
}
Also used : KeyShape(com.hedera.services.bdd.spec.keys.KeyShape)

Example 7 with KeyShape

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));
}
Also used : KeyShape(com.hedera.services.bdd.spec.keys.KeyShape)

Example 8 with KeyShape

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));
}
Also used : TxnVerbs.cryptoCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate) UtilVerbs.withOpContext(com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext) TxnVerbs.cryptoTransfer(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer) TxnVerbs.fileUpdate(com.hedera.services.bdd.spec.transactions.TxnVerbs.fileUpdate) KeyShape.listOf(com.hedera.services.bdd.spec.keys.KeyShape.listOf) QueryVerbs.getAccountInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountInfo) HapiApiSuite(com.hedera.services.bdd.suites.HapiApiSuite) Map(java.util.Map) HapiApiSpec.defaultHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec) KEY_REQUIRED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.KEY_REQUIRED) KeyShape(com.hedera.services.bdd.spec.keys.KeyShape) KeyList(com.hederahashgraph.api.proto.java.KeyList) HapiCryptoTransfer.tinyBarsFromTo(com.hedera.services.bdd.spec.transactions.crypto.HapiCryptoTransfer.tinyBarsFromTo) UtilVerbs.validateChargedUsd(com.hedera.services.bdd.spec.utilops.UtilVerbs.validateChargedUsd) REQUESTED_NUM_AUTOMATIC_ASSOCIATIONS_EXCEEDS_ASSOCIATION_LIMIT(com.hederahashgraph.api.proto.java.ResponseCodeEnum.REQUESTED_NUM_AUTOMATIC_ASSOCIATIONS_EXCEEDS_ASSOCIATION_LIMIT) TxnVerbs.tokenCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenCreate) INVALID_ZERO_BYTE_IN_STRING(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_ZERO_BYTE_IN_STRING) QueryVerbs.getAccountBalance(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance) TxnUtils.randomUtf8Bytes(com.hedera.services.bdd.spec.transactions.TxnUtils.randomUtf8Bytes) KeyShape.threshOf(com.hedera.services.bdd.spec.keys.KeyShape.threshOf) ByteString(com.google.protobuf.ByteString) SIMPLE(com.hedera.services.bdd.spec.keys.KeyShape.SIMPLE) Key(com.hederahashgraph.api.proto.java.Key) List(java.util.List) Logger(org.apache.logging.log4j.Logger) AUTORENEW_DURATION_NOT_IN_RANGE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.AUTORENEW_DURATION_NOT_IN_RANGE) ThresholdKey(com.hederahashgraph.api.proto.java.ThresholdKey) BAD_ENCODING(com.hederahashgraph.api.proto.java.ResponseCodeEnum.BAD_ENCODING) TxnVerbs.contractCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCreate) INSUFFICIENT_TX_FEE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_TX_FEE) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) LogManager(org.apache.logging.log4j.LogManager) ThresholdKey(com.hederahashgraph.api.proto.java.ThresholdKey) KeyList(com.hederahashgraph.api.proto.java.KeyList) KeyShape(com.hedera.services.bdd.spec.keys.KeyShape) Key(com.hederahashgraph.api.proto.java.Key) ThresholdKey(com.hederahashgraph.api.proto.java.ThresholdKey)

Example 9 with KeyShape

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"));
}
Also used : KeyShape(com.hedera.services.bdd.spec.keys.KeyShape)

Example 10 with KeyShape

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)));
}
Also used : SigControl(com.hedera.services.bdd.spec.keys.SigControl) 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