Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erase the constant REGTEST_FEDERATION_PRIVATE_KEYS from the tests #2930

Open
wants to merge 12 commits into
base: bridge-refactors-integration
Choose a base branch
from

Conversation

julianlen
Copy link
Contributor

@julianlen julianlen commented Jan 13, 2025

Description

Motivation and Context

How Has This Been Tested?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • Tests for the changes have been added (for bug fixes / features)
  • Requires Activation Code (Hard Fork)
  • Other information:

Copy link

github-actions bot commented Jan 13, 2025

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files

Address federationAddress = genesisFederation.getAddress();
wallet.addWatchedAddress(federationAddress, genesisFederation.getCreationTime().toEpochMilli());
Federation federation = getErpFederationWithPrivKeys(networkParameters, fedKeys);
Wallet wallet = new BridgeBtcWallet(btcContext, Collections.singletonList(federation));

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation

Invoking [PegUtilsLegacy.isValidPegInTx](1) should be avoided because it has been deprecated.
Wallet federationWallet = new BridgeBtcWallet(btcContext, Collections.singletonList(genesisFederation));
assertTrue(isValidPegInTx(tx, genesisFederation, federationWallet, bridgeConstantsMainnet, activations));
Wallet federationWallet = new BridgeBtcWallet(btcContext, Collections.singletonList(federation));
assertTrue(isValidPegInTx(tx, federation, federationWallet, bridgeConstantsMainnet, activations));

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation

Invoking [PegUtilsLegacy.isValidPegInTx](1) should be avoided because it has been deprecated.
Wallet federationWallet = new BridgeBtcWallet(btcContext, Collections.singletonList(genesisFederation));
assertFalse(isValidPegInTx(tx, genesisFederation, federationWallet, bridgeConstantsMainnet, activations));
Wallet federationWallet = new BridgeBtcWallet(btcContext, Collections.singletonList(federation));
assertFalse(isValidPegInTx(tx, federation, federationWallet, bridgeConstantsMainnet, activations));

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation

Invoking [PegUtilsLegacy.isValidPegInTx](1) should be avoided because it has been deprecated.
Wallet federationWallet = new BridgeBtcWallet(btcContext, Collections.singletonList(genesisFederation));
assertTrue(isValidPegInTx(tx, genesisFederation, federationWallet, bridgeConstantsMainnet, activations));
Wallet federationWallet = new BridgeBtcWallet(btcContext, Collections.singletonList(federation));
assertTrue(isValidPegInTx(tx, federation, federationWallet, bridgeConstantsMainnet, activations));

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation

Invoking [PegUtilsLegacy.isValidPegInTx](1) should be avoided because it has been deprecated.

assertTrue(scriptCorrectlySpendsTx(tx, 0, genesisFederation.getP2SHScript()));
assertTrue(scriptCorrectlySpendsTx(tx, 0, federation.getP2SHScript()));

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation

Invoking [PegUtilsLegacy.scriptCorrectlySpendsTx](1) should be avoided because it has been deprecated.
@@ -2289,7 +2285,7 @@
.build();
tx.getInput(0).setScriptSig(invalidScript);

assertFalse(scriptCorrectlySpendsTx(tx, 0, genesisFederation.getP2SHScript()));
assertFalse(scriptCorrectlySpendsTx(tx, 0, federation.getP2SHScript()));

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation

Invoking [PegUtilsLegacy.scriptCorrectlySpendsTx](1) should be avoided because it has been deprecated.
@julianlen julianlen marked this pull request as ready for review January 13, 2025 19:07
@julianlen julianlen requested a review from a team as a code owner January 13, 2025 19:07
@julianlen
Copy link
Contributor Author

The tests in https://github.com/rsksmart/rskj/blob/398faa59ef120c989d61cacbd4492969bbe5bf59/rskj-core/src/test/java/co/rsk/peg/RskForksBridgeTest.java use REGTEST_FEDERATION_PRIVATE_KEYS. However, it's not straightforward to erase it since it uses the testing class World which has embedded the constants for the bridge

@julianlen julianlen force-pushed the erase-genesisfed-pKeys branch from 343f19d to aa90966 Compare January 14, 2025 14:36
@julianlen julianlen changed the base branch from master to bridge-refactors-integration January 14, 2025 14:36
@julianlen julianlen force-pushed the erase-genesisfed-pKeys branch from 8ba7ec8 to 7c135be Compare January 14, 2025 18:47
@@ -304,7 +304,7 @@ public static Constants regtest() {
);
}

public static Constants regtestWithFederation(List<BtcECKey> genesisFederationPublicKeys) {
public static Constants regtestWithFederation(List<BtcECKey> federation) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public static Constants regtestWithFederation(List<BtcECKey> federation) {
public static Constants regtestWithFederation(List<BtcECKey> federationPublicKeys) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

BtcECKey.fromPrivate(Hex.decode("45c5b07fc1a6f58892615b7c31dca6c96db58c4bbc538a6b8a22999aaa860c32")),
BtcECKey.fromPrivate(Hex.decode("505334c7745df2fc61486dffb900784505776a898377172ffa77384892749179")),
BtcECKey.fromPrivate(Hex.decode("bed0af2ce8aa8cb2bc3f9416c9d518fdee15d1ff15b8ded28376fcb23db6db69"))
private static final List<BtcECKey> retiringFedKeys = BitcoinTestUtils.getBtcEcKeysFromSeeds(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why retiring fed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a copy paste, my bad! Fixed!

BtcECKey.fromPrivate(Hex.decode("45c5b07fc1a6f58892615b7c31dca6c96db58c4bbc538a6b8a22999aaa860c32")),
BtcECKey.fromPrivate(Hex.decode("505334c7745df2fc61486dffb900784505776a898377172ffa77384892749179")),
BtcECKey.fromPrivate(Hex.decode("bed0af2ce8aa8cb2bc3f9416c9d518fdee15d1ff15b8ded28376fcb23db6db69"))
private static final List<BtcECKey> fedECKeys = BitcoinTestUtils.getBtcEcKeysFromSeeds(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private static final List<BtcECKey> fedECKeys = BitcoinTestUtils.getBtcEcKeysFromSeeds(
private static final List<BtcECKey> fedBtcECKeys = BitcoinTestUtils.getBtcEcKeysFromSeeds(

careful, ECKeys is for rsk and mst keys.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how's that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just in case, it is fixed already!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants