From a4aee36c9c0fe77003fa031532cb6d79be21fdda Mon Sep 17 00:00:00 2001 From: Julian Len Date: Fri, 13 Dec 2024 18:35:10 -0300 Subject: [PATCH] feat: added a test to check a tx with negative block height is invalid --- .../java/co/rsk/peg/RegisterBtcTransactionIT.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 857b99a3cf..467a0c3718 100644 --- a/rskj-core/src/test/java/co/rsk/peg/RegisterBtcTransactionIT.java +++ b/rskj-core/src/test/java/co/rsk/peg/RegisterBtcTransactionIT.java @@ -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 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(),