From 710857d6a7ceaf948e35645e79a875fa07e457e9 Mon Sep 17 00:00:00 2001 From: Julian Len Date: Tue, 17 Dec 2024 14:43:31 -0300 Subject: [PATCH] fix: moved variables as final and renamed btcTransferred to minimumPegintxValue --- .../co/rsk/peg/BridgeSupportTestUtil.java | 3 ++- .../co/rsk/peg/RegisterBtcTransactionIT.java | 20 +++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/rskj-core/src/test/java/co/rsk/peg/BridgeSupportTestUtil.java b/rskj-core/src/test/java/co/rsk/peg/BridgeSupportTestUtil.java index 12f19b9f56..41c49090f2 100644 --- a/rskj-core/src/test/java/co/rsk/peg/BridgeSupportTestUtil.java +++ b/rskj-core/src/test/java/co/rsk/peg/BridgeSupportTestUtil.java @@ -16,6 +16,7 @@ import java.util.*; import org.bouncycastle.util.encoders.Hex; import org.ethereum.config.blockchain.upgrades.ActivationConfig; +import org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest; import org.ethereum.core.Block; import org.ethereum.core.BlockHeader; import org.ethereum.core.BlockHeaderBuilder; @@ -98,7 +99,7 @@ public static FederationStorageProvider createFederationStorageProvider(Reposito public static Block getRskExecutionBlock() { long rskExecutionBlockNumber = 1000L; long rskExecutionBlockTimestamp = 10L; - BlockHeader blockHeader = new BlockHeaderBuilder(mock(ActivationConfig.class)) + BlockHeader blockHeader = new BlockHeaderBuilder(ActivationConfigsForTest.all()) .setNumber(rskExecutionBlockNumber) .setTimestamp(rskExecutionBlockTimestamp) .build(); diff --git a/rskj-core/src/test/java/co/rsk/peg/RegisterBtcTransactionIT.java b/rskj-core/src/test/java/co/rsk/peg/RegisterBtcTransactionIT.java index 39b8fc17b2..778e3d1f6a 100644 --- a/rskj-core/src/test/java/co/rsk/peg/RegisterBtcTransactionIT.java +++ b/rskj-core/src/test/java/co/rsk/peg/RegisterBtcTransactionIT.java @@ -36,29 +36,28 @@ class RegisterBtcTransactionIT { private final BridgeConstants bridgeConstants = BridgeMainNetConstants.getInstance(); private final NetworkParameters btcParams = bridgeConstants.getBtcParams(); private final BridgeSupportBuilder bridgeSupportBuilder = BridgeSupportBuilder.builder(); + private final ActivationConfig.ForBlock activations = ActivationConfigsForTest.all().forBlock(0); + private final Transaction rskTx = TransactionUtils.createTransaction(); + private final Coin minimumPeginValue = bridgeConstants.getMinimumPeginTxValue(activations); + private final Block rskExecutionBlock = getRskExecutionBlock(); private Repository track; private Repository repository; - private Block rskExecutionBlock; private FederationSupport federationSupport; private BridgeStorageProvider bridgeStorageProvider; private BtcTransaction bitcoinTransaction; private PartialMerkleTree pmtWithTransactions; private int btcBlockWithPmtHeight; - private Transaction rskTx; private RskAddress rskReceiver; private BridgeSupport bridgeSupport; private BridgeEventLoggerImpl bridgeEventLogger; - private Coin btcTransferred; + + @BeforeEach void setUp() throws Exception{ - rskTx = TransactionUtils.createTransaction(); repository = BridgeSupportTestUtil.createRepository(); track = repository.startTracking(); - ActivationConfig.ForBlock activations = ActivationConfigsForTest.all().forBlock(0); - rskExecutionBlock = getRskExecutionBlock(); - BtcLockSenderProvider btcLockSenderProvider = new BtcLockSenderProvider(); FeePerKbSupport feePerKbSupport = getFeePerKbSupport(repository, bridgeConstants); @@ -77,8 +76,7 @@ void setUp() throws Exception{ BtcECKey btcPublicKey = BitcoinTestUtils.getBtcEcKeyFromSeed("seed"); rskReceiver = getRskReceiver(btcPublicKey); - btcTransferred = bridgeConstants.getMinimumPeginTxValue(activations); - bitcoinTransaction = createPegInTransaction(federationSupport.getActiveFederation().getAddress(), btcTransferred, btcPublicKey); + bitcoinTransaction = createPegInTransaction(federationSupport.getActiveFederation().getAddress(), minimumPeginValue, btcPublicKey); pmtWithTransactions = createValidPmtForTransactions(List.of(bitcoinTransaction.getHash()), bridgeConstants.getBtcParams()); btcBlockWithPmtHeight = bridgeConstants.getBtcHeightWhenPegoutTxIndexActivates() + bridgeConstants.getPegoutTxIndexGracePeriodInBtcBlocks(); @@ -109,7 +107,7 @@ void whenRegisterALegacyBtcTransaction_shouldRegisterTheNewUtxoAndTransferTheRbt List expectedFederationUtxos = Collections.singletonList(utxoOf(bitcoinTransaction, output)); co.rsk.core.Coin receiverBalance = track.getBalance(rskReceiver); - co.rsk.core.Coin expectedReceiverBalance = receiverBalance.add(co.rsk.core.Coin.fromBitcoin(btcTransferred)); + co.rsk.core.Coin expectedReceiverBalance = receiverBalance.add(co.rsk.core.Coin.fromBitcoin(minimumPeginValue)); // Act registerBtcTransactionAndCommit(); @@ -121,7 +119,7 @@ void whenRegisterALegacyBtcTransaction_shouldRegisterTheNewUtxoAndTransferTheRbt assertEquals(expectedFederationUtxos, federationSupport.getActiveFederationBtcUTXOs()); assertEquals(expectedReceiverBalance, repository.getBalance(rskReceiver)); - verify(bridgeEventLogger, times(1)).logPeginBtc(rskReceiver, bitcoinTransaction, btcTransferred, 0); + verify(bridgeEventLogger, times(1)).logPeginBtc(rskReceiver, bitcoinTransaction, minimumPeginValue, 0); }