Search in sources :

Example 1 with Enclave

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

the class DiscoveryHelperProviderTest method provider.

@Test
public void provider() {
    try (var mockedEnclave = mockStatic(Enclave.class);
        var mockedNetworkStore = mockStatic(NetworkStore.class)) {
        NetworkStore networkStore = mock(NetworkStore.class);
        mockedNetworkStore.when(NetworkStore::getInstance).thenReturn(networkStore);
        Enclave enclave = mock(Enclave.class);
        mockedEnclave.when(Enclave::create).thenReturn(enclave);
        DiscoveryHelper helper = DiscoveryHelperProvider.provider();
        assertThat(helper).isNotNull().isExactlyInstanceOf(DiscoveryHelperImpl.class);
        mockedEnclave.verify(Enclave::create);
        mockedEnclave.verifyNoMoreInteractions();
        mockedNetworkStore.verify(NetworkStore::getInstance);
        mockedNetworkStore.verifyNoMoreInteractions();
        verifyNoInteractions(networkStore);
        verifyNoInteractions(enclave);
    }
}
Also used : Enclave(com.quorum.tessera.enclave.Enclave) DiscoveryHelper(com.quorum.tessera.discovery.DiscoveryHelper) NetworkStore(com.quorum.tessera.discovery.NetworkStore) Test(org.junit.Test)

Example 2 with Enclave

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

the class DiscoveryHelperTest method create.

@Test
public void create() {
    try (var staticEnclave = mockStatic(Enclave.class)) {
        Enclave enclave = mock(Enclave.class);
        staticEnclave.when(Enclave::create).thenReturn(enclave);
        DiscoveryHelper.create();
        staticEnclave.verify(Enclave::create);
        verifyNoInteractions(enclave);
        staticEnclave.verifyNoMoreInteractions();
    }
}
Also used : Enclave(com.quorum.tessera.enclave.Enclave) Test(org.junit.Test)

Example 3 with Enclave

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

the class EnclaveKeySynchroniserProviderTest method provider.

@Test
public void provider() {
    try (var mockedEnclave = mockStatic(Enclave.class);
        var mockedNetworkStore = mockStatic(NetworkStore.class)) {
        NetworkStore networkStore = mock(NetworkStore.class);
        mockedNetworkStore.when(NetworkStore::getInstance).thenReturn(networkStore);
        Enclave enclave = mock(Enclave.class);
        mockedEnclave.when(Enclave::create).thenReturn(enclave);
        EnclaveKeySynchroniser enclaveKeySynchroniser = EnclaveKeySynchroniserProvider.provider();
        assertThat(enclaveKeySynchroniser).isNotNull().isExactlyInstanceOf(EnclaveKeySynchroniserImpl.class);
        mockedEnclave.verify(Enclave::create);
        mockedEnclave.verifyNoMoreInteractions();
        mockedNetworkStore.verify(NetworkStore::getInstance);
        mockedNetworkStore.verifyNoMoreInteractions();
        verifyNoInteractions(networkStore);
        verifyNoInteractions(enclave);
    }
}
Also used : Enclave(com.quorum.tessera.enclave.Enclave) NetworkStore(com.quorum.tessera.discovery.NetworkStore) EnclaveKeySynchroniser(com.quorum.tessera.discovery.EnclaveKeySynchroniser) Test(org.junit.Test)

Example 4 with Enclave

use of com.quorum.tessera.enclave.Enclave 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 5 with Enclave

use of com.quorum.tessera.enclave.Enclave 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)

Aggregations

Enclave (com.quorum.tessera.enclave.Enclave)29 Test (org.junit.Test)11 Discovery (com.quorum.tessera.discovery.Discovery)9 EncryptedTransactionDAO (com.quorum.tessera.data.EncryptedTransactionDAO)7 PayloadDigest (com.quorum.tessera.enclave.PayloadDigest)6 RuntimeContext (com.quorum.tessera.context.RuntimeContext)5 PayloadPublisher (com.quorum.tessera.transaction.publish.PayloadPublisher)5 NetworkStore (com.quorum.tessera.discovery.NetworkStore)4 PrivacyHelper (com.quorum.tessera.transaction.PrivacyHelper)4 TransactionManager (com.quorum.tessera.transaction.TransactionManager)4 Config (com.quorum.tessera.config.Config)3 PrivacyGroupManager (com.quorum.tessera.privacygroup.PrivacyGroupManager)3 LegacyResendManager (com.quorum.tessera.recovery.workflow.LegacyResendManager)3 Client (jakarta.ws.rs.client.Client)3 CliResult (com.quorum.tessera.cli.CliResult)2 ConfigKeyPair (com.quorum.tessera.config.keypairs.ConfigKeyPair)2 KeyEncryptor (com.quorum.tessera.config.keys.KeyEncryptor)2 RestClientFactory (com.quorum.tessera.context.RestClientFactory)2 PartyStore (com.quorum.tessera.p2p.partyinfo.PartyStore)2 ResendBatchPublisher (com.quorum.tessera.recovery.resend.ResendBatchPublisher)2