add test coverage for transactionmanager
@@ -1096,6 +1096,23 @@ public class TransactionManagerTest {
assertThat(tm).isNotNull();
}
+ @Test
+ public void publishDoesNotPublishToSender() {
+
+ TransactionManagerImpl impl = TransactionManagerImpl.class.cast(transactionManager);
+ EncodedPayload transaction = mock(EncodedPayload.class);
+
+ PublicKey someKey = mock(PublicKey.class);
+
+ List<PublicKey> recipients = Arrays.asList(someKey);
+
+ when(enclave.getPublicKeys()).thenReturn(singleton(someKey));
+
+ impl.publish(recipients, transaction);
+
+ verify(enclave).getPublicKeys();
+ }
+
@Test
public void isSenderThrowsOnMissingTransaction() {
@@ -1220,4 +1237,21 @@ public class TransactionManagerTest {
transactionManager.defaultPublicKey();
verify(enclave).defaultPublicKey();
}
+
+ @Test
+ public void publish() {
+
+ PublicKey reipcient = mock(PublicKey.class);
+ List<PublicKey> recipients = List.of(reipcient);
+ EncodedPayload payload = mock(EncodedPayload.class);
+
+ when(enclave.getPublicKeys()).thenReturn(Set.of(mock(PublicKey.class)));
+ when(payloadEncoder.forRecipient(payload, reipcient)).thenReturn(payload);
+
+ TransactionManagerImpl.class.cast(transactionManager).publish(recipients, payload);
+
+ verify(enclave).getPublicKeys();
+ verify(payloadEncoder).forRecipient(payload, reipcient);
+ verify(partyInfoService).publishPayload(payload, reipcient);
+ }
}
