Search in sources :

Example 1 with PayloadDigest

use of com.quorum.tessera.enclave.PayloadDigest in project tessera by ConsenSys.

the class ResendManagerProviderTest method provider.

@Test
public void provider() {
    try (var mockedEncryptedTransactionDAO = mockStatic(EncryptedTransactionDAO.class);
        var mockedEnclave = mockStatic(Enclave.class);
        var mockedStaticPayloadDigest = mockStatic(PayloadDigest.class)) {
        Enclave enclave = mock(Enclave.class);
        mockedEnclave.when(Enclave::create).thenReturn(enclave);
        mockedEncryptedTransactionDAO.when(EncryptedTransactionDAO::create).thenReturn(mock(EncryptedTransactionDAO.class));
        mockedStaticPayloadDigest.when(PayloadDigest::create).thenReturn(mock(PayloadDigest.class));
        ResendManager resendManager = ResendManagerProvider.provider();
        assertThat(resendManager).isNotNull();
        mockedEncryptedTransactionDAO.verify(EncryptedTransactionDAO::create);
        mockedEncryptedTransactionDAO.verifyNoMoreInteractions();
        mockedEnclave.verify(Enclave::create);
        mockedEnclave.verifyNoMoreInteractions();
        mockedStaticPayloadDigest.verify(PayloadDigest::create);
        mockedStaticPayloadDigest.verifyNoMoreInteractions();
    }
}
Also used : ResendManager(com.quorum.tessera.transaction.resend.ResendManager) Enclave(com.quorum.tessera.enclave.Enclave) PayloadDigest(com.quorum.tessera.enclave.PayloadDigest) EncryptedTransactionDAO(com.quorum.tessera.data.EncryptedTransactionDAO) Test(org.junit.Test)

Example 2 with PayloadDigest

use of com.quorum.tessera.enclave.PayloadDigest in project tessera by ConsenSys.

the class EncodedPayloadManagerProviderTest method provider.

@Test
public void provider() {
    try (var mockedEnclaveFactory = mockStatic(Enclave.class);
        var mockedPrivacyHelper = mockStatic(PrivacyHelper.class);
        var mockedPayloadDigest = mockStatic(PayloadDigest.class)) {
        mockedPayloadDigest.when(PayloadDigest::create).thenReturn(mock(PayloadDigest.class));
        mockedPrivacyHelper.when(PrivacyHelper::create).thenReturn(mock(PrivacyHelper.class));
        mockedEnclaveFactory.when(Enclave::create).thenReturn(mock(Enclave.class));
        EncodedPayloadManager encodedPayloadManager = EncodedPayloadManagerProvider.provider();
        assertThat(encodedPayloadManager).isNotNull();
        assertThat(encodedPayloadManager).describedAs("Subsequent invocations should return the same instance").isSameAs(EncodedPayloadManagerProvider.provider());
        mockedPrivacyHelper.verify(PrivacyHelper::create);
        mockedPrivacyHelper.verifyNoMoreInteractions();
        mockedEnclaveFactory.verify(Enclave::create);
        mockedEnclaveFactory.verifyNoMoreInteractions();
        mockedPayloadDigest.verify(PayloadDigest::create);
        mockedPayloadDigest.verifyNoMoreInteractions();
    }
}
Also used : PayloadDigest(com.quorum.tessera.enclave.PayloadDigest) Enclave(com.quorum.tessera.enclave.Enclave) EncodedPayloadManager(com.quorum.tessera.transaction.EncodedPayloadManager) PrivacyHelper(com.quorum.tessera.transaction.PrivacyHelper) Test(org.junit.Test)

Example 3 with PayloadDigest

use of com.quorum.tessera.enclave.PayloadDigest in project tessera by ConsenSys.

the class TransactionManagerProvider method provider.

public static TransactionManager provider() {
    final TransactionManagerHolder transactionManagerHolder = TransactionManagerHolder.INSTANCE;
    if (transactionManagerHolder.getTransactionManager().isPresent()) {
        return transactionManagerHolder.getTransactionManager().get();
    }
    final EncryptedTransactionDAO encryptedTransactionDAO = EncryptedTransactionDAO.create();
    final Enclave enclave = Enclave.create();
    final EncryptedRawTransactionDAO encryptedRawTransactionDAO = EncryptedRawTransactionDAO.create();
    LOGGER.debug("Creating ResendManager");
    final ResendManager resendManager = ResendManager.create();
    LOGGER.debug("Created ResendManager {}", resendManager);
    LOGGER.debug("Creating payload publisher");
    final PayloadPublisher payloadPublisher = PayloadPublisher.create();
    LOGGER.debug("Created payload publisher {}", payloadPublisher);
    LOGGER.debug("Creating batchPayloadPublisher");
    final BatchPayloadPublisher batchPayloadPublisher = BatchPayloadPublisher.create();
    LOGGER.debug("Created batchPayloadPublisher {}", batchPayloadPublisher);
    LOGGER.debug("Creating PrivacyHelper");
    final PrivacyHelper privacyHelper = PrivacyHelper.create();
    LOGGER.debug("Created PrivacyHelper {}", privacyHelper);
    int resendBatchSize = 100;
    LOGGER.debug("Creating PayloadDigest");
    final PayloadDigest messageHashFactory = PayloadDigest.create();
    LOGGER.debug("Created PayloadDigest {}", messageHashFactory);
    return transactionManagerHolder.store(new TransactionManagerImpl(enclave, encryptedTransactionDAO, encryptedRawTransactionDAO, resendManager, batchPayloadPublisher, privacyHelper, messageHashFactory));
}
Also used : ResendManager(com.quorum.tessera.transaction.resend.ResendManager) PayloadPublisher(com.quorum.tessera.transaction.publish.PayloadPublisher) BatchPayloadPublisher(com.quorum.tessera.transaction.publish.BatchPayloadPublisher) BatchPayloadPublisher(com.quorum.tessera.transaction.publish.BatchPayloadPublisher) Enclave(com.quorum.tessera.enclave.Enclave) EncryptedRawTransactionDAO(com.quorum.tessera.data.EncryptedRawTransactionDAO) PayloadDigest(com.quorum.tessera.enclave.PayloadDigest) EncryptedTransactionDAO(com.quorum.tessera.data.EncryptedTransactionDAO) PrivacyHelper(com.quorum.tessera.transaction.PrivacyHelper)

Example 4 with PayloadDigest

use of com.quorum.tessera.enclave.PayloadDigest in project tessera by ConsenSys.

the class TransactionManagerProviderTest method provider.

@Test
public void provider() {
    try (var mockedStaticConfigFactory = mockStatic(ConfigFactory.class);
        var mockedStaticEncryptedTransactionDAO = mockStatic(EncryptedTransactionDAO.class);
        var mockedStaticEnclave = mockStatic(Enclave.class);
        var mockedStaticEncryptedRawTransactionDAO = mockStatic(EncryptedRawTransactionDAO.class);
        var mockedStaticPayloadPublisher = mockStatic(PayloadPublisher.class);
        var mockedStaticBatchPayloadPublisher = mockStatic(BatchPayloadPublisher.class);
        var mockedStaticPrivacyHelper = mockStatic(PrivacyHelper.class);
        var mockedStaticResendManager = mockStatic(ResendManager.class);
        var mockedStaticPayloadDigest = mockStatic(PayloadDigest.class)) {
        ConfigFactory configFactory = mock(ConfigFactory.class);
        Config config = mock(Config.class);
        when(configFactory.getConfig()).thenReturn(config);
        mockedStaticConfigFactory.when(ConfigFactory::create).thenReturn(configFactory);
        PayloadPublisher payloadPublisher = mock(PayloadPublisher.class);
        mockedStaticPayloadPublisher.when(PayloadPublisher::create).thenReturn(payloadPublisher);
        BatchPayloadPublisher batchPayloadPublisher = mock(BatchPayloadPublisher.class);
        mockedStaticBatchPayloadPublisher.when(BatchPayloadPublisher::create).thenReturn(batchPayloadPublisher);
        mockedStaticEncryptedRawTransactionDAO.when(EncryptedRawTransactionDAO::create).thenReturn(mock(EncryptedRawTransactionDAO.class));
        mockedStaticEnclave.when(Enclave::create).thenReturn(mock(Enclave.class));
        mockedStaticEncryptedTransactionDAO.when(EncryptedTransactionDAO::create).thenReturn(mock(EncryptedTransactionDAO.class));
        mockedStaticPrivacyHelper.when(PrivacyHelper::create).thenReturn(mock(PrivacyHelper.class));
        mockedStaticResendManager.when(ResendManager::create).thenReturn(mock(ResendManager.class));
        mockedStaticPayloadDigest.when(PayloadDigest::create).thenReturn(mock(PayloadDigest.class));
        TransactionManager transactionManager = TransactionManagerProvider.provider();
        assertThat(transactionManager).isNotNull();
        assertThat(TransactionManagerProvider.provider()).describedAs("Second invocation should return same instance").isSameAs(transactionManager);
        mockedStaticEncryptedTransactionDAO.verify(EncryptedTransactionDAO::create);
        mockedStaticEncryptedTransactionDAO.verifyNoMoreInteractions();
        mockedStaticEnclave.verify(Enclave::create);
        mockedStaticEnclave.verifyNoMoreInteractions();
        mockedStaticEncryptedRawTransactionDAO.verify(EncryptedRawTransactionDAO::create);
        mockedStaticEncryptedRawTransactionDAO.verifyNoMoreInteractions();
        mockedStaticPayloadPublisher.verify(PayloadPublisher::create);
        mockedStaticPayloadPublisher.verifyNoMoreInteractions();
        mockedStaticBatchPayloadPublisher.verify(BatchPayloadPublisher::create);
        mockedStaticBatchPayloadPublisher.verifyNoMoreInteractions();
        mockedStaticPrivacyHelper.verify(PrivacyHelper::create);
        mockedStaticPrivacyHelper.verifyNoMoreInteractions();
        mockedStaticResendManager.verify(ResendManager::create);
        mockedStaticResendManager.verifyNoMoreInteractions();
        mockedStaticPayloadDigest.verify(PayloadDigest::create);
        mockedStaticPayloadDigest.verifyNoMoreInteractions();
    }
}
Also used : ResendManager(com.quorum.tessera.transaction.resend.ResendManager) BatchPayloadPublisher(com.quorum.tessera.transaction.publish.BatchPayloadPublisher) PayloadPublisher(com.quorum.tessera.transaction.publish.PayloadPublisher) BatchPayloadPublisher(com.quorum.tessera.transaction.publish.BatchPayloadPublisher) Config(com.quorum.tessera.config.Config) EncryptedRawTransactionDAO(com.quorum.tessera.data.EncryptedRawTransactionDAO) Enclave(com.quorum.tessera.enclave.Enclave) PayloadDigest(com.quorum.tessera.enclave.PayloadDigest) TransactionManager(com.quorum.tessera.transaction.TransactionManager) EncryptedTransactionDAO(com.quorum.tessera.data.EncryptedTransactionDAO) PrivacyHelper(com.quorum.tessera.transaction.PrivacyHelper) ConfigFactory(com.quorum.tessera.config.ConfigFactory) Test(org.junit.Test)

Example 5 with PayloadDigest

use of com.quorum.tessera.enclave.PayloadDigest in project tessera by ConsenSys.

the class EncodedPayloadManagerProvider method provider.

public static EncodedPayloadManager provider() {
    EncodedPayloadManagerHolder encodedPayloadManagerHolder = EncodedPayloadManagerHolder.INSTANCE;
    if (encodedPayloadManagerHolder.getEncodedPayloadManager().isPresent()) {
        return encodedPayloadManagerHolder.getEncodedPayloadManager().get();
    }
    Enclave enclave = Enclave.create();
    PrivacyHelper privacyHelper = PrivacyHelper.create();
    PayloadDigest payloadDigest = PayloadDigest.create();
    EncodedPayloadManager encodedPayloadManager = new EncodedPayloadManagerImpl(enclave, privacyHelper, payloadDigest);
    encodedPayloadManagerHolder.storeInstance(encodedPayloadManager);
    return encodedPayloadManager;
}
Also used : Enclave(com.quorum.tessera.enclave.Enclave) PayloadDigest(com.quorum.tessera.enclave.PayloadDigest) EncodedPayloadManager(com.quorum.tessera.transaction.EncodedPayloadManager) PrivacyHelper(com.quorum.tessera.transaction.PrivacyHelper)

Aggregations

Enclave (com.quorum.tessera.enclave.Enclave)6 PayloadDigest (com.quorum.tessera.enclave.PayloadDigest)6 EncryptedTransactionDAO (com.quorum.tessera.data.EncryptedTransactionDAO)4 PrivacyHelper (com.quorum.tessera.transaction.PrivacyHelper)4 ResendManager (com.quorum.tessera.transaction.resend.ResendManager)3 Test (org.junit.Test)3 EncryptedRawTransactionDAO (com.quorum.tessera.data.EncryptedRawTransactionDAO)2 EncodedPayloadManager (com.quorum.tessera.transaction.EncodedPayloadManager)2 BatchPayloadPublisher (com.quorum.tessera.transaction.publish.BatchPayloadPublisher)2 PayloadPublisher (com.quorum.tessera.transaction.publish.PayloadPublisher)2 Config (com.quorum.tessera.config.Config)1 ConfigFactory (com.quorum.tessera.config.ConfigFactory)1 TransactionManager (com.quorum.tessera.transaction.TransactionManager)1