use of com.quorum.tessera.recovery.resend.PushBatchRequest in project tessera by ConsenSys.
the class BatchResendManagerImplTest method testStoreResendBatchMultipleVersions.
@Test
public void testStoreResendBatchMultipleVersions() {
try (var payloadDigestMockedStatic = mockStatic(PayloadDigest.class);
var payloadEncoderMockedStatic = mockStatic(PayloadEncoder.class)) {
payloadDigestMockedStatic.when(PayloadDigest::create).thenReturn((PayloadDigest) cipherText -> cipherText);
payloadEncoderMockedStatic.when(() -> PayloadEncoder.create(any())).thenReturn(payloadEncoder);
final EncodedPayload encodedPayload = EncodedPayload.Builder.create().withSenderKey(publicKey).withCipherText("cipherText".getBytes()).withCipherTextNonce(new Nonce("nonce".getBytes())).withRecipientBoxes(singletonList("box".getBytes())).withRecipientNonce(new Nonce("recipientNonce".getBytes())).withRecipientKeys(singletonList(PublicKey.from("receiverKey".getBytes()))).withPrivacyMode(PrivacyMode.STANDARD_PRIVATE).withAffectedContractTransactions(emptyMap()).withExecHash(new byte[0]).build();
when(payloadEncoder.decode(any())).thenReturn(encodedPayload);
final byte[] raw = new PayloadEncoderImpl().encode(encodedPayload);
PushBatchRequest request = PushBatchRequest.from(List.of(raw), EncodedPayloadCodec.LEGACY);
StagingTransaction existing = new StagingTransaction();
when(stagingEntityDAO.retrieveByHash(any())).thenReturn(Optional.of(existing));
when(stagingEntityDAO.update(any(StagingTransaction.class))).thenReturn(new StagingTransaction());
manager.storeResendBatch(request);
verify(stagingEntityDAO).save(any(StagingTransaction.class));
verify(payloadEncoder).decode(any());
verify(payloadEncoder).encodedPayloadCodec();
payloadDigestMockedStatic.verify(PayloadDigest::create);
payloadDigestMockedStatic.verifyNoMoreInteractions();
}
}
Aggregations