From c9f1e9c94656901f43f43ef41baaa0c18b234c91 Mon Sep 17 00:00:00 2001 From: Wilmer Rondon Date: Tue, 17 Sep 2024 13:17:10 -0400 Subject: [PATCH] Use MainNet Constants and Parameters. --- .../java/co/rsk/peg/PegUtilsLegacyTest.java | 35 ++++++++----------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/rskj-core/src/test/java/co/rsk/peg/PegUtilsLegacyTest.java b/rskj-core/src/test/java/co/rsk/peg/PegUtilsLegacyTest.java index 538018e8576..c0d08b9a918 100644 --- a/rskj-core/src/test/java/co/rsk/peg/PegUtilsLegacyTest.java +++ b/rskj-core/src/test/java/co/rsk/peg/PegUtilsLegacyTest.java @@ -585,7 +585,8 @@ void testIsValidPegInTx_hasChangeUtxoFromFlyoverErpFederation_beforeRskip201_isP @Test void testIsValidPegInTx_hasChangeUtxoFromFlyoverErpFederation_afterRskip201_notPegin() { - Context btcContext = new Context(networkParameters); + NetworkParameters mainnetBtcParams = bridgeConstantsMainnet.getBtcParams(); + Context btcContext = new Context(mainnetBtcParams); when(activations.isActive(ConsensusRule.RSKIP201)).thenReturn(true); Federation activeFederation = FederationTestUtils.getGenesisFederation(federationConstantsMainnet); @@ -596,7 +597,7 @@ void testIsValidPegInTx_hasChangeUtxoFromFlyoverErpFederation_afterRskip201_notP ); // Create a tx from the fast bridge erp fed to the active fed - BtcTransaction tx = new BtcTransaction(networkParameters); + BtcTransaction tx = new BtcTransaction(mainnetBtcParams); tx.addOutput(Coin.COIN, activeFederation.getAddress()); tx.addInput(Sha256Hash.ZERO_HASH, 0, flyoverErpRedeemScript); @@ -606,55 +607,47 @@ void testIsValidPegInTx_hasChangeUtxoFromFlyoverErpFederation_afterRskip201_notP tx, activeFederation, federationWallet, - bridgeConstantsRegtest, + bridgeConstantsMainnet, activations )); } @Test void testIsValidPegInTx_hasChangeUtxoFromErpFederation_beforeRskip201_isPegin() { - Context btcContext = new Context(networkParameters); + NetworkParameters mainnetBtcParams = bridgeConstantsMainnet.getBtcParams(); + Context btcContext = new Context(mainnetBtcParams); when(activations.isActive(ConsensusRule.RSKIP201)).thenReturn(false); - Federation activeFederation = FederationTestUtils.getGenesisFederation(federationConstantsRegtest); - List erpFederationKeys = Arrays.asList( - BtcECKey.fromPrivate(Hex.decode("fa01")), - BtcECKey.fromPrivate(Hex.decode("fa02")) - ); - erpFederationKeys.sort(BtcECKey.PUBKEY_COMPARATOR); + Federation activeFederation = FederationTestUtils.getGenesisFederation(federationConstantsMainnet); // Create a tx from the erp fed to the active fed - BtcTransaction tx = new BtcTransaction(networkParameters); + BtcTransaction tx = new BtcTransaction(mainnetBtcParams); tx.addOutput(Coin.COIN, activeFederation.getAddress()); tx.addInput(Sha256Hash.ZERO_HASH, 0, nonStandardErpRedeemScript); Wallet federationWallet = new BridgeBtcWallet(btcContext, Collections.singletonList(activeFederation)); Assertions.assertTrue(isValidPegInTx(tx, activeFederation, federationWallet, - bridgeConstantsRegtest, activations)); + bridgeConstantsMainnet, activations)); } @Test void testIsValidPegInTx_hasChangeUtxoFromErpFederation_afterRskip201_notPegin() { - Context btcContext = new Context(networkParameters); + NetworkParameters mainnetBtcParams = bridgeConstantsMainnet.getBtcParams(); + Context btcContext = new Context(mainnetBtcParams); when(activations.isActive(ConsensusRule.RSKIP201)).thenReturn(true); - Federation activeFederation = FederationTestUtils.getGenesisFederation(federationConstantsRegtest); - List erpFederationKeys = Arrays.asList( - BtcECKey.fromPrivate(Hex.decode("fa01")), - BtcECKey.fromPrivate(Hex.decode("fa02")) - ); - erpFederationKeys.sort(BtcECKey.PUBKEY_COMPARATOR); + Federation activeFederation = FederationTestUtils.getGenesisFederation(federationConstantsMainnet); // Create a tx from the erp fed to the active fed - BtcTransaction tx = new BtcTransaction(networkParameters); + BtcTransaction tx = new BtcTransaction(mainnetBtcParams); tx.addOutput(Coin.COIN, activeFederation.getAddress()); tx.addInput(Sha256Hash.ZERO_HASH, 0, nonStandardErpRedeemScript); Wallet federationWallet = new BridgeBtcWallet(btcContext, Collections.singletonList(activeFederation)); Assertions.assertFalse(isValidPegInTx(tx, activeFederation, federationWallet, - bridgeConstantsRegtest, activations)); + bridgeConstantsMainnet, activations)); } @Test