Skip to content

Commit

Permalink
fix: moved variables as final and renamed btcTransferred to minimumPe…
Browse files Browse the repository at this point in the history
…gintxValue
  • Loading branch information
julianlen committed Dec 17, 2024
1 parent d7a0091 commit 710857d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
20 changes: 9 additions & 11 deletions rskj-core/src/test/java/co/rsk/peg/RegisterBtcTransactionIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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();
Expand Down Expand Up @@ -109,7 +107,7 @@ void whenRegisterALegacyBtcTransaction_shouldRegisterTheNewUtxoAndTransferTheRbt
List<UTXO> 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();
Expand All @@ -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);

}

Expand Down

0 comments on commit 710857d

Please sign in to comment.