Skip to content

Commit

Permalink
feat: added a test to check a tx with negative block height is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
julianlen committed Dec 17, 2024
1 parent c3770fe commit a4aee36
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions rskj-core/src/test/java/co/rsk/peg/RegisterBtcTransactionIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,20 @@ void registerBtc_forARepeatedLegacyBtcTransaction_shouldNotPerformAnyChange() th
assertEquals(expectedReceiverBalance, repository.getBalance(rskReceiver));
}

@Test
void whenRegisterALegacyBtcTransactionWithNegativeHeight_shouldNotPerformAnyChange() throws Exception {
// Arrange
co.rsk.core.Coin expectedReceiverBalance = repository.getBalance(rskReceiver);
List<UTXO> expectedFederationUTXOs = federationSupport.getActiveFederationBtcUTXOs();

// Act
bridgeSupport.registerBtcTransaction(rskTx, bitcoinTransaction.bitcoinSerialize(), -1, pmtWithTransactions.bitcoinSerialize());
bridgeSupport.save();

// Assert
assertEquals(expectedFederationUTXOs, federationSupport.getActiveFederationBtcUTXOs());
assertEquals(expectedReceiverBalance, repository.getBalance(rskReceiver));
}
private static UTXO utxoOf(BtcTransaction bitcoinTransaction, TransactionOutput output) {
return new UTXO(
bitcoinTransaction.getHash(),
Expand Down

0 comments on commit a4aee36

Please sign in to comment.