Skip to content

Commit

Permalink
Fix remaining unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: tinker-michaelj <[email protected]>
  • Loading branch information
tinker-michaelj committed May 28, 2021
1 parent 1556518 commit a45d460
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}",
Expand Down Expand Up @@ -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());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit a45d460

Please sign in to comment.