From a45d46065ccc63da6abe617caa5ad0e2dcf278d1 Mon Sep 17 00:00:00 2001 From: tinker-michaelj Date: Fri, 28 May 2021 16:55:37 -0500 Subject: [PATCH] Fix remaining unit tests Signed-off-by: tinker-michaelj --- .../com/hedera/services/stream/RecordStreamManager.java | 8 ++++++-- .../handler/SmartContractRequestHandlerPayableTest.java | 9 +++++++++ .../hedera/services/stream/RecordStreamManagerTest.java | 4 ++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/hedera-node/src/main/java/com/hedera/services/stream/RecordStreamManager.java b/hedera-node/src/main/java/com/hedera/services/stream/RecordStreamManager.java index 1f11d43e3964..9e59dc0195cf 100644 --- a/hedera-node/src/main/java/com/hedera/services/stream/RecordStreamManager.java +++ b/hedera-node/src/main/java/com/hedera/services/stream/RecordStreamManager.java @@ -154,7 +154,9 @@ public RecordStreamManager( multiStream.setRunningHash(initialHash); hashQueueThread.start(); - writeQueueThread.start(); + if (writeQueueThread != null) { + writeQueueThread.start(); + } log.info("Finish initializing RecordStreamManager with: enableRecordStreaming: {}, recordStreamDir: {}, " + "recordsLogPeriod: {} secs, recordStreamQueueCapacity: {}, initialHash: {}", @@ -200,7 +202,9 @@ public void addRecordStreamObject(final RecordStreamObject recordStreamObject) { log.warn("Unhandled exception while streaming {}", recordStreamObject, e); } } - runningAvgs.writeQueueSizeRecordStream(getWriteQueueSize()); + if (writeQueueThread != null) { + runningAvgs.writeQueueSizeRecordStream(getWriteQueueSize()); + } runningAvgs.hashQueueSizeRecordStream(getHashQueueSize()); } diff --git a/hedera-node/src/test/java/com/hedera/services/legacy/unit/handler/SmartContractRequestHandlerPayableTest.java b/hedera-node/src/test/java/com/hedera/services/legacy/unit/handler/SmartContractRequestHandlerPayableTest.java index 51c61ac577b3..e7cd4c0ef1bf 100644 --- a/hedera-node/src/test/java/com/hedera/services/legacy/unit/handler/SmartContractRequestHandlerPayableTest.java +++ b/hedera-node/src/test/java/com/hedera/services/legacy/unit/handler/SmartContractRequestHandlerPayableTest.java @@ -67,7 +67,10 @@ import com.hederahashgraph.api.proto.java.TransactionBody; import com.hederahashgraph.api.proto.java.TransactionRecord; import com.hederahashgraph.builder.RequestBuilder; +import com.swirlds.common.constructable.ClassConstructorPair; +import com.swirlds.common.constructable.ConstructableRegistry; import com.swirlds.fcmap.FCMap; +import com.swirlds.fcmap.internal.FCMLeaf; import net.i2p.crypto.eddsa.EdDSAPublicKey; import net.i2p.crypto.eddsa.KeyPairGenerator; import org.apache.commons.codec.DecoderException; @@ -158,6 +161,12 @@ private ServicesRepositoryRoot getLocalRepositoryInstance() { @BeforeEach public void setUp() throws Exception { + // setup: + ConstructableRegistry.registerConstructable( + new ClassConstructorPair(FCMLeaf.class, FCMLeaf::new)); + ConstructableRegistry.registerConstructable( + new ClassConstructorPair(MerkleAccount.class, MerkleAccount::new)); + payerAccountId = RequestBuilder.getAccountIdBuild(payerAccount, 0l, 0l); nodeAccountId = RequestBuilder.getAccountIdBuild(nodeAccount, 0l, 0l); feeCollAccountId = RequestBuilder.getAccountIdBuild(feeCollAccount, 0l, 0l); diff --git a/hedera-node/src/test/java/com/hedera/services/stream/RecordStreamManagerTest.java b/hedera-node/src/test/java/com/hedera/services/stream/RecordStreamManagerTest.java index 28a4afec3ec6..4ea0ae8f39e5 100644 --- a/hedera-node/src/test/java/com/hedera/services/stream/RecordStreamManagerTest.java +++ b/hedera-node/src/test/java/com/hedera/services/stream/RecordStreamManagerTest.java @@ -146,6 +146,10 @@ void setInitialHashTest() { @Test void warnsOnInterruptedStreaming() { + // setup: + final var mockQueue = mock(Queue.class); + + given(writeQueueThreadMock.getQueue()).willReturn(mockQueue); recordStreamManager = new RecordStreamManager(multiStreamMock, writeQueueThreadMock, runningAvgsMock); willThrow(RuntimeException.class).given(multiStreamMock).addObject(any());