use of com.hederahashgraph.api.proto.java.ResponseCodeEnum.BAD_ENCODING 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.hederahashgraph.api.proto.java.ResponseCodeEnum.BAD_ENCODING in project hedera-services by hashgraph.
the class CryptoCreateSuite method createAnAccountInvalidED25519.
private HapiApiSpec createAnAccountInvalidED25519() {
long initialBalance = 10_000L;
Key emptyKey = Key.newBuilder().setEd25519(ByteString.EMPTY).build();
Key shortKey = Key.newBuilder().setEd25519(ByteString.copyFrom(new byte[10])).build();
return defaultHapiSpec("createAnAccountInvalidED25519").given().when().then(withOpContext((spec, opLog) -> {
spec.registry().saveKey("shortKey", shortKey);
spec.registry().saveKey("emptyKey", emptyKey);
}), cryptoCreate("shortKey").key("shortKey").balance(initialBalance).signedBy(GENESIS).logged().hasPrecheck(BAD_ENCODING), cryptoCreate("emptyKey").key("emptyKey").balance(initialBalance).signedBy(GENESIS).logged().hasPrecheck(BAD_ENCODING));
}
Aggregations