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 18, 2024
1 parent d956d40 commit bc71e17
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 @@ -147,6 +147,20 @@ void registerBtcTransaction_forARepeatedLegacyBtcTransaction_shouldNotPerformAny
assertEquals(expectedReceiverBalance, repository.getBalance(rskReceiver));
}

@Test
void registerBtcTransaction_forALegacyBtcTransactionWithNegativeHeight_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 bc71e17

Please sign in to comment.