From 94912ba55a8b453b6948cd2469d42f3202ac257c Mon Sep 17 00:00:00 2001 From: julia-zack Date: Thu, 9 Jan 2025 12:52:42 -0300 Subject: [PATCH] Remove assert methods that do not return void --- .../java/co/rsk/peg/BridgeSupportSvpTest.java | 49 +++++++------------ 1 file changed, 19 insertions(+), 30 deletions(-) diff --git a/rskj-core/src/test/java/co/rsk/peg/BridgeSupportSvpTest.java b/rskj-core/src/test/java/co/rsk/peg/BridgeSupportSvpTest.java index 870d6913b6..1840c59e94 100644 --- a/rskj-core/src/test/java/co/rsk/peg/BridgeSupportSvpTest.java +++ b/rskj-core/src/test/java/co/rsk/peg/BridgeSupportSvpTest.java @@ -376,9 +376,12 @@ void updateCollections_whenFundTxCanBeCreated_createsExpectedFundTxAndSavesTheHa bridgeStorageProvider.save(); // assert - Sha256Hash svpFundTxHashUnsigned = assertSvpFundTxHashUnsignedIsInStorage(); - assertSvpFundTxReleaseWasSettled(svpFundTxHashUnsigned); + Optional svpFundTxHashUnsigned = bridgeStorageProvider.getSvpFundTxHashUnsigned(); + assertTrue(svpFundTxHashUnsigned.isPresent()); + assertSvpFundTxReleaseWasSettled(svpFundTxHashUnsigned.get()); + assertActiveFederationUtxosSize(activeFederationUtxosSizeBeforeCreatingFundTx - 1); + assertSvpFundTransactionHasExpectedInputsAndOutputs(); } @@ -416,7 +419,6 @@ private void assertInputsAreFromActiveFederation() { void updateCollections_whenWaitingForFundTxToBeRegistered_shouldNotCreateFundTransactionAgain() throws Exception { // arrange arrangeSvpFundTransactionUnsigned(); - assertSvpFundTxHashUnsignedIsInStorage(); // act bridgeSupport.updateCollections(rskTx); @@ -469,7 +471,10 @@ private void assertJustUpdateCollectionsWasLogged() { private void arrangeSvpFundTransactionUnsigned() { recreateSvpFundTransactionUnsigned(); addOutputChange(svpFundTransaction); + saveSvpFundTransactionUnsigned(); + Optional svpFundTransactionHashUnsigned = bridgeStorageProvider.getSvpFundTxHashUnsigned(); + assertTrue(svpFundTransactionHashUnsigned.isPresent()); } private void saveSvpFundTransactionUnsigned() { @@ -487,12 +492,6 @@ private void saveSvpFundTransactionHashUnsigned(Sha256Hash svpFundTransactionHas bridgeSupport.save(); } - private Sha256Hash assertSvpFundTxHashUnsignedIsInStorage() { - Optional svpFundTransactionHashUnsigned = bridgeStorageProvider.getSvpFundTxHashUnsigned(); - assertTrue(svpFundTransactionHashUnsigned.isPresent()); - - return svpFundTransactionHashUnsigned.get(); - } private void assertSvpFundTxReleaseWasSettled(Sha256Hash svpFundTransactionHashUnsigned) throws IOException { PegoutsWaitingForConfirmations pegoutsWaitingForConfirmations = bridgeStorageProvider.getPegoutsWaitingForConfirmations(); @@ -702,15 +701,22 @@ void updateCollections_whenSpendTxCanBeCreated_createsExpectedSpendTxAndSavesThe bridgeStorageProvider.save(); // assert - Sha256Hash svpSpendTransactionHashUnsigned = assertSvpSpendTxHashUnsignedIsInStorage(); - svpSpendTransaction = assertSvpSpendTxIsWaitingForSignatures(); + Optional svpSpendTransactionHashUnsigned = bridgeStorageProvider.getSvpSpendTxHashUnsigned(); + assertTrue(svpSpendTransactionHashUnsigned.isPresent()); + + Optional> svpSpendTxWaitingForSignaturesOpt = bridgeStorageProvider.getSvpSpendTxWaitingForSignatures(); + assertTrue(svpSpendTxWaitingForSignaturesOpt.isPresent()); + Map.Entry svpSpendTxWaitingForSignatures = svpSpendTxWaitingForSignaturesOpt.get(); + svpSpendTransaction = svpSpendTxWaitingForSignatures.getValue(); + assertSvpSpendTxHasExpectedInputsAndOutputs(); assertSvpFundTxSignedWasRemovedFromStorage(); assertLogPegoutTransactionCreated(svpSpendTransaction); + TransactionOutput outputToActiveFed = svpSpendTransaction.getOutput(0); - assertLogReleaseRequested(rskTx.getHash(), svpSpendTransactionHashUnsigned, outputToActiveFed.getValue()); + assertLogReleaseRequested(rskTx.getHash(), svpSpendTransactionHashUnsigned.get(), outputToActiveFed.getValue()); } private void assertSvpFundTxSignedWasRemovedFromStorage() { @@ -766,26 +772,9 @@ private void assertInputHasExpectedScriptSig(TransactionInput input, Script rede } } - private Sha256Hash assertSvpSpendTxHashUnsignedIsInStorage() { + private void assertSvpSpendTxHashUnsignedIsInStorage() { Optional svpSpendTransactionHashUnsignedOpt = bridgeStorageProvider.getSvpSpendTxHashUnsigned(); assertTrue(svpSpendTransactionHashUnsignedOpt.isPresent()); - - return svpSpendTransactionHashUnsignedOpt.get(); - } - - private BtcTransaction assertSvpSpendTxIsWaitingForSignatures() { - Optional> svpSpendTxWaitingForSignaturesOpt = bridgeStorageProvider.getSvpSpendTxWaitingForSignatures(); - assertTrue(svpSpendTxWaitingForSignaturesOpt.isPresent()); - Map.Entry svpSpendTxWaitingForSignatures = svpSpendTxWaitingForSignaturesOpt.get(); - - Keccak256 svpSpendTxWaitingForSignaturesRskTxHash = svpSpendTxWaitingForSignatures.getKey(); - assertEquals(rskTx.getHash(), svpSpendTxWaitingForSignaturesRskTxHash); - - BtcTransaction svpSpendTxWaitingForSignaturesSpendTx = svpSpendTxWaitingForSignatures.getValue(); - Sha256Hash svpSpendTransactionHashUnsigned = assertSvpSpendTxHashUnsignedIsInStorage(); - assertEquals(svpSpendTransactionHashUnsigned, svpSpendTxWaitingForSignaturesSpendTx.getHash()); - - return svpSpendTxWaitingForSignaturesSpendTx; } @Nested