Search in sources :

Example 6 with PlatformTxnAccessor

use of com.hedera.services.utils.PlatformTxnAccessor in project hedera-services by hashgraph.

the class HederaToPlatformSigOpsTest method doesNothingToTxnIfAllSigsAreRational.

@Test
void doesNothingToTxnIfAllSigsAreRational() throws Exception {
    wellBehavedOrdersAndSigSources();
    platformTxn = new PlatformTxnAccessor(PlatformTxnFactory.withClearFlag(platformTxn.getPlatformTxn()));
    platformTxn.getPlatformTxn().addAll(asValid(expectedSigsWithNoErrors()).toArray(new TransactionSignature[0]));
    final SyncVerifier syncVerifier = l -> {
        throw new AssertionError("All sigs were verified async!");
    };
    final var rationalization = new Rationalization(syncVerifier, keyOrdering, new ReusableBodySigningFactory());
    rationalization.performFor(platformTxn);
    assertFalse(rationalization.usedSyncVerification());
    assertEquals(OK, rationalization.finalStatus());
    assertEquals(expectedSigsWithNoErrors(), platformTxn.getPlatformTxn().getSignatures());
    assertTrue(allVerificationStatusesAre(VerificationStatus.VALID::equals));
    assertFalse(((PlatformTxnFactory.TransactionWithClearFlag) platformTxn.getPlatformTxn()).hasClearBeenCalled());
}
Also used : SyncVerifier(com.hedera.services.sigs.verification.SyncVerifier) PubKeyToSigBytes(com.hedera.services.sigs.sourcing.PubKeyToSigBytes) BeforeEach(org.junit.jupiter.api.BeforeEach) OK(com.hederahashgraph.api.proto.java.ResponseCodeEnum.OK) KeyPrefixMismatchException(com.hedera.services.legacy.exception.KeyPrefixMismatchException) NodeFactory.ed25519(com.hedera.test.factories.keys.NodeFactory.ed25519) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) KEY_PREFIX_MISMATCH(com.hederahashgraph.api.proto.java.ResponseCodeEnum.KEY_PREFIX_MISMATCH) SigRequirements(com.hedera.services.sigs.order.SigRequirements) SigWrappers.asValid(com.hedera.test.factories.sigs.SigWrappers.asValid) PlatformTxnFactory(com.hedera.test.factories.txns.PlatformTxnFactory) ArrayList(java.util.ArrayList) CODE_ORDER_RESULT_FACTORY(com.hedera.services.sigs.order.CodeOrderResultFactory.CODE_ORDER_RESULT_FACTORY) BDDMockito.any(org.mockito.BDDMockito.any) ArgumentCaptor(org.mockito.ArgumentCaptor) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) BeforeAll(org.junit.jupiter.api.BeforeAll) BDDMockito.given(org.mockito.BDDMockito.given) BiConsumer(java.util.function.BiConsumer) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) PlatformTxnAccessor(com.hedera.services.utils.PlatformTxnAccessor) SigningOrderResult(com.hedera.services.sigs.order.SigningOrderResult) HederaToPlatformSigOps.expandIn(com.hedera.services.sigs.HederaToPlatformSigOps.expandIn) KeyType(com.hedera.services.sigs.sourcing.KeyType) SystemDeleteFactory.newSignedSystemDelete(com.hedera.test.factories.txns.SystemDeleteFactory.newSignedSystemDelete) ALWAYS_VALID(com.hedera.test.factories.sigs.SyncVerifiers.ALWAYS_VALID) ReusableBodySigningFactory(com.hedera.services.sigs.factories.ReusableBodySigningFactory) Predicate(java.util.function.Predicate) SigObserver(com.hedera.services.sigs.sourcing.SigObserver) PlatformSigFactory(com.hedera.services.sigs.factories.PlatformSigFactory) VerificationStatus(com.swirlds.common.crypto.VerificationStatus) BDDMockito.willAnswer(org.mockito.BDDMockito.willAnswer) Mockito.verify(org.mockito.Mockito.verify) RationalizedSigMeta(com.hedera.services.utils.RationalizedSigMeta) Test(org.junit.jupiter.api.Test) TransactionSignature(com.swirlds.common.crypto.TransactionSignature) INVALID_ACCOUNT_ID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_ACCOUNT_ID) List(java.util.List) JKey(com.hedera.services.legacy.core.jproto.JKey) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) SyncVerifier(com.hedera.services.sigs.verification.SyncVerifier) BDDMockito.mock(org.mockito.BDDMockito.mock) KeyTree(com.hedera.test.factories.keys.KeyTree) VerificationStatus(com.swirlds.common.crypto.VerificationStatus) PlatformTxnAccessor(com.hedera.services.utils.PlatformTxnAccessor) TransactionSignature(com.swirlds.common.crypto.TransactionSignature) PlatformTxnFactory(com.hedera.test.factories.txns.PlatformTxnFactory) ReusableBodySigningFactory(com.hedera.services.sigs.factories.ReusableBodySigningFactory) Test(org.junit.jupiter.api.Test)

Aggregations

PlatformTxnAccessor (com.hedera.services.utils.PlatformTxnAccessor)6 Test (org.junit.jupiter.api.Test)4 BeforeEach (org.junit.jupiter.api.BeforeEach)3 SigRequirements (com.hedera.services.sigs.order.SigRequirements)2 PubKeyToSigBytes (com.hedera.services.sigs.sourcing.PubKeyToSigBytes)2 MockAccountNumbers (com.hedera.services.config.MockAccountNumbers)1 TransactionContext (com.hedera.services.context.TransactionContext)1 GlobalDynamicProperties (com.hedera.services.context.properties.GlobalDynamicProperties)1 HFileMeta (com.hedera.services.files.HFileMeta)1 JContractIDKey (com.hedera.services.legacy.core.jproto.JContractIDKey)1 JKey (com.hedera.services.legacy.core.jproto.JKey)1 KeyPrefixMismatchException (com.hedera.services.legacy.exception.KeyPrefixMismatchException)1 HederaToPlatformSigOps.expandIn (com.hedera.services.sigs.HederaToPlatformSigOps.expandIn)1 PlatformSigFactory (com.hedera.services.sigs.factories.PlatformSigFactory)1 ReusableBodySigningFactory (com.hedera.services.sigs.factories.ReusableBodySigningFactory)1 CODE_ORDER_RESULT_FACTORY (com.hedera.services.sigs.order.CodeOrderResultFactory.CODE_ORDER_RESULT_FACTORY)1 SigningOrderResult (com.hedera.services.sigs.order.SigningOrderResult)1 KeyType (com.hedera.services.sigs.sourcing.KeyType)1 SigObserver (com.hedera.services.sigs.sourcing.SigObserver)1 SyncVerifier (com.hedera.services.sigs.verification.SyncVerifier)1