From 4a59618bb03c065fb6e720be8428c1aaf7a05dcf Mon Sep 17 00:00:00 2001 From: Alfredo Gutierrez Date: Tue, 17 Dec 2024 14:14:59 -0600 Subject: [PATCH] Fixing Existing Unit tests and removing an addition (requires org.checkerframework.checker.qual;) on module-info by accident Signed-off-by: Alfredo Gutierrez --- .../signature/SignatureVerifierDummy.java | 2 +- server/src/main/java/module-info.java | 1 - .../server/notifier/NotifierImplTest.java | 7 ++- .../PbjBlockStreamServiceIntegrationTest.java | 49 +++++++++++++++++-- 4 files changed, 51 insertions(+), 8 deletions(-) diff --git a/server/src/main/java/com/hedera/block/server/verification/signature/SignatureVerifierDummy.java b/server/src/main/java/com/hedera/block/server/verification/signature/SignatureVerifierDummy.java index 37f2c8f5b..f1de352b8 100644 --- a/server/src/main/java/com/hedera/block/server/verification/signature/SignatureVerifierDummy.java +++ b/server/src/main/java/com/hedera/block/server/verification/signature/SignatureVerifierDummy.java @@ -22,7 +22,7 @@ public class SignatureVerifierDummy implements SignatureVerifier { @Inject - // TODO we need to provide the public key (aka LedgerID) + // on actual impl we would need to provide the public key (aka LedgerID) public SignatureVerifierDummy() {} @Override diff --git a/server/src/main/java/module-info.java b/server/src/main/java/module-info.java index 4e102e087..d4c8618dd 100644 --- a/server/src/main/java/module-info.java +++ b/server/src/main/java/module-info.java @@ -44,7 +44,6 @@ requires javax.inject; requires static com.github.spotbugs.annotations; requires static com.google.auto.service; - requires org.checkerframework.checker.qual; provides com.swirlds.config.api.ConfigurationExtension with BlockNodeConfigExtension; diff --git a/server/src/test/java/com/hedera/block/server/notifier/NotifierImplTest.java b/server/src/test/java/com/hedera/block/server/notifier/NotifierImplTest.java index 22eac039e..3b7b5614a 100644 --- a/server/src/test/java/com/hedera/block/server/notifier/NotifierImplTest.java +++ b/server/src/test/java/com/hedera/block/server/notifier/NotifierImplTest.java @@ -44,6 +44,8 @@ import com.hedera.block.server.service.ServiceStatusImpl; import com.hedera.block.server.util.TestConfigUtil; import com.hedera.block.server.util.TestUtils; +import com.hedera.block.server.verification.BlockVerificationService; +import com.hedera.block.server.verification.BlockVerificationServiceNoOp; import com.hedera.block.server.verification.StreamVerificationHandlerImpl; import com.hedera.hapi.block.Acknowledgement; import com.hedera.hapi.block.BlockItemUnparsed; @@ -273,9 +275,10 @@ private PbjBlockStreamServiceProxy buildBlockStreamService(final Notifier notifi final var streamMediator = buildStreamMediator(new ConcurrentHashMap<>(32), serviceStatus); final var blockNodeEventHandler = new StreamPersistenceHandlerImpl( streamMediator, notifier, blockWriter, blockNodeContext, serviceStatus); + final BlockVerificationService blockVerificationService = new BlockVerificationServiceNoOp(); - final var streamVerificationHandler = - new StreamVerificationHandlerImpl(streamMediator, blockNodeContext.metricsService(), serviceStatus); + final var streamVerificationHandler = new StreamVerificationHandlerImpl( + streamMediator, notifier, blockNodeContext.metricsService(), serviceStatus, blockVerificationService); return new PbjBlockStreamServiceProxy( streamMediator, diff --git a/server/src/test/java/com/hedera/block/server/pbj/PbjBlockStreamServiceIntegrationTest.java b/server/src/test/java/com/hedera/block/server/pbj/PbjBlockStreamServiceIntegrationTest.java index 0f7312d69..966ecedc0 100644 --- a/server/src/test/java/com/hedera/block/server/pbj/PbjBlockStreamServiceIntegrationTest.java +++ b/server/src/test/java/com/hedera/block/server/pbj/PbjBlockStreamServiceIntegrationTest.java @@ -49,6 +49,8 @@ import com.hedera.block.server.service.ServiceStatus; import com.hedera.block.server.service.ServiceStatusImpl; import com.hedera.block.server.util.TestConfigUtil; +import com.hedera.block.server.verification.BlockVerificationService; +import com.hedera.block.server.verification.StreamVerificationHandlerImpl; import com.hedera.hapi.block.Acknowledgement; import com.hedera.hapi.block.BlockItemSetUnparsed; import com.hedera.hapi.block.BlockItemUnparsed; @@ -392,8 +394,21 @@ public void testSubAndUnsubWhileStreaming() throws InterruptedException { final var streamMediator = buildStreamMediator(consumers, serviceStatus); final var blockNodeEventHandler = new StreamPersistenceHandlerImpl( streamMediator, notifier, blockWriter, blockNodeContext, serviceStatus); + + final StreamVerificationHandlerImpl streamVerificationHandler = new StreamVerificationHandlerImpl( + streamMediator, + notifier, + blockNodeContext.metricsService(), + serviceStatus, + mock(BlockVerificationService.class)); + final PbjBlockStreamServiceProxy pbjBlockStreamServiceProxy = new PbjBlockStreamServiceProxy( - streamMediator, serviceStatus, blockNodeEventHandler, notifier, blockNodeContext); + streamMediator, + serviceStatus, + blockNodeEventHandler, + streamVerificationHandler, + notifier, + blockNodeContext); final Pipeline producerPipeline = pbjBlockStreamServiceProxy.open( PbjBlockStreamService.BlockStreamMethod.publishBlockStream, options, helidonPublishStreamObserver1); @@ -519,8 +534,21 @@ public void testMediatorExceptionHandlingWhenPersistenceFailure() throws IOExcep final var notifier = new NotifierImpl(streamMediator, blockNodeContext, serviceStatus); final var blockNodeEventHandler = new StreamPersistenceHandlerImpl( streamMediator, notifier, blockWriter, blockNodeContext, serviceStatus); + + final StreamVerificationHandlerImpl streamVerificationHandler = new StreamVerificationHandlerImpl( + streamMediator, + notifier, + blockNodeContext.metricsService(), + serviceStatus, + mock(BlockVerificationService.class)); + final PbjBlockStreamServiceProxy pbjBlockStreamServiceProxy = new PbjBlockStreamServiceProxy( - streamMediator, serviceStatus, blockNodeEventHandler, notifier, blockNodeContext); + streamMediator, + serviceStatus, + blockNodeEventHandler, + streamVerificationHandler, + notifier, + blockNodeContext); // Register a producer final Pipeline producerPipeline = pbjBlockStreamServiceProxy.open( @@ -539,7 +567,7 @@ public void testMediatorExceptionHandlingWhenPersistenceFailure() throws IOExcep .onNext(buildEmptySubscribeStreamRequest()); // 3 subscribers + 1 streamPersistenceHandler - assertEquals(4, consumers.size()); + assertEquals(5, consumers.size()); // Transmit a BlockItem final Bytes publishStreamRequest = @@ -670,11 +698,24 @@ private PbjBlockStreamServiceProxy buildBlockStreamService(final BlockWriter(32), serviceStatus); final var notifier = new NotifierImpl(streamMediator, blockNodeContext, serviceStatus); + final var blockNodeEventHandler = new StreamPersistenceHandlerImpl( streamMediator, notifier, blockWriter, blockNodeContext, serviceStatus); + final StreamVerificationHandlerImpl streamVerificationHandler = new StreamVerificationHandlerImpl( + streamMediator, + notifier, + blockNodeContext.metricsService(), + serviceStatus, + mock(BlockVerificationService.class)); + return new PbjBlockStreamServiceProxy( - streamMediator, serviceStatus, blockNodeEventHandler, notifier, blockNodeContext); + streamMediator, + serviceStatus, + blockNodeEventHandler, + streamVerificationHandler, + notifier, + blockNodeContext); } private LiveStreamMediator buildStreamMediator(