use of com.hedera.services.legacy.core.jproto.JEd25519Key in project hedera-services by hashgraph.
the class PlatformSigOpsTest method ignoresAmbiguousScheduledSig.
@Test
void ignoresAmbiguousScheduledSig() throws Throwable {
final JKey scheduledKey = new JEd25519Key("01234578901234578901234578901".getBytes());
scheduledKey.setForScheduledTxn(true);
given(sigBytes.sigBytesFor(any())).willThrow(KeyPrefixMismatchException.class);
final var result = createCryptoSigsFrom(List.of(scheduledKey), sigBytes, sigFactory);
assertFalse(result.hasFailed());
assertTrue(result.getPlatformSigs().isEmpty());
}
use of com.hedera.services.legacy.core.jproto.JEd25519Key in project hedera-services by hashgraph.
the class RationalizationTest method resetWorks.
@Test
void resetWorks() {
given(txnAccessor.getPlatformTxn()).willReturn(swirldsTxn);
final List<TransactionSignature> mockSigs = new ArrayList<>();
final JKey fake = new JEd25519Key("FAKE".getBytes(StandardCharsets.UTF_8));
subject = new Rationalization(syncVerifier, keyOrderer, sigFactory);
given(txnAccessor.getPkToSigsFn()).willReturn(pkToSigFn);
given(swirldsTxn.getSignatures()).willReturn(mockSigs);
// and:
subject.getRealPayerSigs().add(null);
subject.getRealOtherPartySigs().add(null);
subject.setReqPayerSig(fake);
subject.setReqOthersSigs(List.of(fake));
subject.setLastOrderResult(CODE_ORDER_RESULT_FACTORY.forGeneralError());
subject.setFinalStatus(INVALID_ACCOUNT_ID);
subject.setVerifiedSync(true);
// when:
subject.resetFor(txnAccessor);
// then:
assertSame(txnAccessor, subject.getTxnAccessor());
assertSame(syncVerifier, subject.getSyncVerifier());
assertSame(keyOrderer, subject.getSigReqs());
assertSame(pkToSigFn, subject.getPkToSigFn());
assertSame(mockSigs, subject.getTxnSigs());
// and:
assertTrue(subject.getRealPayerSigs().isEmpty());
assertTrue(subject.getRealOtherPartySigs().isEmpty());
// and:
assertFalse(subject.usedSyncVerification());
assertNull(subject.finalStatus());
assertNull(subject.getReqPayerSig());
assertNull(subject.getReqOthersSigs());
assertNull(subject.getLastOrderResult());
// and:
verify(sigFactory).resetFor(txnAccessor);
verify(pkToSigFn).resetAllSigsToUnused();
}
use of com.hedera.services.legacy.core.jproto.JEd25519Key in project hedera-services by hashgraph.
the class PrecheckKeyReqsTest method usesBothOrderForQueryPayments.
@Test
void usesBothOrderForQueryPayments() throws Exception {
final JKey key1 = new JEd25519Key("firstKey".getBytes());
final JKey key2 = new JEd25519Key("secondKey".getBytes());
final JKey key3 = new JEd25519Key("thirdKey".getBytes());
final JKey key4 = new JEd25519Key("firstKey".getBytes());
given(keyOrder.keysForPayer(txn, CODE_ORDER_RESULT_FACTORY)).willReturn(new SigningOrderResult<>(List.of(key1)));
given(keyOrder.keysForOtherParties(txn, CODE_ORDER_RESULT_FACTORY)).willReturn(new SigningOrderResult<>(List.of(key2, key3, key4)));
givenImpliedSubject(FOR_QUERY_PAYMENT);
// when:
keys = subject.getRequiredKeys(txn);
// then:
verify(keyOrder).keysForPayer(txn, CODE_ORDER_RESULT_FACTORY);
verify(keyOrder).keysForOtherParties(txn, CODE_ORDER_RESULT_FACTORY);
verifyNoMoreInteractions(keyOrder);
assertEquals(3, keys.size());
assertTrue(keys.contains(key1));
assertTrue(keys.contains(key2));
assertTrue(keys.contains(key3));
}
use of com.hedera.services.legacy.core.jproto.JEd25519Key in project hedera-services by hashgraph.
the class CodeOrderResultFactoryTest method createsNewResultForValidOrder.
@Test
void createsNewResultForValidOrder() {
// given:
final List<JKey> pretendKeys = List.of(new JEd25519Key("IMAGINARY".getBytes(StandardCharsets.UTF_8)));
// when:
final var ans = subject.forValidOrder(pretendKeys);
// then:
assertSame(pretendKeys, ans.getOrderedKeys());
}
use of com.hedera.services.legacy.core.jproto.JEd25519Key in project hedera-services by hashgraph.
the class CommonTestUtils method createRandomMerkleAccountState.
public static MerkleAccountState createRandomMerkleAccountState(int iteration, Random random) {
byte[] key = new byte[JEd25519Key.ED25519_BYTE_LENGTH];
random.nextBytes(key);
JEd25519Key ed25519Key = new JEd25519Key(key);
return new MerkleAccountState(ed25519Key, iteration, iteration, iteration, randomString(256, random), false, false, false, new EntityId(iteration, iteration, iteration), 1001, 0);
}
Aggregations