Skip to content

Commit

Permalink
Remove global variable svpFundTxHashUnsigned from BridgeSupportSvpTest
Browse files Browse the repository at this point in the history
  • Loading branch information
marcos-iov committed Jan 15, 2025
1 parent c8f6539 commit d4580ec
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions rskj-core/src/test/java/co/rsk/peg/BridgeSupportSvpTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ public class BridgeSupportSvpTest {
private Federation activeFederation;
private Federation proposedFederation;

private Sha256Hash svpFundTransactionHashUnsigned;
private BtcTransaction svpFundTransaction;
private BtcTransaction svpSpendTransaction;

Expand Down Expand Up @@ -183,7 +182,7 @@ void setUp() {
@Test
void updateCollections_whenSvpFundTxHashUnsigned_shouldLogValidationFailureAndClearValue() throws IOException {
// arrange
svpFundTransactionHashUnsigned = BitcoinTestUtils.createHash(1);
Sha256Hash svpFundTransactionHashUnsigned = BitcoinTestUtils.createHash(1);
bridgeStorageProvider.setSvpFundTxHashUnsigned(svpFundTransactionHashUnsigned);

// act
Expand Down Expand Up @@ -297,8 +296,8 @@ void updateCollections_whenFundTxCanBeCreated_createsExpectedFundTxAndSavesTheHa
bridgeStorageProvider.save();

// assert
assertSvpFundTxHashUnsignedIsSavedInStorage();
assertSvpFundTxReleaseWasSettled();
Sha256Hash svpFundTxHashUnsigned = assertSvpFundTxHashUnsignedIsInStorage();
assertSvpFundTxReleaseWasSettled(svpFundTxHashUnsigned);
assertSvpFundTransactionHasExpectedInputsAndOutputs();
}

Expand Down Expand Up @@ -346,7 +345,7 @@ private void assertOneOutputIsToProposedFederationWithFlyoverPrefixWithExpectedA
void updateCollections_whenWaitingForFundTxToBeRegistered_shouldNotCreateFundTransactionAgain() throws Exception {
// arrange
arrangeSvpFundTransactionUnsigned();
assertSvpFundTxHashUnsignedIsSavedInStorage();
assertSvpFundTxHashUnsignedIsInStorage();

// act
bridgeSupport.updateCollections(rskTx);
Expand Down Expand Up @@ -417,14 +416,14 @@ private void saveSvpFundTransactionHashUnsigned(Sha256Hash svpFundTransactionHas
bridgeSupport.save();
}

private void assertSvpFundTxHashUnsignedIsSavedInStorage() {
Optional<Sha256Hash> svpFundTransactionHashUnsignedOpt = bridgeStorageProvider.getSvpFundTxHashUnsigned();
assertTrue(svpFundTransactionHashUnsignedOpt.isPresent());
private Sha256Hash assertSvpFundTxHashUnsignedIsInStorage() {
Optional<Sha256Hash> svpFundTransactionHashUnsigned = bridgeStorageProvider.getSvpFundTxHashUnsigned();
assertTrue(svpFundTransactionHashUnsigned.isPresent());

svpFundTransactionHashUnsigned = svpFundTransactionHashUnsignedOpt.get();
return svpFundTransactionHashUnsigned.get();
}

private void assertSvpFundTxReleaseWasSettled() throws IOException {
private void assertSvpFundTxReleaseWasSettled(Sha256Hash svpFundTransactionHashUnsigned) throws IOException {
PegoutsWaitingForConfirmations pegoutsWaitingForConfirmations = bridgeStorageProvider.getPegoutsWaitingForConfirmations();
assertPegoutWasAddedToPegoutsWaitingForConfirmations(pegoutsWaitingForConfirmations, svpFundTransactionHashUnsigned, rskTx.getHash());

Expand Down

0 comments on commit d4580ec

Please sign in to comment.