use of com.hedera.services.sigs.verification.SyncVerifier in project hedera-services by hashgraph.
the class SigOpsRegressionTest method invokeRationalizationScenario.
private Rationalization invokeRationalizationScenario() {
// setup:
SyncVerifier syncVerifier = new CryptoEngine()::verifySync;
final var hfsSigMetaLookup = new HfsSigMetaLookup(hfs, fileNumbers);
SigMetadataLookup sigMetaLookups = defaultLookupsFor(aliasManager, hfsSigMetaLookup, () -> accounts, () -> null, ref -> null, ref -> null);
SigRequirements keyOrder = new SigRequirements(sigMetaLookups, mockSignatureWaivers);
// given:
final var rationalization = new Rationalization(syncVerifier, keyOrder, new ReusableBodySigningFactory());
rationalization.performFor(platformTxn);
return rationalization;
}
use of com.hedera.services.sigs.verification.SyncVerifier in project hedera-services by hashgraph.
the class SigVerifierRegressionTest method setupFor.
private void setupFor(TxnHandlingScenario scenario) throws Throwable {
accounts = scenario.accounts();
platformTxn = scenario.platformTxn();
aliasManager = mock(AliasManager.class);
keyOrder = new SigRequirements(defaultLookupsFor(aliasManager, null, () -> accounts, () -> null, ref -> null, ref -> null), mockSignatureWaivers);
final var nodeInfo = mock(NodeInfo.class);
given(nodeInfo.selfAccount()).willReturn(DEFAULT_NODE);
isQueryPayment = PrecheckUtils.queryPaymentTestFor(nodeInfo);
SyncVerifier syncVerifier = new CryptoEngine()::verifySync;
precheckKeyReqs = new PrecheckKeyReqs(keyOrder, isQueryPayment);
precheckVerifier = new PrecheckVerifier(syncVerifier, precheckKeyReqs);
}
use of com.hedera.services.sigs.verification.SyncVerifier in project hedera-services by hashgraph.
the class HederaToPlatformSigOpsTest method rationalizesOnlyMissingSigs.
@Test
void rationalizesOnlyMissingSigs() throws Exception {
wellBehavedOrdersAndSigSources();
platformTxn.getPlatformTxn().addAll(asValid(expectedSigsWithOtherPartiesCreationError()).toArray(new TransactionSignature[0]));
final SyncVerifier syncVerifier = l -> {
if (l.equals(expectedSigsWithOtherPartiesCreationError())) {
throw new AssertionError("Payer sigs were verified async!");
} else {
ALWAYS_VALID.verifySync(l);
}
};
final var mockAccessor = mock(PlatformTxnAccessor.class);
final var captor = ArgumentCaptor.forClass(RationalizedSigMeta.class);
givenMirrorMock(mockAccessor, platformTxn);
final var rationalization = new Rationalization(syncVerifier, keyOrdering, new ReusableBodySigningFactory());
rationalization.performFor(mockAccessor);
assertTrue(rationalization.usedSyncVerification());
assertEquals(OK, rationalization.finalStatus());
verify(mockAccessor).setSigMeta(captor.capture());
final var sigMeta = captor.getValue();
platformTxn.setSigMeta(sigMeta);
assertEquals(expectedSigsWithNoErrors(), platformTxn.getSigMeta().verifiedSigs());
assertTrue(allVerificationStatusesAre(VerificationStatus.VALID::equals));
}
use of com.hedera.services.sigs.verification.SyncVerifier 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());
}
Aggregations