From 3717795f26c32bf2773f943397960805e8ead172 Mon Sep 17 00:00:00 2001 From: Fabio Di Fabio Date: Wed, 28 Jun 2023 10:24:45 +0200 Subject: [PATCH] Fix test and log errors Signed-off-by: Fabio Di Fabio --- .../org/hyperledger/besu/RunnerBuilderTest.java | 3 ++- .../eth/transactions/TransactionPool.java | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/besu/src/test/java/org/hyperledger/besu/RunnerBuilderTest.java b/besu/src/test/java/org/hyperledger/besu/RunnerBuilderTest.java index d4c0a79a316..6db9f68efad 100644 --- a/besu/src/test/java/org/hyperledger/besu/RunnerBuilderTest.java +++ b/besu/src/test/java/org/hyperledger/besu/RunnerBuilderTest.java @@ -128,7 +128,8 @@ public void setup() { when(besuController.getNodeKey()).thenReturn(nodeKey); when(besuController.getMiningParameters()).thenReturn(mock(MiningParameters.class)); when(besuController.getPrivacyParameters()).thenReturn(mock(PrivacyParameters.class)); - when(besuController.getTransactionPool()).thenReturn(mock(TransactionPool.class)); + when(besuController.getTransactionPool()) + .thenReturn(mock(TransactionPool.class, RETURNS_DEEP_STUBS)); when(besuController.getSynchronizer()).thenReturn(mock(Synchronizer.class)); when(besuController.getMiningCoordinator()).thenReturn(mock(MiningCoordinator.class)); when(besuController.getMiningCoordinator()).thenReturn(mock(MergeMiningCoordinator.class)); diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java index 26e2abd6358..7b16d8717d6 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java @@ -531,7 +531,13 @@ public CompletableFuture setEnabled() { isPoolEnabled.set(true); subscribeConnectId = OptionalLong.of(ethContext.getEthPeers().subscribeConnect(this::handleConnect)); - return saveRestoreManager.loadFromDisk(); + return saveRestoreManager + .loadFromDisk() + .exceptionally( + t -> { + LOG.error("Error while restoring transaction pool from disk", t); + return null; + }); } return CompletableFuture.completedFuture(null); } @@ -543,7 +549,13 @@ public CompletableFuture setDisabled() { pendingTransactionsListenersProxy.unsubscribe(); final PendingTransactions pendingTransactionsToSave = pendingTransactions; pendingTransactions = new DisabledPendingTransactions(); - return saveRestoreManager.saveToDisk(pendingTransactionsToSave); + return saveRestoreManager + .saveToDisk(pendingTransactionsToSave) + .exceptionally( + t -> { + LOG.error("Error while saving transaction pool to disk", t); + return null; + }); } return CompletableFuture.completedFuture(null); }