Skip to content

Commit

Permalink
feat: a legacy pegin transaction below the minimum should fail and th…
Browse files Browse the repository at this point in the history
…e funds not refunded
  • Loading branch information
julianlen committed Jan 7, 2025
1 parent 1c1e721 commit c21c0af
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions rskj-core/src/test/java/co/rsk/peg/RegisterBtcTransactionIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ void registerBtcTransaction_whenLegacyPeginBtcTransactionFromAMultiSig_shouldRef
Address pegoutReceiver = pegOutOutput.getAddressFromP2SH(btcNetworkParams);
assertEquals(pegInTxSender, pegoutReceiver);

assertRejectedPeginTransaction(btcTransaction);
assertRejectedPeginTransaction(btcTransaction, BridgeEvents.REJECTED_PEGIN.getEvent(), RejectedPeginReason.LEGACY_PEGIN_MULTISIG_SENDER.getValue());
assertReleaseBtcRequested(rskTx.getHash().getBytes(), pegOut, minimumPeginValue);
assertPegoutTransactionCreated(pegOut.getHash(), UtxoUtils.extractOutpointValues(pegOut));

Expand Down Expand Up @@ -254,16 +254,16 @@ private BtcTransaction createPegInTransaction(Address federationAddress, Coin co
}

private BtcTransaction createMultiSigPegInTransaction(Address federationAddress, Coin coin) {
BtcTransaction btcTx = new BtcTransaction(btcNetworkParams);
BtcTransaction btcTransaction = new BtcTransaction(btcNetworkParams);

btcTx.addInput(
btcTransaction.addInput(
BitcoinTestUtils.createHash(1),
0,
ScriptBuilder.createP2SHMultiSigInputScript(null, federationSupport.getActiveFederation().getRedeemScript())
);
btcTx.addOutput(new TransactionOutput(btcNetworkParams, btcTx, coin, federationAddress));
btcTransaction.addOutput(new TransactionOutput(btcNetworkParams, btcTransaction, coin, federationAddress));

return btcTx;
return btcTransaction;
}

private void assertLogPegInBtc(BtcTransaction btcTransaction) {
Expand All @@ -279,11 +279,11 @@ private void assertLogPegInBtc(BtcTransaction btcTransaction) {
assertEventWasEmittedWithExpectedData(encodedData, logs);
}

private void assertRejectedPeginTransaction(BtcTransaction btcTransaction) {
CallTransaction.Function rejectedPeginEvent = BridgeEvents.REJECTED_PEGIN.getEvent();

private void assertRejectedPeginTransaction(BtcTransaction btcTransaction, CallTransaction.Function rejectionEvent, int rejectionReason) {
Sha256Hash peginTransactionHash = btcTransaction.getHash();
List<DataWord> encodedTopics = getEncodedTopics(rejectedPeginEvent, peginTransactionHash.getBytes());
byte[] encodedData = getEncodedData(rejectedPeginEvent, RejectedPeginReason.LEGACY_PEGIN_MULTISIG_SENDER.getValue());
List<DataWord> encodedTopics = getEncodedTopics(rejectionEvent, peginTransactionHash.getBytes());
byte[] encodedData = getEncodedData(rejectionEvent, rejectionReason);

assertEventWasEmittedWithExpectedTopics(encodedTopics, logs);
assertEventWasEmittedWithExpectedData(encodedData, logs);
Expand Down

0 comments on commit c21c0af

Please sign in to comment.