Search in sources :

Example 1 with EncodedPayloadManager

use of com.quorum.tessera.transaction.EncodedPayloadManager 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 2 with EncodedPayloadManager

use of com.quorum.tessera.transaction.EncodedPayloadManager 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)2 PayloadDigest (com.quorum.tessera.enclave.PayloadDigest)2 EncodedPayloadManager (com.quorum.tessera.transaction.EncodedPayloadManager)2 PrivacyHelper (com.quorum.tessera.transaction.PrivacyHelper)2 Test (org.junit.Test)1