Repository: rsksmart/rskj
Pull request #3013: Rollback the custom regtest federation private keys to the default ones
Author: login: julianlen
Created: 2025-02-28T16:11:28Z | Merged: 2025-03-07T15:27:51Z

BridgeRegTestConstants is now a singleton. BridgeRegTestConstants stores the instance of FederationRegTestConstants in a global variable. Since all the tests share this variable, the test will fail if they try to use different Regtest federation private keys.


Diff:
diff --git a/rskj-core/src/test/java/co/rsk/net/handler/txvalidator/TxValidatorIntrinsicGasLimitValidatorTest.java b/rskj-core/src/test/java/co/rsk/net/handler/txvalidator/TxValidatorIntrinsicGasLimitValidatorTest.java
index d4252425682..55f3eb12272 100644
--- a/rskj-core/src/test/java/co/rsk/net/handler/txvalidator/TxValidatorIntrinsicGasLimitValidatorTest.java
+++ b/rskj-core/src/test/java/co/rsk/net/handler/txvalidator/TxValidatorIntrinsicGasLimitValidatorTest.java
@@ -17,14 +17,10 @@
  */
 package co.rsk.net.handler.txvalidator;
 
-import  static org.junit.jupiter.api.Assertions.assertFalse;
+import static co.rsk.peg.federation.FederationTestUtils.REGTEST_FEDERATION_PRIVATE_KEYS;
+import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import co.rsk.bitcoinj.core.BtcECKey;
-
-import java.util.List;
-
-import co.rsk.peg.bitcoin.BitcoinTestUtils;
 import org.bouncycastle.util.encoders.Hex;
 import org.ethereum.config.Constants;
 import org.ethereum.config.blockchain.upgrades.ActivationConfig;
@@ -42,16 +38,12 @@
 import java.math.BigInteger;
 
 class TxValidatorIntrinsicGasLimitValidatorTest {
-    private static final List<BtcECKey> fedBtcECKeys = BitcoinTestUtils.getBtcEcKeysFromSeeds(
-        new String[]{"fa01", "fa02", "fa03"}, true
-    );
-
     private Constants constants;
     private ActivationConfig activationConfig;
 
     @BeforeEach
     void setUp() {
-        constants = Constants.regtestWithFederation(fedBtcECKeys);
+        constants = Constants.regtest();
         activationConfig = ActivationConfigsForTest.allBut(ConsensusRule.ARE_BRIDGE_TXS_PAID);
     }
 
@@ -101,7 +93,7 @@ void validIntrinsicGasPrice() {
             .chainId(Constants.REGTEST_CHAIN_ID)
             .value(BigInteger.ZERO)
             .build();
-        tx4.sign(fedBtcECKeys.get(0).getPrivKeyBytes());
+        tx4.sign(REGTEST_FEDERATION_PRIVATE_KEYS.get(0).getPrivKeyBytes());
 
         TxValidatorIntrinsicGasLimitValidator tvigpv = new TxValidatorIntrinsicGasLimitValidator(
             constants,
diff --git a/rskj-core/src/test/java/co/rsk/peg/BridgeCostsTest.java b/rskj-core/src/test/java/co/rsk/peg/BridgeCostsTest.java
index 59100a1f12d..cc3e61b915d 100644
--- a/rskj-core/src/test/java/co/rsk/peg/BridgeCostsTest.java
+++ b/rskj-core/src/test/java/co/rsk/peg/BridgeCostsTest.java
@@ -1,8 +1,6 @@
 package co.rsk.peg;
 
-import co.rsk.bitcoinj.core.BtcECKey;
 import co.rsk.blockchain.utils.BlockGenerator;
-import co.rsk.peg.bitcoin.BitcoinTestUtils;
 import co.rsk.peg.constants.BridgeRegTestConstants;
 import co.rsk.config.RskSystemProperties;
 import co.rsk.config.TestSystemProperties;
@@ -22,8 +20,7 @@
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
-import java.util.List;
-
+import static co.rsk.peg.federation.FederationTestUtils.REGTEST_FEDERATION_PRIVATE_KEYS;
 import static org.ethereum.config.blockchain.upgrades.ConsensusRule.RSKIP124;
 import static org.ethereum.config.blockchain.upgrades.ConsensusRule.RSKIP132;
 import static org.mockito.ArgumentMatchers.anyLong;
@@ -31,9 +28,6 @@
 import static org.mockito.Mockito.*;
 
 class BridgeCostsTest {
-    private static final List<BtcECKey> fedBtcECKeys = BitcoinTestUtils.getBtcEcKeysFromSeeds(
-        new String[]{"fa01", "fa02", "fa03"}, true
-    );
     private static BridgeRegTestConstants bridgeConstants;
     private TestSystemProperties config = new TestSystemProperties();
     private Constants constants;
@@ -43,13 +37,13 @@ class BridgeCostsTest {
 
     @BeforeAll
      static void setUpBeforeClass() {
-        bridgeConstants = new BridgeRegTestConstants(fedBtcECKeys);
+        bridgeConstants = new BridgeRegTestConstants();
     }
 
     @BeforeEach
     void resetConfigToRegTest() {
         config = spy(new TestSystemProperties());
-        constants = Constants.regtestWithFederation(fedBtcECKeys);
+        constants = Constants.regtest();
         when(config.getNetworkConstants()).thenReturn(constants);
         activationConfig = spy(ActivationConfigsForTest.genesis());
         when(config.getActivationConfig()).thenReturn(activationConfig);
@@ -149,7 +143,7 @@ void getGasForDataFreeTx() {
                 0,
                 Bridge.UPDATE_COLLECTIONS,
                 Constants.REGTEST_CHAIN_ID);
-        rskTx.sign(fedBtcECKeys.get(0).getPrivKeyBytes());
+        rskTx.sign(REGTEST_FEDERATION_PRIVATE_KEYS.get(0).getPrivKeyBytes());
 
         Block rskExecutionBlock = new BlockGenerator().createChildBlock(getGenesisInstance(config));
 
@@ -252,7 +246,7 @@ private void getGasForDataPaidTx(int expected, CallTransaction.Function function
             );
         }
 
-        rskTx.sign(fedBtcECKeys.get(0).getPrivKeyBytes());
+        rskTx.sign(REGTEST_FEDERATION_PRIVATE_KEYS.get(0).getPrivKeyBytes());
 
         BlockGenerator blockGenerator = new BlockGenerator();
         Block rskExecutionBlock = blockGenerator.createChildBlock(getGenesisInstance(config));
diff --git a/rskj-core/src/test/java/co/rsk/peg/BridgeIT.java b/rskj-core/src/test/java/co/rsk/peg/BridgeIT.java
index 544e24ad759..5bbd75af514 100644
--- a/rskj-core/src/test/java/co/rsk/peg/BridgeIT.java
+++ b/rskj-core/src/test/java/co/rsk/peg/BridgeIT.java
@@ -19,6 +19,7 @@
 
 import static co.rsk.bitcoinj.core.Utils.uint32ToByteStreamLE;
 import static co.rsk.peg.federation.FederationStorageIndexKey.*;
+import static co.rsk.peg.federation.FederationTestUtils.REGTEST_FEDERATION_PRIVATE_KEYS;
 import static org.ethereum.config.blockchain.upgrades.ConsensusRule.*;
 import static org.hamcrest.CoreMatchers.is;
 import static org.junit.jupiter.api.Assertions.*;
@@ -102,11 +103,6 @@
 class BridgeIT {
     private static final RskAddress BRIDGE_ADDRESS = PrecompiledContracts.BRIDGE_ADDR;
     private static final String BRIDGE_ADDRESS_TO_STRING = PrecompiledContracts.BRIDGE_ADDR_STR;
-    private static final List<BtcECKey> REGTEST_FEDERATION_PRIVATE_KEYS = Arrays.asList(
-        BtcECKey.fromPrivate(Hex.decode("45c5b07fc1a6f58892615b7c31dca6c96db58c4bbc538a6b8a22999aaa860c32")),
-        BtcECKey.fromPrivate(Hex.decode("505334c7745df2fc61486dffb900784505776a898377172ffa77384892749179")),
-        BtcECKey.fromPrivate(Hex.decode("bed0af2ce8aa8cb2bc3f9416c9d518fdee15d1ff15b8ded28376fcb23db6db69"))
-    );
     private static final ECKey federatorECKey = ECKey.fromPrivate(REGTEST_FEDERATION_PRIVATE_KEYS.get(0).getPrivKey());
     private static final String[] ACTIVE_FED_SEEDS = new String[] {
         "activeFedMember1",
@@ -1610,7 +1606,7 @@ void getGasForDataFreeTx() {
                 0,
                 Bridge.UPDATE_COLLECTIONS,
                 Constants.REGTEST_CHAIN_ID);
-        rskTx.sign(ACTIVE_FEDERATION_KEYS.get(0).getPrivKeyBytes());
+        rskTx.sign(REGTEST_FEDERATION_PRIVATE_KEYS.get(0).getPrivKeyBytes());
 
         Block rskExecutionBlock = new BlockGenerator().createChildBlock(getGenesisInstance(config));
 
@@ -3363,7 +3359,7 @@ void receiveHeadersAccess_beforePublic_noAccessIfNotFromFederationMember() throw
     void receiveHeadersAccess_beforePublic_accessIfFromFederationMember() throws Exception {
         doReturn(false).when(activationConfig).isActive(eq(RSKIP124), anyLong());
 
-        byte[] privKeyBytes = ACTIVE_FEDERATION_KEYS.get(0).getPrivKeyBytes();
+        byte[] privKeyBytes = REGTEST_FEDERATION_PRIVATE_KEYS.get(0).getPrivKeyBytes();
         RskAddress sender = new RskAddress(ECKey.fromPrivate(privKeyBytes).getAddress());
 
         Transaction txMock = mock(Transaction.class);
diff --git a/rskj-core/src/test/java/co/rsk/peg/BridgeSupportAddSignatureTest.java b/rskj-core/src/test/java/co/rsk/peg/BridgeSupportAddSignatureTest.java
index d47f7250cf6..a12347495ef 100644
--- a/rskj-core/src/test/java/co/rsk/peg/BridgeSupportAddSignatureTest.java
+++ b/rskj-core/src/test/java/co/rsk/peg/BridgeSupportAddSignatureTest.java
@@ -3,6 +3,7 @@
 import static co.rsk.peg.BridgeSupportTestUtil.createRepository;
 import static co.rsk.peg.PegTestUtils.createBaseInputScriptThatSpendsFromTheFederation;
 import static co.rsk.peg.PegTestUtils.createHash3;
+import static co.rsk.peg.federation.FederationTestUtils.REGTEST_FEDERATION_PRIVATE_KEYS;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.hasItem;
 import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
@@ -18,7 +19,6 @@
 import co.rsk.bitcoinj.script.ScriptChunk;
 import co.rsk.core.RskAddress;
 import co.rsk.crypto.Keccak256;
-import co.rsk.peg.bitcoin.BitcoinTestUtils;
 import co.rsk.peg.btcLockSender.BtcLockSenderProvider;
 import co.rsk.peg.constants.*;
 import co.rsk.peg.federation.*;
@@ -57,12 +57,10 @@
 
 class BridgeSupportAddSignatureTest {
     private static final RskAddress bridgeAddress = PrecompiledContracts.BRIDGE_ADDR;
-    private static final List<BtcECKey> federationECKeys = BitcoinTestUtils.getBtcEcKeysFromSeeds(
-        new String[]{"fa91", "fa92", "fa93"}, true
-    );
 
-    private final BridgeConstants bridgeRegTestConstants = new BridgeRegTestConstants(federationECKeys);
+    private final BridgeConstants bridgeRegTestConstants = new BridgeRegTestConstants();
     private final NetworkParameters btcRegTestParams = bridgeRegTestConstants.getBtcParams();
+    private final FederationConstants federationConstants = bridgeRegTestConstants.getFederationConstants();
     private final Instant creationTime = Instant.ofEpochMilli(1000L);
     private final long creationBlockNumber = 0L;
 
@@ -271,7 +269,6 @@ void addSignature_fedPubKey_no_belong_to_retiring_or_active_federation() throws
     @Test
     void addSignature_fedPubKey_no_belong_to_active_federation_no_existing_retiring_fed() throws Exception {
         BridgeStorageProvider provider = mock(BridgeStorageProvider.class);
-        FederationConstants federationConstants = bridgeRegTestConstants.getFederationConstants();
         FederationSupport federationSupport = createDefaultFederationSupport(federationConstants);
 
         BridgeSupport bridgeSupport = bridgeSupportBuilder
@@ -293,7 +290,7 @@ void addSignature_fedPubKey_no_belong_to_active_federation_no_existing_retiring_
     @Test
     void addSignatureToMissingTransaction() throws Exception {
         // Federation is the genesis federation ATM
-        Federation genesisFederation = FederationTestUtils.getGenesisFederation(bridgeRegTestConstants.getFederationConstants());
+        Federation genesisFederation = FederationTestUtils.getGenesisFederation(federationConstants);
         Repository repository = createRepository();
 
         BridgeStorageProvider providerForSupport = new BridgeStorageProvider(
@@ -303,7 +300,7 @@ void addSignatureToMissingTransaction() throws Exception {
             activationsBeforeForks
         );
         FederationStorageProvider federationStorageProvider = new FederationStorageProviderImpl(new BridgeStorageAccessorImpl(repository));
-        FederationSupport federationSupport = createFederationSupport(bridgeRegTestConstants.getFederationConstants(), federationStorageProvider, mock(Block.class), activationsBeforeForks);
+        FederationSupport federationSupport = createFederationSupport(federationConstants, federationStorageProvider, mock(Block.class), activationsBeforeForks);
 
         BridgeSupport bridgeSupport = bridgeSupportBuilder
             .withBridgeConstants(bridgeRegTestConstants)
@@ -334,7 +331,7 @@ void addSignatureFromInvalidFederator() throws Exception {
 
         Repository repository = createRepository();
         BridgeStorageProvider bridgeStorageProvider = new BridgeStorageProvider(repository, bridgeAddress, btcRegTestParams, activationsBeforeForks);
-        FederationSupport federationSupport = createDefaultFederationSupport(bridgeRegTestConstants.getFederationConstants());
+        FederationSupport federationSupport = createDefaultFederationSupport(federationConstants);
 
         BridgeSupport bridgeSupport = bridgeSupportBuilder
             .withBridgeConstants(bridgeRegTestConstants)
@@ -365,25 +362,25 @@ void addSignatureWithInvalidSignature() throws Exception {
 
     @Test
     void addSignatureWithLessSignaturesThanExpected() throws Exception {
-        List<BtcECKey> keys = Collections.singletonList(federationECKeys.get(0));
+        List<BtcECKey> keys = Collections.singletonList(REGTEST_FEDERATION_PRIVATE_KEYS.get(0));
         addSignatureFromValidFederator(keys, 0, true, false, "InvalidParameters");
     }
 
     @Test
     void addSignatureWithMoreSignaturesThanExpected() throws Exception {
-        List<BtcECKey> keys = Collections.singletonList(federationECKeys.get(0));
+        List<BtcECKey> keys = Collections.singletonList(REGTEST_FEDERATION_PRIVATE_KEYS.get(0));
         addSignatureFromValidFederator(keys, 2, true, false, "InvalidParameters");
     }
 
     @Test
     void addSignatureNonCanonicalSignature() throws Exception {
-        List<BtcECKey> keys = Collections.singletonList(federationECKeys.get(0));
+        List<BtcECKey> keys = Collections.singletonList(REGTEST_FEDERATION_PRIVATE_KEYS.get(0));
         addSignatureFromValidFederator(keys, 1, false, false, "InvalidParameters");
     }
 
     private void test_addSignature_EventEmitted(boolean rskip326Active, boolean useValidSignature, int wantedNumberOfInvocations, boolean shouldSignTwice) throws Exception {
         // Setup
-        Federation genesisFederation = FederationTestUtils.getGenesisFederation(bridgeRegTestConstants.getFederationConstants());
+        Federation genesisFederation = FederationTestUtils.getGenesisFederation(federationConstants);
         Repository track = createRepository().startTracking();
         BridgeStorageProvider provider = new BridgeStorageProvider(track, bridgeAddress, btcRegTestParams, activationsBeforeForks);
 
@@ -412,7 +409,7 @@ private void test_addSignature_EventEmitted(boolean rskip326Active, boolean useV
         when(activations.isActive(ConsensusRule.RSKIP146)).thenReturn(true);
         when(activations.isActive(ConsensusRule.RSKIP326)).thenReturn(rskip326Active);
 
-        FederationSupport federationSupport = createDefaultFederationSupport(bridgeRegTestConstants.getFederationConstants());
+        FederationSupport federationSupport = createDefaultFederationSupport(federationConstants);
         BridgeSupport bridgeSupport = bridgeSupportBuilder
             .withBridgeConstants(bridgeRegTestConstants)
             .withProvider(provider)
@@ -426,7 +423,7 @@ private void test_addSignature_EventEmitted(boolean rskip326Active, boolean useV
 
         int indexOfKeyToSignWith = 0;
 
-        BtcECKey privateKeyToSignWith = federationECKeys.get(indexOfKeyToSignWith);
+        BtcECKey privateKeyToSignWith = REGTEST_FEDERATION_PRIVATE_KEYS.get(indexOfKeyToSignWith);
 
         List<byte[]> derEncodedSigs;
 
@@ -446,7 +443,7 @@ private void test_addSignature_EventEmitted(boolean rskip326Active, boolean useV
             derEncodedSigs = Collections.singletonList(malformedSignature);
         }
 
-        BtcECKey federatorPubKey = federationECKeys.get(indexOfKeyToSignWith);
+        BtcECKey federatorPubKey = federationConstants.getGenesisFederationPublicKeys().get(indexOfKeyToSignWith);
         FederationMember federationMember = FederationTestUtils.getFederationMemberWithKey(federatorPubKey);
         bridgeSupport.addSignature(federatorPubKey, derEncodedSigs, rskTxHash);
         if (shouldSignTwice) {
@@ -488,19 +485,19 @@ void addSignature_invalidSignatureAfterRSKIP326_noEventEmitted() throws Exceptio
 
     @Test
     void addSignatureTwice() throws Exception {
-        List<BtcECKey> keys = Collections.singletonList(federationECKeys.get(0));
+        List<BtcECKey> keys = Collections.singletonList(REGTEST_FEDERATION_PRIVATE_KEYS.get(0));
         addSignatureFromValidFederator(keys, 1, true, true, "PartiallySigned");
     }
 
     @Test
     void addSignatureOneSignature() throws Exception {
-        List<BtcECKey> keys = Collections.singletonList(federationECKeys.get(0));
+        List<BtcECKey> keys = Collections.singletonList(REGTEST_FEDERATION_PRIVATE_KEYS.get(0));
         addSignatureFromValidFederator(keys, 1, true, false, "PartiallySigned");
     }
 
     @Test
     void addSignatureTwoSignatures() throws Exception {
-        List<BtcECKey> federatorPrivateKeys = federationECKeys;
+        List<BtcECKey> federatorPrivateKeys = REGTEST_FEDERATION_PRIVATE_KEYS;
         List<BtcECKey> keys = Arrays.asList(federatorPrivateKeys.get(0), federatorPrivateKeys.get(1));
         addSignatureFromValidFederator(keys, 1, true, false, "FullySigned");
     }
@@ -508,7 +505,7 @@ void addSignatureTwoSignatures() throws Exception {
     @Test
     void addSignatureMultipleInputsPartiallyValid() throws Exception {
         // Federation is the genesis federation ATM
-        Federation genesisFederation = FederationTestUtils.getGenesisFederation(bridgeRegTestConstants.getFederationConstants());
+        Federation genesisFederation = FederationTestUtils.getGenesisFederation(federationConstants);
         Repository repository = createRepository();
 
         final Keccak256 keccak256 = createHash3(1);
@@ -539,7 +536,7 @@ void addSignatureMultipleInputsPartiallyValid() throws Exception {
         List<LogInfo> logs = new ArrayList<>();
         BridgeEventLogger eventLogger = new BrigeEventLoggerLegacyImpl(bridgeRegTestConstants, activations, logs);
 
-        FederationSupport federationSupport = createDefaultFederationSupport(bridgeRegTestConstants.getFederationConstants());
+        FederationSupport federationSupport = createDefaultFederationSupport(federationConstants);
 
         BridgeSupport bridgeSupport = bridgeSupportBuilder
             .withBridgeConstants(bridgeRegTestConstants)
@@ -552,8 +549,8 @@ void addSignatureMultipleInputsPartiallyValid() throws Exception {
         // Generate valid signatures for inputs
         List<byte[]> derEncodedSigsFirstFed = new ArrayList<>();
         List<byte[]> derEncodedSigsSecondFed = new ArrayList<>();
-        BtcECKey privateKeyOfFirstFed = federationECKeys.get(0);
-        BtcECKey privateKeyOfSecondFed = federationECKeys.get(1);
+        BtcECKey privateKeyOfFirstFed = REGTEST_FEDERATION_PRIVATE_KEYS.get(0);
+        BtcECKey privateKeyOfSecondFed = REGTEST_FEDERATION_PRIVATE_KEYS.get(1);
 
         BtcECKey.ECDSASignature lastSig = null;
         for (int i = 0; i < 3; i++) {
@@ -756,7 +753,7 @@ private void commonAssertLogs(List<LogInfo> logs) {
      */
     private void addSignatureFromValidFederator(List<BtcECKey> privateKeysToSignWith, int numberOfInputsToSign, boolean signatureCanonical, boolean signTwice, String expectedResult) throws Exception {
         // Federation is the genesis federation ATM
-        Federation genesisFederation = FederationTestUtils.getGenesisFederation(bridgeRegTestConstants.getFederationConstants());
+        Federation genesisFederation = FederationTestUtils.getGenesisFederation(federationConstants);
         Repository repository = createRepository();
 
         final Keccak256 keccak256 = RskTestUtils.createHash(1);
@@ -786,7 +783,7 @@ private void addSignatureFromValidFederator(List<BtcECKey> privateKeysToSignWith
             btcRegTestParams,
             activationsAfterForks
         );
-        FederationSupport federationSupport = createDefaultFederationSupport(bridgeRegTestConstants.getFederationConstants());
+        FederationSupport federationSupport = createDefaultFederationSupport(federationConstants);
 
         BridgeSupport bridgeSupport = bridgeSupportBuilder
             .withBridgeConstants(bridgeRegTestConstants)
diff --git a/rskj-core/src/test/java/co/rsk/peg/BridgeSupportIT.java b/rskj-core/src/test/java/co/rsk/peg/BridgeSupportIT.java
index 1d9b7d1de5e..e3cc142e635 100644
--- a/rskj-core/src/test/java/co/rsk/peg/BridgeSupportIT.java
+++ b/rskj-core/src/test/java/co/rsk/peg/BridgeSupportIT.java
@@ -18,7 +18,7 @@
 package co.rsk.peg;
 
 import static co.rsk.peg.PegTestUtils.createFederation;
-import static co.rsk.peg.federation.FederationTestUtils.getFederationWithPrivateKeys;
+import static co.rsk.peg.federation.FederationTestUtils.REGTEST_FEDERATION_PRIVATE_KEYS;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.hasItem;
 import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
@@ -1648,8 +1648,7 @@ void registerBtcTransactionTxNotLockNorReleaseTx() throws BlockStoreException, A
 
     @Test
     void registerBtcTransactionReleaseTx() throws BlockStoreException, AddressFormatException, IOException, BridgeIllegalArgumentException {
-        List<BtcECKey> fedBtcECKeys = BitcoinTestUtils.getBtcEcKeysFromSeeds(new String[]{"fa01", "fa02"}, true);
-        Federation federation = getFederationWithPrivateKeys(fedBtcECKeys);
+        Federation federation = FederationTestUtils.getGenesisFederation(federationConstants);
         Repository repository = createRepository();
         repository.addBalance(PrecompiledContracts.BRIDGE_ADDR, LIMIT_MONETARY_BASE);
         Repository track = repository.startTracking();
@@ -1674,12 +1673,12 @@ void registerBtcTransactionReleaseTx() throws BlockStoreException, AddressFormat
         Script redeemScript = ScriptBuilder.createRedeemScript(federation.getNumberOfSignaturesRequired(), federation.getBtcPublicKeys());
         Sha256Hash sighash = tx.hashForSignature(0, redeemScript, BtcTransaction.SigHash.ALL, false);
         // Sign by federator 0
-        BtcECKey.ECDSASignature sig0 = fedBtcECKeys.get(0).sign(sighash);
+        BtcECKey.ECDSASignature sig0 = REGTEST_FEDERATION_PRIVATE_KEYS.get(0).sign(sighash);
         TransactionSignature txSig0 = new TransactionSignature(sig0, BtcTransaction.SigHash.ALL, false);
         int sigIndex0 = scriptSig.getSigInsertionIndex(sighash, federation.getBtcPublicKeys().get(0));
         scriptSig = ScriptBuilder.updateScriptWithSignature(scriptSig, txSig0.encodeToBitcoin(), sigIndex0, 1, 1);
         // Sign by federator 1
-        BtcECKey.ECDSASignature sig1 = fedBtcECKeys.get(1).sign(sighash);
+        BtcECKey.ECDSASignature sig1 = REGTEST_FEDERATION_PRIVATE_KEYS.get(1).sign(sighash);
         TransactionSignature txSig1 = new TransactionSignature(sig1, BtcTransaction.SigHash.ALL, false);
         int sigIndex1 = scriptSig.getSigInsertionIndex(sighash, federation.getBtcPublicKeys().get(1));
         scriptSig = ScriptBuilder.updateScriptWithSignature(scriptSig, txSig1.encodeToBitcoin(), sigIndex1, 1, 1);
diff --git a/rskj-core/src/test/java/co/rsk/peg/BridgeUtilsTest.java b/rskj-core/src/test/java/co/rsk/peg/BridgeUtilsTest.java
index f20a6bba5a7..87dbc3173bf 100644
--- a/rskj-core/src/test/java/co/rsk/peg/BridgeUtilsTest.java
+++ b/rskj-core/src/test/java/co/rsk/peg/BridgeUtilsTest.java
@@ -26,7 +26,6 @@
 import co.rsk.bitcoinj.wallet.RedeemData;
 import co.rsk.bitcoinj.wallet.Wallet;
 import co.rsk.blockchain.utils.BlockGenerator;
-import co.rsk.peg.bitcoin.BitcoinTestUtils;
 import co.rsk.peg.bitcoin.FlyoverRedeemScriptBuilderImpl;
 import co.rsk.peg.constants.BridgeConstants;
 import co.rsk.peg.constants.BridgeMainNetConstants;
@@ -64,6 +63,7 @@
 import java.util.Collections;
 import java.util.List;
 
+import static co.rsk.peg.federation.FederationTestUtils.REGTEST_FEDERATION_PRIVATE_KEYS;
 import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.Mockito.*;
 
@@ -75,7 +75,6 @@ class BridgeUtilsTest {
     private static final BigInteger GAS_LIMIT = new BigInteger("1000");
     private static final String DATA = "80af2871";
     private static final byte[] MISSING_SIGNATURE = new byte[0];
-    private static final List<BtcECKey> fedBtcECKeys = BitcoinTestUtils.getBtcEcKeysFromSeeds(new String[]{"fa01", "fa02", "fa03"}, true);
 
     private Constants constants;
     private ActivationConfig activationConfig;
@@ -86,10 +85,10 @@ class BridgeUtilsTest {
 
     @BeforeEach
     void setupConfig() {
-        constants = Constants.regtestWithFederation(fedBtcECKeys);
+        constants = Constants.regtest();
         activationConfig = spy(ActivationConfigsForTest.all());
         activations = mock(ActivationConfig.ForBlock.class);
-        bridgeConstantsRegtest = new BridgeRegTestConstants(fedBtcECKeys);
+        bridgeConstantsRegtest = new BridgeRegTestConstants();
         bridgeConstantsMainnet = BridgeMainNetConstants.getInstance();
         networkParameters = bridgeConstantsRegtest.getBtcParams();
     }
@@ -318,19 +317,19 @@ void countMissingSignatures_several_inputs_one_missing_signature() {
     @Test
     void isFreeBridgeTxTrue() {
         activationConfig = ActivationConfigsForTest.bridgeUnitTest();
-        isFreeBridgeTx(true, PrecompiledContracts.BRIDGE_ADDR, fedBtcECKeys.get(0).getPrivKeyBytes());
+        isFreeBridgeTx(true, PrecompiledContracts.BRIDGE_ADDR, REGTEST_FEDERATION_PRIVATE_KEYS.get(0).getPrivKeyBytes());
     }
 
     @Test
     void isFreeBridgeTxOtherContract() {
         activationConfig = ActivationConfigsForTest.bridgeUnitTest();
-        isFreeBridgeTx(false, PrecompiledContracts.IDENTITY_ADDR, fedBtcECKeys.get(0).getPrivKeyBytes());
+        isFreeBridgeTx(false, PrecompiledContracts.IDENTITY_ADDR, REGTEST_FEDERATION_PRIVATE_KEYS.get(0).getPrivKeyBytes());
     }
 
     @Test
     void isFreeBridgeTxFreeTxDisabled() {
         activationConfig = ActivationConfigsForTest.only(ConsensusRule.ARE_BRIDGE_TXS_PAID);
-        isFreeBridgeTx(false, PrecompiledContracts.BRIDGE_ADDR, fedBtcECKeys.get(0).getPrivKeyBytes());
+        isFreeBridgeTx(false, PrecompiledContracts.BRIDGE_ADDR, REGTEST_FEDERATION_PRIVATE_KEYS.get(0).getPrivKeyBytes());
     }
 
     @Test
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 66c4f919a2b..86754d6a103 100644
--- a/rskj-core/src/test/java/co/rsk/peg/PegUtilsLegacyTest.java
+++ b/rskj-core/src/test/java/co/rsk/peg/PegUtilsLegacyTest.java
@@ -29,7 +29,6 @@
 
 class PegUtilsLegacyTest {
     private final Instant creationTime = Instant.ofEpochMilli(1000L);
-    private final List<BtcECKey> fedBtcECKeys = BitcoinTestUtils.getBtcEcKeysFromSeeds(new String[]{"fa01", "fa02", "fa03"}, true);
     private ActivationConfig.ForBlock activations;
     private BridgeConstants bridgeConstantsRegtest;
     private BridgeConstants bridgeConstantsMainnet;
@@ -49,7 +48,7 @@ void setupConfig() {
     void testIsValidPegInTx() {
         // Peg-in is for the genesis federation ATM
         Context btcContext = new Context(networkParameters);
-        Federation federation = getErpFederationWithPrivKeys(networkParameters, fedBtcECKeys);
+        Federation federation = getErpFederationWithPrivKeys(networkParameters, REGTEST_FEDERATION_PRIVATE_KEYS);
         Wallet wallet = new BridgeBtcWallet(btcContext, Collections.singletonList(federation));
         Address federationAddress = federation.getAddress();
         wallet.addWatchedAddress(federationAddress, federation.getCreationTime().toEpochMilli());
@@ -73,7 +72,7 @@ void testIsValidPegInTx() {
             new TransactionOutPoint(networkParameters, 0, Sha256Hash.ZERO_HASH)
         );
         tx2.addInput(txIn);
-        signWithNecessaryKeys(federation, fedBtcECKeys, txIn, tx2);
+        signWithNecessaryKeys(federation, REGTEST_FEDERATION_PRIVATE_KEYS, txIn, tx2);
         assertFalse(isValidPegInTx(tx2, federation, wallet, bridgeConstantsRegtest, activations));
 
         // Tx sending 1 btc to the federation, is a peg-in tx
@@ -93,7 +92,7 @@ void testIsValidPegInTx() {
     void testIsValidPegInTx_less_than_minimum_not_pegin_after_iris() {
         // Tx sending less than the minimum allowed, not a peg-in tx
         Context btcContext = new Context(networkParameters);
-        Federation federation = getErpFederationWithPrivKeys(networkParameters, fedBtcECKeys);
+        Federation federation = getErpFederationWithPrivKeys(networkParameters, REGTEST_FEDERATION_PRIVATE_KEYS);
 
         when(activations.isActive(ConsensusRule.RSKIP219)).thenReturn(true);
         Coin minimumPegInValueAfterIris = bridgeConstantsRegtest.getMinimumPeginTxValue(activations);
@@ -112,7 +111,7 @@ void testIsValidPegInTx_spending_from_federation_is_pegout_after_iris() {
         // Tx sending 1 btc to the federation, but also spending from the federation address,
         // the typical peg-out tx, not a peg-in tx.
         Context btcContext = new Context(networkParameters);
-        Federation federation = getErpFederationWithPrivKeys(networkParameters, fedBtcECKeys);
+        Federation federation = getErpFederationWithPrivKeys(networkParameters, REGTEST_FEDERATION_PRIVATE_KEYS);
 
         when(activations.isActive(ConsensusRule.RSKIP219)).thenReturn(true);
 
@@ -125,7 +124,7 @@ void testIsValidPegInTx_spending_from_federation_is_pegout_after_iris() {
             new TransactionOutPoint(networkParameters, 0, Sha256Hash.ZERO_HASH)
         );
         tx.addInput(txIn);
-        signWithNecessaryKeys(federation, fedBtcECKeys, txIn, tx);
+        signWithNecessaryKeys(federation, REGTEST_FEDERATION_PRIVATE_KEYS, txIn, tx);
 
         Wallet federationWallet = new BridgeBtcWallet(btcContext, Collections.singletonList(federation));
         assertFalse(isValidPegInTx(tx, federation, federationWallet, bridgeConstantsRegtest, activations));
@@ -135,7 +134,7 @@ void testIsValidPegInTx_spending_from_federation_is_pegout_after_iris() {
     void testIsValidPegInTx_sending_50_btc_after_iris() {
         // Tx sending 50 btc to the federation, is a peg-in tx
         Context btcContext = new Context(bridgeConstantsMainnet.getBtcParams());
-        Federation federation = getErpFederationWithPrivKeys(networkParameters, fedBtcECKeys);
+        Federation federation = getErpFederationWithPrivKeys(networkParameters, REGTEST_FEDERATION_PRIVATE_KEYS);
 
         when(activations.isActive(ConsensusRule.RSKIP219)).thenReturn(true);
 
@@ -151,7 +150,7 @@ void testIsValidPegInTx_sending_50_btc_after_iris() {
     void testIsValidPegInTx_value_between_old_and_new_before_iris() {
         // Tx sending btc between old and new value, it is not a peg-in before iris
         Context btcContext = new Context(bridgeConstantsMainnet.getBtcParams());
-        Federation federation = getErpFederationWithPrivKeys(networkParameters, fedBtcECKeys);
+        Federation federation = getErpFederationWithPrivKeys(networkParameters, REGTEST_FEDERATION_PRIVATE_KEYS);
 
         when(activations.isActive(ConsensusRule.RSKIP219)).thenReturn(false);
 
@@ -175,7 +174,7 @@ void testIsValidPegInTx_value_between_old_and_new_before_iris() {
     void testIsValidPegInTx_value_between_old_and_new_after_iris() {
         // Tx sending btc between old and new value, it is a peg-in after iris
         Context btcContext = new Context(bridgeConstantsMainnet.getBtcParams());
-        Federation federation = getErpFederationWithPrivKeys(networkParameters, fedBtcECKeys);
+        Federation federation = getErpFederationWithPrivKeys(networkParameters, REGTEST_FEDERATION_PRIVATE_KEYS);
         when(activations.isActive(ConsensusRule.RSKIP219)).thenReturn(true);
 
         BtcTransaction tx = new BtcTransaction(bridgeConstantsMainnet.getBtcParams());
@@ -481,7 +480,7 @@ void testIsValidPegInTx_hasChangeUtxoFromFlyoverFederation_beforeRskip201_isPegi
         Context btcContext = new Context(bridgeConstantsMainnet.getBtcParams());
         when(activations.isActive(ConsensusRule.RSKIP201)).thenReturn(false);
 
-        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, fedBtcECKeys);
+        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, REGTEST_FEDERATION_PRIVATE_KEYS);
 
         Keccak256 flyoverDerivationHash = RskTestUtils.createHash(1);
         Script flyoverRedeemScript = FlyoverRedeemScriptBuilderImpl.builder().of(
@@ -505,7 +504,7 @@ void testIsValidPegInTx_hasChangeUtxoFromFlyoverFederation_afterRskip201_notPegi
         Context btcContext = new Context(bridgeConstantsMainnet.getBtcParams());
         when(activations.isActive(ConsensusRule.RSKIP201)).thenReturn(true);
 
-        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, fedBtcECKeys);
+        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, REGTEST_FEDERATION_PRIVATE_KEYS);
 
         Keccak256 flyoverDerivationHash = RskTestUtils.createHash(1);
         Script flyoverRedeemScript = FlyoverRedeemScriptBuilderImpl.builder().of(
@@ -531,7 +530,7 @@ void testIsValidPegInTx_hasChangeUtxoFromFlyoverErpFederation_beforeRskip201_isP
 
         Context btcContext = new Context(networkParameters);
 
-        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, fedBtcECKeys);
+        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, REGTEST_FEDERATION_PRIVATE_KEYS);
         FederationArgs federationArgs = activeFederation.getArgs();
 
         List<BtcECKey> erpPubKeys = Arrays.asList(
@@ -571,7 +570,7 @@ void testIsValidPegInTx_hasChangeUtxoFromFlyoverErpFederation_afterRskip201_notP
         Context btcContext = new Context(networkParameters);
         when(activations.isActive(ConsensusRule.RSKIP201)).thenReturn(true);
 
-        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, fedBtcECKeys);
+        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, REGTEST_FEDERATION_PRIVATE_KEYS);
         List<BtcECKey> erpFederationKeys = Arrays.asList(
             BtcECKey.fromPrivate(Hex.decode("fa01")),
             BtcECKey.fromPrivate(Hex.decode("fa02"))
@@ -623,7 +622,7 @@ void testIsValidPegInTx_hasChangeUtxoFromErpFederation_beforeRskip201_isPegin()
         Context btcContext = new Context(networkParameters);
         when(activations.isActive(ConsensusRule.RSKIP201)).thenReturn(false);
 
-        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, fedBtcECKeys);
+        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, REGTEST_FEDERATION_PRIVATE_KEYS);
         List<BtcECKey> erpFederationKeys = Arrays.asList(
             BtcECKey.fromPrivate(Hex.decode("fa01")),
             BtcECKey.fromPrivate(Hex.decode("fa02"))
@@ -668,7 +667,7 @@ void testIsValidPegInTx_hasChangeUtxoFromErpFederation_afterRskip201_notPegin()
         Context btcContext = new Context(networkParameters);
         when(activations.isActive(ConsensusRule.RSKIP201)).thenReturn(true);
 
-        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, fedBtcECKeys);
+        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, REGTEST_FEDERATION_PRIVATE_KEYS);
         List<BtcECKey> erpFederationKeys = Arrays.asList(
             BtcECKey.fromPrivate(Hex.decode("fa01")),
             BtcECKey.fromPrivate(Hex.decode("fa02"))
@@ -713,7 +712,7 @@ void testIsValidPegInTx_hasChangeUtxoFromErpFederation_afterRskip201_notPegin()
     @Test
     void testIsValidPegInTx_hasChangeUtxoFromFlyoverRetiredFederation_beforeRskip201_isPegin() {
         Context btcContext = new Context(networkParameters);
-        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, fedBtcECKeys);
+        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, REGTEST_FEDERATION_PRIVATE_KEYS);
         when(activations.isActive(ConsensusRule.RSKIP201)).thenReturn(false);
 
         List<BtcECKey> retiredFederationKeys = Arrays.asList(
@@ -765,7 +764,7 @@ void testIsValidPegInTx_hasChangeUtxoFromFlyoverRetiredFederation_beforeRskip201
     @Test
     void testIsValidPegInTx_hasChangeUtxoFromFlyoverRetiredFederation_afterRskip201_notPegin() {
         Context btcContext = new Context(networkParameters);
-        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, fedBtcECKeys);
+        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, REGTEST_FEDERATION_PRIVATE_KEYS);
         when(activations.isActive(ConsensusRule.RSKIP201)).thenReturn(true);
 
         List<BtcECKey> retiredFederationKeys = Arrays.asList(
@@ -817,7 +816,7 @@ void testIsValidPegInTx_hasChangeUtxoFromFlyoverRetiredFederation_afterRskip201_
     @Test
     void testIsValidPegInTx_hasChangeUtxoFromFlyoverErpRetiredFederation_beforeRskip201_isPegin() {
         Context btcContext = new Context(networkParameters);
-        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, fedBtcECKeys);
+        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, REGTEST_FEDERATION_PRIVATE_KEYS);
         when(activations.isActive(ConsensusRule.RSKIP201)).thenReturn(false);
 
         List<BtcECKey> retiredFederationKeys = Arrays.asList(
@@ -872,7 +871,7 @@ void testIsValidPegInTx_hasChangeUtxoFromFlyoverErpRetiredFederation_beforeRskip
     @Test
     void testIsValidPegInTx_hasChangeUtxoFromFlyoverErpRetiredFederation_afterRskip201_notPegin() {
         Context btcContext = new Context(networkParameters);
-        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, fedBtcECKeys);
+        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, REGTEST_FEDERATION_PRIVATE_KEYS);
         when(activations.isActive(ConsensusRule.RSKIP201)).thenReturn(true);
 
         List<BtcECKey> retiredFederationKeys = Arrays.asList(
@@ -927,7 +926,7 @@ void testIsValidPegInTx_hasChangeUtxoFromFlyoverErpRetiredFederation_afterRskip2
     @Test
     void testIsValidPegInTx_hasChangeUtxoFromErpRetiredFederation_beforeRskip201_isPegin() {
         Context btcContext = new Context(networkParameters);
-        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, fedBtcECKeys);
+        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, REGTEST_FEDERATION_PRIVATE_KEYS);
 
         List<BtcECKey> retiredFederationKeys = Arrays.asList(
             BtcECKey.fromPrivate(Hex.decode("fa01")),
@@ -975,7 +974,7 @@ void testIsValidPegInTx_hasChangeUtxoFromErpRetiredFederation_beforeRskip201_isP
     @Test
     void testIsValidPegInTx_hasChangeUtxoFromErpRetiredFederation_afterRskip201_notPegin() {
         Context btcContext = new Context(networkParameters);
-        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, fedBtcECKeys);
+        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, REGTEST_FEDERATION_PRIVATE_KEYS);
         when(activations.isActive(ConsensusRule.RSKIP201)).thenReturn(true);
 
         List<BtcECKey> retiredFederationKeys = Arrays.asList(
@@ -1024,7 +1023,7 @@ void testIsValidPegInTx_hasChangeUtxoFromErpRetiredFederation_afterRskip201_notP
     @Test
     void testIsValidPegInTx_has_multiple_utxos_below_minimum_but_total_amount_is_ok_before_RSKIP293() {
         Context btcContext = new Context(bridgeConstantsMainnet.getBtcParams());
-        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, fedBtcECKeys);
+        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, REGTEST_FEDERATION_PRIVATE_KEYS);
         when(activations.isActive(ConsensusRule.RSKIP201)).thenReturn(true);
         when(activations.isActive(ConsensusRule.RSKIP293)).thenReturn(false);
 
@@ -1051,7 +1050,7 @@ void testIsValidPegInTx_has_multiple_utxos_below_minimum_but_total_amount_is_ok_
     @Test
     void testIsValidPegInTx_has_utxos_below_minimum_and_total_amount_as_well_before_RSKIP293() {
         Context btcContext = new Context(bridgeConstantsMainnet.getBtcParams());
-        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, fedBtcECKeys);
+        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, REGTEST_FEDERATION_PRIVATE_KEYS);
         when(activations.isActive(ConsensusRule.RSKIP201)).thenReturn(true);
         when(activations.isActive(ConsensusRule.RSKIP293)).thenReturn(false);
 
@@ -1078,7 +1077,7 @@ void testIsValidPegInTx_has_utxos_below_minimum_and_total_amount_as_well_before_
     @Test
     void testIsValidPegInTx_has_utxos_below_minimum_after_RSKIP293() {
         Context btcContext = new Context(bridgeConstantsMainnet.getBtcParams());
-        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, fedBtcECKeys);
+        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, REGTEST_FEDERATION_PRIVATE_KEYS);
         when(activations.isActive(ConsensusRule.RSKIP201)).thenReturn(true);
         when(activations.isActive(ConsensusRule.RSKIP293)).thenReturn(true);
 
@@ -1109,7 +1108,7 @@ void testIsValidPegInTx_has_utxos_below_minimum_after_RSKIP293() {
     @Test
     void testIsValidPegInTx_utxo_equal_to_minimum_after_RSKIP293() {
         Context btcContext = new Context(bridgeConstantsMainnet.getBtcParams());
-        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, fedBtcECKeys);
+        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, REGTEST_FEDERATION_PRIVATE_KEYS);
         when(activations.isActive(ConsensusRule.RSKIP201)).thenReturn(true);
         when(activations.isActive(ConsensusRule.RSKIP293)).thenReturn(true);
 
@@ -1132,7 +1131,7 @@ void testIsValidPegInTx_utxo_equal_to_minimum_after_RSKIP293() {
 
     @Test
     void testIsValidPegInTx_p2shErpScript_sends_funds_to_federation_address_after_RSKIP353() {
-        Federation federation = getErpFederationWithPrivKeys(networkParameters, fedBtcECKeys);
+        Federation federation = getErpFederationWithPrivKeys(networkParameters, REGTEST_FEDERATION_PRIVATE_KEYS);
         Address activeFederationAddress = federation.getAddress();
         testIsValidPegInTx_fromP2shErpScriptSender(
             true,
@@ -1155,7 +1154,7 @@ void testIsValidPegInTx_p2shErpScript_sends_funds_to_random_address_after_RSKIP3
 
     @Test
     void testIsValidPegInTx_flyoverpP2shErpScript_sends_funds_to_federation_address_after_RSKIP353() {
-        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, fedBtcECKeys);
+        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, REGTEST_FEDERATION_PRIVATE_KEYS);
         Address activeFederationAddress = activeFederation.getAddress();
         testIsValidPegInTx_fromP2shErpScriptSender(
             true,
@@ -1187,7 +1186,7 @@ private void testIsValidPegInTx_fromP2shErpScriptSender(
         when(activations.isActive(ConsensusRule.RSKIP353)).thenReturn(isRskip353Active);
 
         Context btcContext = new Context(networkParameters);
-        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, fedBtcECKeys);
+        Federation activeFederation = getErpFederationWithPrivKeys(networkParameters, REGTEST_FEDERATION_PRIVATE_KEYS);
         FederationArgs activeFederationArgs = activeFederation.getArgs();
 
         List<BtcECKey> emergencyKeys = PegTestUtils.createRandomBtcECKeys(3);
@@ -1795,7 +1794,7 @@ void testIsMigrationTx() {
 
     @Test
     void testIsPegOutTx() {
-        Federation federation = getFederationWithPrivateKeys(fedBtcECKeys);
+        Federation federation = getFederationWithPrivateKeys(REGTEST_FEDERATION_PRIVATE_KEYS);
 
         List<BtcECKey> activeFederationKeys = Stream.of(
             BtcECKey.fromPrivate(Hex.decode("fa01")),
@@ -1821,7 +1820,7 @@ void testIsPegOutTx() {
             new TransactionOutPoint(networkParameters, 0, Sha256Hash.ZERO_HASH)
         );
         pegOutTx1.addInput(pegOutInput1);
-        signWithNecessaryKeys(federation, fedBtcECKeys, pegOutInput1, pegOutTx1);
+        signWithNecessaryKeys(federation, REGTEST_FEDERATION_PRIVATE_KEYS, pegOutInput1, pegOutTx1);
 
         assertTrue(isPegOutTx(pegOutTx1, Collections.singletonList(federation), activations));
         assertTrue(isPegOutTx(pegOutTx1, Arrays.asList(federation, federation2), activations));
@@ -1849,7 +1848,7 @@ void testIsPegOutTx_fromFlyoverFederation() {
             args
         );
 
-        Federation standardFederation = getErpFederationWithPrivKeys(networkParameters, fedBtcECKeys);
+        Federation standardFederation = getErpFederationWithPrivKeys(networkParameters, REGTEST_FEDERATION_PRIVATE_KEYS);
 
         // Create a tx from the fast bridge fed to a random address
         Address randomAddress = PegTestUtils.createRandomP2PKHBtcAddress(networkParameters);
@@ -1915,7 +1914,7 @@ void testIsPegOutTx_fromErpFederation() {
         erpFederationPublicKeys.sort(BtcECKey.PUBKEY_COMPARATOR);
         ErpFederation nonStandardErpFederation = FederationFactory.buildNonStandardErpFederation(federationArgs, erpFederationPublicKeys, 500L, activations);
 
-        Federation standardFederation = getErpFederationWithPrivKeys(networkParameters, fedBtcECKeys);
+        Federation standardFederation = getErpFederationWithPrivKeys(networkParameters, REGTEST_FEDERATION_PRIVATE_KEYS);
 
         // Create a tx from the erp fed to a random address
         Address randomAddress = PegTestUtils.createRandomP2PKHBtcAddress(networkParameters);
@@ -1981,7 +1980,7 @@ void testIsPegOutTx_fromFlyoverErpFederation() {
 
         ErpFederation nonStandardErpFederation = FederationFactory.buildNonStandardErpFederation(federationArgs, erpFederationPublicKeys, 500L, activations);
 
-        Federation standardFederation = getErpFederationWithPrivKeys(networkParameters, fedBtcECKeys);
+        Federation standardFederation = getErpFederationWithPrivKeys(networkParameters, REGTEST_FEDERATION_PRIVATE_KEYS);
 
         // Create a tx from the fast bridge erp fed to a random address
         Address randomAddress = PegTestUtils.createRandomP2PKHBtcAddress(networkParameters);
@@ -2027,7 +2026,7 @@ void testIsPegOutTx_fromFlyoverErpFederation() {
 
     @Test
     void testIsPegOutTx_noRedeemScript() {
-        Federation federation = getErpFederationWithPrivKeys(networkParameters, fedBtcECKeys);
+        Federation federation = getErpFederationWithPrivKeys(networkParameters, REGTEST_FEDERATION_PRIVATE_KEYS);
         Address randomAddress = PegTestUtils.createRandomP2PKHBtcAddress(bridgeConstantsMainnet.getBtcParams());
 
         BtcTransaction pegOutTx1 = new BtcTransaction(bridgeConstantsMainnet.getBtcParams());
@@ -2045,7 +2044,7 @@ void testIsPegOutTx_noRedeemScript() {
 
     @Test
     void testIsPegOutTx_invalidRedeemScript() {
-        Federation federation = getErpFederationWithPrivKeys(networkParameters, fedBtcECKeys);
+        Federation federation = getErpFederationWithPrivKeys(networkParameters, REGTEST_FEDERATION_PRIVATE_KEYS);
         Address randomAddress = PegTestUtils.createRandomP2PKHBtcAddress(bridgeConstantsMainnet.getBtcParams());
         Script invalidRedeemScript = ScriptBuilder.createRedeemScript(2, Arrays.asList(new BtcECKey(), new BtcECKey()));
 
@@ -2240,7 +2239,7 @@ void testIsAnyUTXOAmountBelowMinimum_has_utxos_below_minimum() {
 
     @Test
     void scriptCorrectlySpends_fromAFederation_ok() {
-        Federation federation = getErpFederationWithPrivKeys(networkParameters, fedBtcECKeys);
+        Federation federation = getErpFederationWithPrivKeys(networkParameters, REGTEST_FEDERATION_PRIVATE_KEYS);
         Address destinationAddress = PegTestUtils.createRandomP2PKHBtcAddress(networkParameters);
 
         BtcTransaction tx = new BtcTransaction(networkParameters);
@@ -2252,14 +2251,14 @@ void scriptCorrectlySpends_fromAFederation_ok() {
             new TransactionOutPoint(networkParameters, 0, Sha256Hash.ZERO_HASH)
         );
         tx.addInput(txIn);
-        signWithNecessaryKeys(federation, fedBtcECKeys, txIn, tx);
+        signWithNecessaryKeys(federation, REGTEST_FEDERATION_PRIVATE_KEYS, txIn, tx);
 
         assertTrue(scriptCorrectlySpendsTx(tx, 0, federation.getP2SHScript()));
     }
 
     @Test
     void scriptCorrectlySpends_invalidScript() {
-        Federation federation = getErpFederationWithPrivKeys(networkParameters, fedBtcECKeys);
+        Federation federation = getErpFederationWithPrivKeys(networkParameters, REGTEST_FEDERATION_PRIVATE_KEYS);
         Address destinationAddress = PegTestUtils.createRandomP2PKHBtcAddress(networkParameters);
 
         BtcTransaction tx = new BtcTransaction(networkParameters);
@@ -2271,7 +2270,7 @@ void scriptCorrectlySpends_invalidScript() {
             new TransactionOutPoint(networkParameters, 0, Sha256Hash.ZERO_HASH)
         );
         tx.addInput(txIn);
-        signWithNecessaryKeys(federation, fedBtcECKeys, txIn, tx);
+        signWithNecessaryKeys(federation, REGTEST_FEDERATION_PRIVATE_KEYS, txIn, tx);
 
         // Add script op codes to the tx input script sig to make it invalid
         ScriptBuilder scriptBuilder = new ScriptBuilder(tx.getInput(0).getScriptSig());
diff --git a/rskj-core/src/test/java/co/rsk/peg/RskForksBridgeTest.java b/rskj-core/src/test/java/co/rsk/peg/RskForksBridgeTest.java
index eddf087aff2..7102b4d4d68 100644
--- a/rskj-core/src/test/java/co/rsk/peg/RskForksBridgeTest.java
+++ b/rskj-core/src/test/java/co/rsk/peg/RskForksBridgeTest.java
@@ -19,7 +19,6 @@
 package co.rsk.peg;
 
 import co.rsk.bitcoinj.core.AddressFormatException;
-import co.rsk.bitcoinj.core.BtcECKey;
 import co.rsk.bitcoinj.core.Coin;
 import co.rsk.config.TestSystemProperties;
 import co.rsk.core.RskAddress;
@@ -49,12 +48,9 @@
 import java.util.Arrays;
 import java.util.List;
 
+import static co.rsk.peg.federation.FederationTestUtils.REGTEST_FEDERATION_PRIVATE_KEYS;
+
 class RskForksBridgeTest {
-    private static final List<BtcECKey> REGTEST_FEDERATION_PRIVATE_KEYS = Arrays.asList(
-        BtcECKey.fromPrivate(Hex.decode("45c5b07fc1a6f58892615b7c31dca6c96db58c4bbc538a6b8a22999aaa860c32")),
-        BtcECKey.fromPrivate(Hex.decode("505334c7745df2fc61486dffb900784505776a898377172ffa77384892749179")),
-        BtcECKey.fromPrivate(Hex.decode("bed0af2ce8aa8cb2bc3f9416c9d518fdee15d1ff15b8ded28376fcb23db6db69"))
-    );
     private static final ECKey fedECPrivateKey = ECKey.fromPrivate(
             REGTEST_FEDERATION_PRIVATE_KEYS.get(0).getPrivKey()
     );
diff --git a/rskj-core/src/test/java/co/rsk/peg/federation/FederationTestUtils.java b/rskj-core/src/test/java/co/rsk/peg/federation/FederationTestUtils.java
index 3024cb8ddb1..a02ae7712cb 100644
--- a/rskj-core/src/test/java/co/rsk/peg/federation/FederationTestUtils.java
+++ b/rskj-core/src/test/java/co/rsk/peg/federation/FederationTestUtils.java
@@ -34,10 +34,17 @@
 import java.util.List;
 import java.util.stream.Collectors;
 
+import org.bouncycastle.util.encoders.Hex;
 import org.ethereum.crypto.ECKey;
 
 public final class FederationTestUtils {
 
+    public static final List<BtcECKey> REGTEST_FEDERATION_PRIVATE_KEYS = Arrays.asList(
+        BtcECKey.fromPrivate(Hex.decode("45c5b07fc1a6f58892615b7c31dca6c96db58c4bbc538a6b8a22999aaa860c32")),
+        BtcECKey.fromPrivate(Hex.decode("505334c7745df2fc61486dffb900784505776a898377172ffa77384892749179")),
+        BtcECKey.fromPrivate(Hex.decode("bed0af2ce8aa8cb2bc3f9416c9d518fdee15d1ff15b8ded28376fcb23db6db69"))
+    );
+
     private FederationTestUtils() {
     }
 


Reviews:
user: login: nathanieliov
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-03-05T18:24:06Z
user: login: nathanieliov
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-05T18:25:58Z
user: login: julianlen
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-05T21:26:15Z
user: login: nathanieliov
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-03-06T12:56:50Z
user: login: julia-zack
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-06T18:28:32Z
user: login: julia-zack
body: left a comment but lgtm :)
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-03-06T18:31:03Z
user: login: julianlen
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-06T18:42:23Z
user: login: julia-zack
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-06T18:49:17Z
user: login: marcos-iov
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-06T19:13:03Z
user: login: julianlen
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-07T14:55:45Z
user: login: marcos-iov
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-03-07T15:12:58Z

Review comments:
diff_hunk: @@ -57,11 +56,14 @@
 
 class BridgeSupportAddSignatureTest {
     private static final RskAddress bridgeAddress = PrecompiledContracts.BRIDGE_ADDR;
-    private static final List<BtcECKey> federationECKeys = BitcoinTestUtils.getBtcEcKeysFromSeeds(
-        new String[]{"fa91", "fa92", "fa93"}, true
+    private static final List<BtcECKey> REGTEST_FEDERATION_PRIVATE_KEYS = Arrays.asList(
+        BtcECKey.fromPrivate(Hex.decode("45c5b07fc1a6f58892615b7c31dca6c96db58c4bbc538a6b8a22999aaa860c32")),
path: rskj-core/src/test/java/co/rsk/peg/BridgeSupportAddSignatureTest.java
user: login: nathanieliov
body: You should get these private keys from the `FederationTestUtils`
created_at: 2025-03-05T18:25:58Z
author_association: CONTRIBUTOR
diff_hunk: @@ -57,11 +56,14 @@
 
 class BridgeSupportAddSignatureTest {
     private static final RskAddress bridgeAddress = PrecompiledContracts.BRIDGE_ADDR;
-    private static final List<BtcECKey> federationECKeys = BitcoinTestUtils.getBtcEcKeysFromSeeds(
-        new String[]{"fa91", "fa92", "fa93"}, true
+    private static final List<BtcECKey> REGTEST_FEDERATION_PRIVATE_KEYS = Arrays.asList(
+        BtcECKey.fromPrivate(Hex.decode("45c5b07fc1a6f58892615b7c31dca6c96db58c4bbc538a6b8a22999aaa860c32")),
path: rskj-core/src/test/java/co/rsk/peg/BridgeSupportAddSignatureTest.java
user: login: julianlen
body: Yep, and found some others tests where I didn't delete the constant
created_at: 2025-03-05T21:26:14Z
author_association: CONTRIBUTOR
diff_hunk: @@ -57,11 +57,9 @@
 
 class BridgeSupportAddSignatureTest {
     private static final RskAddress bridgeAddress = PrecompiledContracts.BRIDGE_ADDR;
-    private static final List<BtcECKey> federationECKeys = BitcoinTestUtils.getBtcEcKeysFromSeeds(
-        new String[]{"fa91", "fa92", "fa93"}, true
-    );
+    private static final List<BtcECKey> REGTEST_FEDERATION_PUBLIC_KEYS = REGTEST_FEDERATION_PRIVATE_KEYS.stream().map(BtcECKey::getPubKey).map(BtcECKey::fromPublicOnly).toList();
path: rskj-core/src/test/java/co/rsk/peg/BridgeSupportAddSignatureTest.java
user: login: julia-zack
body: would it make sense to have this in `FederationTestUtils` too?
created_at: 2025-03-06T18:28:32Z
author_association: CONTRIBUTOR
diff_hunk: @@ -57,11 +57,9 @@
 
 class BridgeSupportAddSignatureTest {
     private static final RskAddress bridgeAddress = PrecompiledContracts.BRIDGE_ADDR;
-    private static final List<BtcECKey> federationECKeys = BitcoinTestUtils.getBtcEcKeysFromSeeds(
-        new String[]{"fa91", "fa92", "fa93"}, true
-    );
+    private static final List<BtcECKey> REGTEST_FEDERATION_PUBLIC_KEYS = REGTEST_FEDERATION_PRIVATE_KEYS.stream().map(BtcECKey::getPubKey).map(BtcECKey::fromPublicOnly).toList();
path: rskj-core/src/test/java/co/rsk/peg/BridgeSupportAddSignatureTest.java
user: login: julianlen
body: Even when used only in one place?
created_at: 2025-03-06T18:42:23Z
author_association: CONTRIBUTOR
diff_hunk: @@ -57,11 +57,9 @@
 
 class BridgeSupportAddSignatureTest {
     private static final RskAddress bridgeAddress = PrecompiledContracts.BRIDGE_ADDR;
-    private static final List<BtcECKey> federationECKeys = BitcoinTestUtils.getBtcEcKeysFromSeeds(
-        new String[]{"fa91", "fa92", "fa93"}, true
-    );
+    private static final List<BtcECKey> REGTEST_FEDERATION_PUBLIC_KEYS = REGTEST_FEDERATION_PRIVATE_KEYS.stream().map(BtcECKey::getPubKey).map(BtcECKey::fromPublicOnly).toList();
path: rskj-core/src/test/java/co/rsk/peg/BridgeSupportAddSignatureTest.java
user: login: julia-zack
body: nope, in that case it does not make sense :)
created_at: 2025-03-06T18:49:17Z
author_association: CONTRIBUTOR
diff_hunk: @@ -57,11 +57,9 @@
 
 class BridgeSupportAddSignatureTest {
     private static final RskAddress bridgeAddress = PrecompiledContracts.BRIDGE_ADDR;
-    private static final List<BtcECKey> federationECKeys = BitcoinTestUtils.getBtcEcKeysFromSeeds(
-        new String[]{"fa91", "fa92", "fa93"}, true
-    );
+    private static final List<BtcECKey> REGTEST_FEDERATION_PUBLIC_KEYS = REGTEST_FEDERATION_PRIVATE_KEYS.stream().map(BtcECKey::getPubKey).map(BtcECKey::fromPublicOnly).toList();
path: rskj-core/src/test/java/co/rsk/peg/BridgeSupportAddSignatureTest.java
user: login: marcos-iov
body: Can't you just call BridgeRegTestConstants.getGenesisFederationPublicKeys?
created_at: 2025-03-06T19:11:44Z
author_association: CONTRIBUTOR
diff_hunk: @@ -57,11 +57,9 @@
 
 class BridgeSupportAddSignatureTest {
     private static final RskAddress bridgeAddress = PrecompiledContracts.BRIDGE_ADDR;
-    private static final List<BtcECKey> federationECKeys = BitcoinTestUtils.getBtcEcKeysFromSeeds(
-        new String[]{"fa91", "fa92", "fa93"}, true
-    );
+    private static final List<BtcECKey> REGTEST_FEDERATION_PUBLIC_KEYS = REGTEST_FEDERATION_PRIVATE_KEYS.stream().map(BtcECKey::getPubKey).map(BtcECKey::fromPublicOnly).toList();
path: rskj-core/src/test/java/co/rsk/peg/BridgeSupportAddSignatureTest.java
user: login: julianlen
body: I was trying to minimize the parts of the test code using constants. I modified that line so it uses one constant (REGTEST_FEDERATION_PRIVATE_KEYS) instead of REGTEST_FEDERATION_PRIVATE_KEYS and getGenesisFederationPublicKeys. I also wanted to show the relation between those keys.

But if it adds boiler code I can simplify it with Federationconstants.getGenesisFederationPublicKeys()

created_at: 2025-03-07T14:55:45Z
author_association: CONTRIBUTOR

PR comments:
user: login: github-actions[bot]
created_at: 2025-02-28T16:11:46Z
body: <h1>Dependency Review</h1>
✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.<h2>OpenSSF Scorecard</h2>
<table><tr><th>Package</th><th>Version</th><th>Score</th><th>Details</th></tr>
</table><h2>Scanned Files</h2>
<ul>


<!-- dependency-review-pr-comment-marker -->
author_association: NONE
user: login: sonarqubecloud[bot]
created_at: 2025-03-07T15:20:50Z
body: ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=rskj&pullRequest=3013) **Quality Gate passed**  
Issues  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=rskj&pullRequest=3013&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=rskj&pullRequest=3013&issueStatuses=ACCEPTED)

Measures  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=rskj&pullRequest=3013&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=rskj&pullRequest=3013&metric=new_coverage&view=list)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=rskj&pullRequest=3013&metric=new_duplicated_lines_density&view=list)  
  
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=rskj&pullRequest=3013)


author_association: NONE