use of com.hederahashgraph.api.proto.java.KeyList in project hedera-services by hashgraph.
the class JKeyListTest method validJKeyListTest.
@Test
void validJKeyListTest() throws Exception {
Key validED25519Key = Key.newBuilder().setEd25519(TxnUtils.randomUtf8ByteString(JEd25519Key.ED25519_BYTE_LENGTH)).build();
Key validECDSAsecp256k1Key = randomValidECDSASecp256K1Key();
Key validECDSA384Key = Key.newBuilder().setECDSA384(TxnUtils.randomUtf8ByteString(24)).build();
KeyList validKeyList1 = KeyList.newBuilder().addKeys(validECDSA384Key).addKeys(validED25519Key).build();
Key validKey1 = Key.newBuilder().setKeyList(validKeyList1).build();
KeyList validKeyList2 = KeyList.newBuilder().addKeys(validED25519Key).addKeys(validKey1).build();
Key validKey2 = Key.newBuilder().setKeyList(validKeyList2).build();
KeyList validKeyList3 = KeyList.newBuilder().addKeys(validED25519Key).addKeys(validKey2).build();
Key validKey3 = Key.newBuilder().setKeyList(validKeyList3).build();
KeyList validKeyList4 = KeyList.newBuilder().addKeys(validECDSAsecp256k1Key).addKeys(validKey3).build();
Key validKey4 = Key.newBuilder().setKeyList(validKeyList4).build();
JKey jKeyList1 = JKey.convertKey(validKey1, 1);
assertTrue(jKeyList1.isValid());
JKey jKeyList2 = JKey.convertKey(validKey2, 1);
assertTrue(jKeyList2.isValid());
JKey jKeyList3 = JKey.convertKey(validKey3, 1);
assertTrue(jKeyList3.isValid());
JKey jKeyList4 = JKey.convertKey(validKey4, 1);
assertTrue(jKeyList4.isValid());
}
use of com.hederahashgraph.api.proto.java.KeyList in project hedera-services by hashgraph.
the class FileOpsUsageTest method estimatesUpdateAsExpected.
@Test
void estimatesUpdateAsExpected() {
// setup:
long oldExpiry = expiry - 1_234L;
byte[] oldContents = "Archiac".getBytes();
KeyList oldWacl = KeyUtils.A_KEY_LIST.getKeyList();
String oldMemo = "Lettuce";
// and:
long bytesUsed = reprSize() - FileOpsUsage.bytesInBaseRepr();
// and:
long oldSbs = (oldExpiry - now) * (oldContents.length + oldMemo.length() + getAccountKeyStorageSize(Key.newBuilder().setKeyList(oldWacl).build()));
// and:
long newSbs = (expiry - now) * bytesUsed;
givenUpdateOp();
// and:
var ctx = ExtantFileContext.newBuilder().setCurrentExpiry(oldExpiry).setCurrentMemo(oldMemo).setCurrentWacl(oldWacl).setCurrentSize(oldContents.length).build();
// when:
var estimate = subject.fileUpdateUsage(txn, sigUsage, ctx);
// then:
assertEquals(A_USAGES_MATRIX, estimate);
// and:
verify(base).addBpt(bytesUsed + BASIC_ENTITY_ID_SIZE + LONG_SIZE);
verify(base).addSbs(newSbs - oldSbs);
}
use of com.hederahashgraph.api.proto.java.KeyList in project hedera-services by hashgraph.
the class FeeBuilderTest method assertCalculateKeysMetadataThresholdKey.
@Test
void assertCalculateKeysMetadataThresholdKey() {
int[] countKeyMetatData = { 0, 0 };
KeyList thresholdKeyList = KeyList.newBuilder().addKeys(Key.newBuilder().setEd25519(ByteString.copyFromUtf8("aaaaaaaa")).build()).addKeys(Key.newBuilder().setEd25519(ByteString.copyFromUtf8("bbbbbbbbbbbbbbbbbbbbb")).build()).build();
ThresholdKey thresholdKey = ThresholdKey.newBuilder().setKeys(thresholdKeyList).setThreshold(2).build();
Key validED25519Keys = Key.newBuilder().setThresholdKey(thresholdKey).build();
assertEquals(countKeyMetatData.length, FeeBuilder.calculateKeysMetadata(validED25519Keys, countKeyMetatData).length);
assertEquals(2, FeeBuilder.calculateKeysMetadata(validED25519Keys, countKeyMetatData)[1]);
}
Aggregations