Skip to content

Commit

Permalink
Improve readiness of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanieliov committed Sep 16, 2024
1 parent b299134 commit ec64a34
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
17 changes: 12 additions & 5 deletions rskj-core/src/test/java/co/rsk/peg/PegUtilsLegacyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import co.rsk.bitcoinj.wallet.RedeemData;
import co.rsk.bitcoinj.wallet.Wallet;
import co.rsk.peg.bitcoin.ErpRedeemScriptBuilder;
import co.rsk.peg.bitcoin.NonStandardErpRedeemScriptBuilder;
import co.rsk.peg.bitcoin.NonStandardErpRedeemScriptBuilderFactory;
import co.rsk.peg.constants.BridgeConstants;
import co.rsk.peg.constants.BridgeMainNetConstants;
Expand Down Expand Up @@ -527,7 +526,9 @@ void testIsValidPegInTx_hasChangeUtxoFromFlyoverFederation_afterRskip201_notPegi
// Create a tx from the fast bridge fed to the active fed
BtcTransaction tx = new BtcTransaction(bridgeConstantsMainnet.getBtcParams());
tx.addOutput(Coin.COIN, activeFederation.getAddress());
tx.addInput(Sha256Hash.ZERO_HASH, 0, ScriptBuilder.createP2SHMultiSigInputScript(null, flyoverRedeemScript));

Script flyoverInputScriptSig = ScriptBuilder.createP2SHMultiSigInputScript(null, flyoverRedeemScript);
tx.addInput(Sha256Hash.ZERO_HASH, 0, flyoverInputScriptSig);

Wallet federationWallet = new BridgeBtcWallet(btcContext, Collections.singletonList(activeFederation));
Assertions.assertFalse(isValidPegInTx(tx, activeFederation, federationWallet,
Expand Down Expand Up @@ -611,7 +612,9 @@ void testIsValidPegInTx_hasChangeUtxoFromFlyoverErpFederation_afterRskip201_notP
// Create a tx from the fast bridge erp fed to the active fed
BtcTransaction tx = new BtcTransaction(networkParameters);
tx.addOutput(Coin.COIN, activeFederation.getAddress());
tx.addInput(Sha256Hash.ZERO_HASH, 0, ScriptBuilder.createP2SHMultiSigInputScript(null, flyoverErpRedeemScript));

Script flyoverInputScriptSig = ScriptBuilder.createP2SHMultiSigInputScript(null, flyoverErpRedeemScript);
tx.addInput(Sha256Hash.ZERO_HASH, 0, flyoverInputScriptSig);

Wallet federationWallet = new BridgeBtcWallet(btcContext, Collections.singletonList(activeFederation));

Expand Down Expand Up @@ -706,7 +709,9 @@ void testIsValidPegInTx_hasChangeUtxoFromErpFederation_afterRskip201_notPegin()
// Create a tx from the erp fed to the active fed
BtcTransaction tx = new BtcTransaction(networkParameters);
tx.addOutput(Coin.COIN, activeFederation.getAddress());
tx.addInput(Sha256Hash.ZERO_HASH, 0, ScriptBuilder.createP2SHMultiSigInputScript(null, erpRedeemScript));

Script flyoverInputScriptSig = ScriptBuilder.createP2SHMultiSigInputScript(null, erpRedeemScript);
tx.addInput(Sha256Hash.ZERO_HASH, 0, flyoverInputScriptSig);

Wallet federationWallet = new BridgeBtcWallet(btcContext, Collections.singletonList(activeFederation));

Expand Down Expand Up @@ -1250,10 +1255,12 @@ private void testIsValidPegInTx_fromP2shErpScriptSender(
BtcTransaction tx = new BtcTransaction(networkParameters);
tx.addOutput(Coin.COIN, destinationAddress);

Script inputScriptSig = ScriptBuilder.createP2SHMultiSigInputScript(null,
flyoverFederation ? flyoverP2shErpRedeemScript : p2shErpFederation.getRedeemScript());
tx.addInput(
Sha256Hash.ZERO_HASH,
0,
ScriptBuilder.createP2SHMultiSigInputScript(null, flyoverFederation ? flyoverP2shErpRedeemScript : p2shErpFederation.getRedeemScript())
inputScriptSig
);

Wallet federationWallet = new BridgeBtcWallet(btcContext, Collections.singletonList(activeFederation));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ void removeSignaturesFromTransaction_whenNotAllTransactionInputsHaveP2shMultiSig
@Test
void removeSignaturesFromTransaction_whenTransactionIsLegacyAndInputsHaveP2shMultiSigInputScript_shouldRemoveSignatures() {
// arrange

Federation federation = P2shErpFederationBuilder.builder().build();
Script scriptSig = federation.getP2SHScript().createEmptyInputScript(null, federation.getRedeemScript());

Expand Down

0 comments on commit ec64a34

Please sign in to comment.