Skip to content

Commit

Permalink
Use MainNet Constants and Parameters.
Browse files Browse the repository at this point in the history
  • Loading branch information
wilmerrootstock committed Sep 17, 2024
1 parent 46d592c commit c9f1e9c
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions rskj-core/src/test/java/co/rsk/peg/PegUtilsLegacyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand All @@ -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<BtcECKey> 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<BtcECKey> 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
Expand Down

0 comments on commit c9f1e9c

Please sign in to comment.