diff --git a/rskj-core/src/main/java/co/rsk/peg/ErpFederation.java b/rskj-core/src/main/java/co/rsk/peg/ErpFederation.java index 6a8ba7a14b1..cced1d6532b 100644 --- a/rskj-core/src/main/java/co/rsk/peg/ErpFederation.java +++ b/rskj-core/src/main/java/co/rsk/peg/ErpFederation.java @@ -57,6 +57,7 @@ public Script getStandardP2SHScript() { return standardP2SHScript; } + @Override public int getNumberOfSignaturesRequired() { List standardRedeemScriptChunks = getStandardRedeemScript().getChunks(); diff --git a/rskj-core/src/main/java/co/rsk/peg/LegacyErpFederation.java b/rskj-core/src/main/java/co/rsk/peg/LegacyErpFederation.java index 09b78b5e5bd..cfd104dcdcb 100644 --- a/rskj-core/src/main/java/co/rsk/peg/LegacyErpFederation.java +++ b/rskj-core/src/main/java/co/rsk/peg/LegacyErpFederation.java @@ -34,6 +34,7 @@ public LegacyErpFederation( validateRedeemScript(); } + @Override public Script getRedeemScript() { if (!activations.isActive(ConsensusRule.RSKIP284) && btcParams.getId().equals(NetworkParameters.ID_TESTNET)) { @@ -53,6 +54,7 @@ public Script getRedeemScript() { return redeemScript; } + @Override public Script getStandardRedeemScript() { if (standardRedeemScript == null) { // i think is not quite right to just "fix" the standardRedeemScript in the buggy fed. diff --git a/rskj-core/src/main/java/co/rsk/peg/P2shErpFederation.java b/rskj-core/src/main/java/co/rsk/peg/P2shErpFederation.java index 58f97f54a8e..573fe02f903 100644 --- a/rskj-core/src/main/java/co/rsk/peg/P2shErpFederation.java +++ b/rskj-core/src/main/java/co/rsk/peg/P2shErpFederation.java @@ -26,6 +26,7 @@ public P2shErpFederation( super(members, creationTime, creationBlockNumber, btcParams, erpPubKeys, activationDelay, activations); } + @Override public final Script getRedeemScript() { if (redeemScript == null) { logger.debug("[getRedeemScript] Creating the redeem script from the keys"); @@ -39,6 +40,7 @@ public final Script getRedeemScript() { return redeemScript; } + @Override public final Script getStandardRedeemScript() { if (standardRedeemScript == null) { standardRedeemScript = P2shErpFederationRedeemScriptParser.extractStandardRedeemScript( diff --git a/rskj-core/src/main/java/co/rsk/peg/StandardMultisigFederation.java b/rskj-core/src/main/java/co/rsk/peg/StandardMultisigFederation.java index 1b4291a8c28..7adb20b1339 100644 --- a/rskj-core/src/main/java/co/rsk/peg/StandardMultisigFederation.java +++ b/rskj-core/src/main/java/co/rsk/peg/StandardMultisigFederation.java @@ -44,6 +44,7 @@ public StandardMultisigFederation( super(members, creationTime, creationBlockNumber, btcParams); } + @Override public Script getRedeemScript() { if (redeemScript == null) { redeemScript = ScriptBuilder.createRedeemScript(getNumberOfSignaturesRequired(), getBtcPublicKeys()); @@ -52,6 +53,7 @@ public Script getRedeemScript() { return redeemScript; } + @Override public int getNumberOfSignaturesRequired() { List standardRedeemScriptChunks = getRedeemScript().getChunks(); @@ -61,6 +63,7 @@ public int getNumberOfSignaturesRequired() { return Integer.parseInt(thresholdChunk.toString()); } + @Override public int hashCode() { // Can use java.util.Objects.hash since all of Instant, int and List have // well-defined hashCode()s diff --git a/rskj-core/src/test/java/co/rsk/peg/BridgeSerializationUtilsTest.java b/rskj-core/src/test/java/co/rsk/peg/BridgeSerializationUtilsTest.java index efaea5539e4..730cb05ee13 100644 --- a/rskj-core/src/test/java/co/rsk/peg/BridgeSerializationUtilsTest.java +++ b/rskj-core/src/test/java/co/rsk/peg/BridgeSerializationUtilsTest.java @@ -151,7 +151,7 @@ void serializeFederationOnlyBtcKeys() throws Exception { }; // Only actual keys serialized are BTC keys, so we don't really care about RSK or MST keys - Federation federation = new Federation( + Federation federation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(Arrays.asList(new BtcECKey[]{ BtcECKey.fromPublicOnly(publicKeyBytes[0]), BtcECKey.fromPublicOnly(publicKeyBytes[1]), @@ -302,7 +302,7 @@ void serializeFederation_serializedKeysAreCompressedAndThree() { members.add(new FederationMember(new BtcECKey(), new ECKey(), new ECKey())); } - Federation testFederation = new Federation( + Federation testFederation = new StandardMultisigFederation( members, Instant.now(), 123, NetworkParameters.fromID(NetworkParameters.ID_REGTEST) ); @@ -787,7 +787,7 @@ void serializeAndDeserializeFederationOnlyBtcKeysWithRealRLP() { }; // Only actual keys serialized are BTC keys, so deserialization will fill RSK and MST keys with those - Federation federation = new Federation( + Federation federation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithKeys(Arrays.asList( BtcECKey.fromPublicOnly(publicKeyBytes[0]), BtcECKey.fromPublicOnly(publicKeyBytes[1]), @@ -1246,7 +1246,7 @@ private void testSerializeAndDeserializeFederation( members.add(new FederationMember(new BtcECKey(), new ECKey(), new ECKey())); } - Federation testFederation = new Federation( + Federation testFederation = new StandardMultisigFederation( members, Instant.now(), 123, @@ -1259,7 +1259,7 @@ private void testSerializeAndDeserializeFederation( bridgeConstants.getBtcParams() ); - Federation testErpFederation = new ErpFederation( + Federation testErpFederation = new LegacyErpFederation( members, Instant.now(), 123, diff --git a/rskj-core/src/test/java/co/rsk/peg/BridgeStorageProviderFederationTests.java b/rskj-core/src/test/java/co/rsk/peg/BridgeStorageProviderFederationTests.java index 5f3e0cbdbd5..767ff666fcf 100644 --- a/rskj-core/src/test/java/co/rsk/peg/BridgeStorageProviderFederationTests.java +++ b/rskj-core/src/test/java/co/rsk/peg/BridgeStorageProviderFederationTests.java @@ -614,7 +614,7 @@ private Federation createFederation(int version) { activations ); case ERP_FEDERATION_FORMAT_VERSION: - return new ErpFederation( + return new LegacyErpFederation( members, Instant.now(), 1L, @@ -624,7 +624,7 @@ private Federation createFederation(int version) { activations ); default: - return new Federation( + return new StandardMultisigFederation( members, Instant.now(), 1L, diff --git a/rskj-core/src/test/java/co/rsk/peg/BridgeStorageProviderTest.java b/rskj-core/src/test/java/co/rsk/peg/BridgeStorageProviderTest.java index 66e84c07618..8d7c0c79d4b 100644 --- a/rskj-core/src/test/java/co/rsk/peg/BridgeStorageProviderTest.java +++ b/rskj-core/src/test/java/co/rsk/peg/BridgeStorageProviderTest.java @@ -402,7 +402,7 @@ void getNewFederation_multiKeyVersion() { @Test void getNewFederation_erp_fed() { Federation newFederation = buildMockFederation(100, 200, 300); - ErpFederation erpFederation = new ErpFederation( + ErpFederation erpFederation = new LegacyErpFederation( newFederation.getMembers(), newFederation.getCreationTime(), newFederation.getCreationBlockNumber(), @@ -546,7 +546,7 @@ void saveNewFederation_postMultiKey_RSKIP_201_active_erp_fed() { BridgeConstants bridgeConstants = config.getNetworkConstants().getBridgeConstants(); Federation newFederation = buildMockFederation(100, 200, 300); - ErpFederation erpFederation = new ErpFederation( + ErpFederation erpFederation = new LegacyErpFederation( newFederation.getMembers(), newFederation.getCreationTime(), newFederation.getCreationBlockNumber(), @@ -680,7 +680,7 @@ void getOldFederation_multiKeyVersion() { void getOldFederation_erp_fed() { BridgeConstants bridgeConstants = config.getNetworkConstants().getBridgeConstants(); Federation oldFederation = buildMockFederation(100, 200, 300); - ErpFederation erpFederation = new ErpFederation( + ErpFederation erpFederation = new LegacyErpFederation( oldFederation.getMembers(), oldFederation.getCreationTime(), oldFederation.getCreationBlockNumber(), @@ -820,7 +820,7 @@ void saveOldFederation_postMultikey_RSKIP_201_active_erp_fed() { BridgeConstants bridgeConstants = config.getNetworkConstants().getBridgeConstants(); Federation oldFederation = buildMockFederation(100, 200, 300); - ErpFederation erpFederation = new ErpFederation( + ErpFederation erpFederation = new LegacyErpFederation( oldFederation.getMembers(), oldFederation.getCreationTime(), oldFederation.getCreationBlockNumber(), @@ -3912,7 +3912,7 @@ private Address getBtcAddress(String addr) { } private Federation buildMockFederation(Integer... pks) { - return new Federation( + return new StandardMultisigFederation( FederationTestUtils.getFederationMembersFromPks(pks), Instant.ofEpochMilli(1000), 0L, NetworkParameters.fromID(NetworkParameters.ID_REGTEST) 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 76e1a98cba5..5f4744eef9e 100644 --- a/rskj-core/src/test/java/co/rsk/peg/BridgeSupportAddSignatureTest.java +++ b/rskj-core/src/test/java/co/rsk/peg/BridgeSupportAddSignatureTest.java @@ -75,7 +75,7 @@ void addSignature_fedPubKey_belongs_to_active_federation() throws Exception { ); federation1Keys.sort(BtcECKey.PUBKEY_COMPARATOR); - Federation activeFederation = new Federation( + Federation activeFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(federation1Keys), Instant.ofEpochMilli(1000L), 0L, @@ -133,7 +133,7 @@ void addSignature_fedPubKey_belongs_to_retiring_federation() throws Exception { BtcECKey.fromPrivate(Hex.decode("fa02"))); federation1Keys.sort(BtcECKey.PUBKEY_COMPARATOR); - Federation retiringFederation = new Federation( + Federation retiringFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(federation1Keys), Instant.ofEpochMilli(1000L), 0L, @@ -147,7 +147,7 @@ void addSignature_fedPubKey_belongs_to_retiring_federation() throws Exception { ); activeFederationKeys.sort(BtcECKey.PUBKEY_COMPARATOR); - Federation activeFederation = new Federation( + Federation activeFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(activeFederationKeys), Instant.ofEpochMilli(1000L), 0L, @@ -191,7 +191,7 @@ void addSignature_fedPubKey_no_belong_to_retiring_or_active_federation() throws ); federation1Keys.sort(BtcECKey.PUBKEY_COMPARATOR); - Federation retiringFederation = new Federation( + Federation retiringFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(federation1Keys), Instant.ofEpochMilli(1000L), 0L, @@ -205,7 +205,7 @@ void addSignature_fedPubKey_no_belong_to_retiring_or_active_federation() throws ); activeFederationKeys.sort(BtcECKey.PUBKEY_COMPARATOR); - Federation activeFederation = new Federation( + Federation activeFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(activeFederationKeys), Instant.ofEpochMilli(1000L), 0L, diff --git a/rskj-core/src/test/java/co/rsk/peg/BridgeSupportGetTransactionTypeTest.java b/rskj-core/src/test/java/co/rsk/peg/BridgeSupportGetTransactionTypeTest.java index 8b86aaa01dd..e433dbf5eb3 100644 --- a/rskj-core/src/test/java/co/rsk/peg/BridgeSupportGetTransactionTypeTest.java +++ b/rskj-core/src/test/java/co/rsk/peg/BridgeSupportGetTransactionTypeTest.java @@ -128,7 +128,7 @@ void getTransactionType_sentFromOldFed(ActivationConfig.ForBlock activations, Pe .withProvider(provider) .build(); - Federation activeFederation = new Federation( + Federation activeFederation = new StandardMultisigFederation( bridgeRegTestConstants.getGenesisFederation().getMembers(), bridgeRegTestConstants.getGenesisFederation().getCreationTime(), 5L, @@ -258,7 +258,7 @@ void getTransactionType_pegout_tx() { new String[]{"fa01", "fa02", "fa03"}, true ); - Federation activeFederation = new Federation( + Federation activeFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(fedKeys), Instant.ofEpochMilli(1000L), 0L, @@ -304,7 +304,7 @@ void getTransactionType_migration_tx() { new String[]{"fa01", "fa02", "fa03"}, true );; - Federation retiringFederation = new Federation( + Federation retiringFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(retiringFedKeys), Instant.ofEpochMilli(1000L), 0L, diff --git a/rskj-core/src/test/java/co/rsk/peg/BridgeSupportProcessFundsMigrationTest.java b/rskj-core/src/test/java/co/rsk/peg/BridgeSupportProcessFundsMigrationTest.java index 10133a00253..6f1a565d7d3 100644 --- a/rskj-core/src/test/java/co/rsk/peg/BridgeSupportProcessFundsMigrationTest.java +++ b/rskj-core/src/test/java/co/rsk/peg/BridgeSupportProcessFundsMigrationTest.java @@ -127,7 +127,7 @@ void test_processFundsMigration( federationActivationAge + bridgeConstants.getFundsMigrationAgeSinceActivationEnd(activations) + 1; - Federation newFederation = new Federation( + Federation newFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembers(1), Instant.EPOCH, federationCreationBlockNumber, diff --git a/rskj-core/src/test/java/co/rsk/peg/BridgeSupportReleaseBtcTest.java b/rskj-core/src/test/java/co/rsk/peg/BridgeSupportReleaseBtcTest.java index 11a4cbaaa28..35cfde10491 100644 --- a/rskj-core/src/test/java/co/rsk/peg/BridgeSupportReleaseBtcTest.java +++ b/rskj-core/src/test/java/co/rsk/peg/BridgeSupportReleaseBtcTest.java @@ -1250,7 +1250,7 @@ private static Repository createRepository() { } private static Federation getFederation() { - return new Federation( + return new StandardMultisigFederation( FederationTestUtils.getFederationMembers(3), Instant.ofEpochMilli(1000), 0L, diff --git a/rskj-core/src/test/java/co/rsk/peg/BridgeSupportTest.java b/rskj-core/src/test/java/co/rsk/peg/BridgeSupportTest.java index 3a4457a91b6..7576c1c34b7 100644 --- a/rskj-core/src/test/java/co/rsk/peg/BridgeSupportTest.java +++ b/rskj-core/src/test/java/co/rsk/peg/BridgeSupportTest.java @@ -970,7 +970,7 @@ void registerBtcTransactionLockTxNotWhitelisted_before_rskip_146_activation() th BtcECKey.fromPrivate(Hex.decode("fa02")) ); - Federation federation1 = new Federation( + Federation federation1 = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(federation1Keys), Instant.ofEpochMilli(1000L), 0L, @@ -983,7 +983,7 @@ void registerBtcTransactionLockTxNotWhitelisted_before_rskip_146_activation() th BtcECKey.fromPrivate(Hex.decode("fb02")), BtcECKey.fromPrivate(Hex.decode("fb03"))); - Federation federation2 = new Federation( + Federation federation2 = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(federation2Keys), Instant.ofEpochMilli(2000L), 0L, @@ -1140,7 +1140,7 @@ void registerBtcTransactionLockTxNotWhitelisted_after_rskip_146_activation() thr BtcECKey.fromPrivate(Hex.decode("fa02")) ); - Federation federation1 = new Federation( + Federation federation1 = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(federation1Keys), Instant.ofEpochMilli(1000L), 0L, @@ -1153,7 +1153,7 @@ void registerBtcTransactionLockTxNotWhitelisted_after_rskip_146_activation() thr BtcECKey.fromPrivate(Hex.decode("fb02")), BtcECKey.fromPrivate(Hex.decode("fb03"))); - Federation federation2 = new Federation( + Federation federation2 = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(federation2Keys), Instant.ofEpochMilli(2000L), 0L, @@ -1324,7 +1324,7 @@ void registerBtcTransaction_sending_segwit_tx_twice_locks_just_once() throws Blo BtcECKey.fromPrivate(Hex.decode("fa02")) ); - Federation fed = new Federation( + Federation fed = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(fedKeys), Instant.ofEpochMilli(1000L), 0L, @@ -1416,7 +1416,7 @@ void callProcessFundsMigration_is_migrating_before_rskip_146_activation() throws Federation oldFederation = bridgeConstantsRegtest.getGenesisFederation(); - Federation newFederation = new Federation( + Federation newFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembers(1), Instant.EPOCH, 5L, @@ -1479,7 +1479,7 @@ void callProcessFundsMigration_is_migrating_after_rskip_146_activation() throws Federation oldFederation = bridgeConstantsRegtest.getGenesisFederation(); - Federation newFederation = new Federation( + Federation newFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembers(1), Instant.EPOCH, 5L, @@ -1544,7 +1544,7 @@ void callProcessFundsMigration_is_migrated_before_rskip_146_activation() throws Federation oldFederation = bridgeConstantsRegtest.getGenesisFederation(); - Federation newFederation = new Federation( + Federation newFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembers(1), Instant.EPOCH, 5L, @@ -1607,7 +1607,7 @@ void callProcessFundsMigration_is_migrated_after_rskip_146_activation() throws I Federation oldFederation = bridgeConstantsRegtest.getGenesisFederation(); - Federation newFederation = new Federation( + Federation newFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembers(1), Instant.EPOCH, 5L, @@ -1671,7 +1671,7 @@ void updateFederationCreationBlockHeights_before_rskip_186_activation() throws I Federation oldFederation = bridgeConstantsRegtest.getGenesisFederation(); - Federation newFederation = new Federation( + Federation newFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembers(1), Instant.EPOCH, 5L, @@ -1734,7 +1734,7 @@ void updateFederationCreationBlockHeights_after_rskip_186_activation() throws IO Federation oldFederation = bridgeConstantsRegtest.getGenesisFederation(); - Federation newFederation = new Federation( + Federation newFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembers(1), Instant.EPOCH, 5L, @@ -2115,7 +2115,7 @@ void rskTxWaitingForSignature_fail_adding_an_already_existing_key_after_rskip_37 // Set state to make concur a pegout migration tx and pegout batch creation on the same updateCollection Federation oldFederation = bridgeConstants.getGenesisFederation(); - Federation newFederation = new Federation( + Federation newFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembers(1), Instant.EPOCH, 5L, @@ -6410,13 +6410,13 @@ private void test_migrating_many_utxos(boolean isRskip294Active, int utxosToCrea oldFedMembers.add(FederationMember.getFederationMemberFromKey(new BtcECKey())); } - Federation oldFed = new Federation( + Federation oldFed = new StandardMultisigFederation( oldFedMembers, Instant.now(), 0, btcRegTestParams ); - Federation newFed = new Federation( + Federation newFed = new StandardMultisigFederation( Arrays.asList( FederationMember.getFederationMemberFromKey(new BtcECKey()), FederationMember.getFederationMemberFromKey(new BtcECKey()), diff --git a/rskj-core/src/test/java/co/rsk/peg/BridgeSupportTestIntegration.java b/rskj-core/src/test/java/co/rsk/peg/BridgeSupportTestIntegration.java index a7e4d2663a2..c49937c0e45 100644 --- a/rskj-core/src/test/java/co/rsk/peg/BridgeSupportTestIntegration.java +++ b/rskj-core/src/test/java/co/rsk/peg/BridgeSupportTestIntegration.java @@ -584,7 +584,7 @@ void minimumProcessFundsMigrationValue() throws IOException { Federation oldFederation = bridgeConstants.getGenesisFederation(); BtcECKey key = new BtcECKey(new SecureRandom()); FederationMember member = new FederationMember(key, new ECKey(), new ECKey()); - Federation newFederation = new Federation( + Federation newFederation = new StandardMultisigFederation( Collections.singletonList(member), Instant.EPOCH, 5L, @@ -1346,14 +1346,14 @@ void registerBtcTransactionMigrationTx() throws BlockStoreException, AddressForm BtcECKey.fromPrivate(Hex.decode("fa02")) ).sorted(BtcECKey.PUBKEY_COMPARATOR).collect(Collectors.toList()); - Federation activeFederation = new Federation(FederationTestUtils.getFederationMembersWithBtcKeys(activeFederationKeys), Instant.ofEpochMilli(2000L), 2L, parameters); + Federation activeFederation = new StandardMultisigFederation(FederationTestUtils.getFederationMembersWithBtcKeys(activeFederationKeys), Instant.ofEpochMilli(2000L), 2L, parameters); List retiringFederationKeys = Stream.of( BtcECKey.fromPrivate(Hex.decode("fb01")), BtcECKey.fromPrivate(Hex.decode("fb02")) ).sorted(BtcECKey.PUBKEY_COMPARATOR).collect(Collectors.toList()); - Federation retiringFederation = new Federation(FederationTestUtils.getFederationMembersWithBtcKeys(retiringFederationKeys), Instant.ofEpochMilli(1000L), 1L, parameters); + Federation retiringFederation = new StandardMultisigFederation(FederationTestUtils.getFederationMembersWithBtcKeys(retiringFederationKeys), Instant.ofEpochMilli(1000L), 1L, parameters); Repository repository = createRepository(); repository.addBalance(PrecompiledContracts.BRIDGE_ADDR, LIMIT_MONETARY_BASE); @@ -1459,7 +1459,7 @@ void registerBtcTransactionWithCrossFederationsChange() throws Exception { .map(BtcECKey::fromPrivate) .sorted(BtcECKey.PUBKEY_COMPARATOR) .collect(Collectors.toList()); - Federation activeFederation = new Federation( + Federation activeFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(activeFederationKeys), Instant.ofEpochMilli(1000L), 0L, params ); @@ -1469,7 +1469,7 @@ void registerBtcTransactionWithCrossFederationsChange() throws Exception { .map(BtcECKey::fromPrivate) .sorted(BtcECKey.PUBKEY_COMPARATOR) .collect(Collectors.toList()); - Federation retiringFederation = new Federation( + Federation retiringFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(retiringFederationKeys), Instant.ofEpochMilli(2000L), 0L, params ); @@ -1566,7 +1566,7 @@ void registerBtcTransactionLockTxWhitelisted() throws Exception { }); federation1Keys.sort(BtcECKey.PUBKEY_COMPARATOR); - Federation federation1 = new Federation(FederationTestUtils.getFederationMembersWithBtcKeys(federation1Keys), Instant.ofEpochMilli(1000L), 0L, btcParams); + Federation federation1 = new StandardMultisigFederation(FederationTestUtils.getFederationMembersWithBtcKeys(federation1Keys), Instant.ofEpochMilli(1000L), 0L, btcParams); List federation2Keys = Arrays.asList(new BtcECKey[]{ BtcECKey.fromPrivate(Hex.decode("fb01")), @@ -1575,7 +1575,7 @@ void registerBtcTransactionLockTxWhitelisted() throws Exception { }); federation2Keys.sort(BtcECKey.PUBKEY_COMPARATOR); - Federation federation2 = new Federation(FederationTestUtils.getFederationMembersWithBtcKeys(federation2Keys), Instant.ofEpochMilli(2000L), 0L, btcParams); + Federation federation2 = new StandardMultisigFederation(FederationTestUtils.getFederationMembersWithBtcKeys(federation2Keys), Instant.ofEpochMilli(2000L), 0L, btcParams); Repository repository = createRepository(); repository.addBalance(PrecompiledContracts.BRIDGE_ADDR, LIMIT_MONETARY_BASE); @@ -1726,13 +1726,13 @@ void getBtcTxHashProcessedHeight() throws IOException, BlockStoreException { @Test void getFederationMethods_genesis() throws IOException { - Federation activeFederation = new Federation( + Federation activeFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembers(3), Instant.ofEpochMilli(1000), 0L, NetworkParameters.fromID(NetworkParameters.ID_REGTEST) ); - Federation genesisFederation = new Federation( + Federation genesisFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembers(6), Instant.ofEpochMilli(1000), 0L, @@ -1754,13 +1754,13 @@ void getFederationMethods_genesis() throws IOException { @Test void getFederationMethods_active() throws IOException { - Federation activeFederation = new Federation( + Federation activeFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembers(3), Instant.ofEpochMilli(1000), 0L, NetworkParameters.fromID(NetworkParameters.ID_REGTEST) ); - Federation genesisFederation = new Federation( + Federation genesisFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembers(6), Instant.ofEpochMilli(1000), 0L, @@ -1790,13 +1790,13 @@ void getFederationMethods_active() throws IOException { @Test void getFederationMethods_newActivated() throws IOException { - Federation newFederation = new Federation( + Federation newFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembers(3), Instant.ofEpochMilli(1000), 15L, NetworkParameters.fromID(NetworkParameters.ID_REGTEST) ); - Federation oldFederation = new Federation( + Federation oldFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembers(6), Instant.ofEpochMilli(1000), 0L, @@ -1830,13 +1830,13 @@ void getFederationMethods_newActivated() throws IOException { @Test void getFederationMethods_newNotActivated() throws IOException { - Federation newFederation = new Federation( + Federation newFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembers(3), Instant.ofEpochMilli(1000), 15L, NetworkParameters.fromID(NetworkParameters.ID_REGTEST) ); - Federation oldFederation = new Federation( + Federation oldFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembers(6), Instant.ofEpochMilli(1000), 0L, @@ -1883,14 +1883,14 @@ void getRetiringFederationMethods_none() throws IOException { @Test void getRetiringFederationMethods_presentNewInactive() throws IOException { - Federation mockedNewFederation = new Federation( + Federation mockedNewFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembers(2), Instant.ofEpochMilli(2000), 10L, NetworkParameters.fromID(NetworkParameters.ID_REGTEST) ); - Federation mockedOldFederation = new Federation( + Federation mockedOldFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembers(4), Instant.ofEpochMilli(1000), 0L, @@ -1920,14 +1920,14 @@ void getRetiringFederationMethods_presentNewInactive() throws IOException { @Test void getRetiringFederationMethods_presentNewActive() throws IOException { - Federation mockedNewFederation = new Federation( + Federation mockedNewFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembers(2), Instant.ofEpochMilli(2000), 10L, NetworkParameters.fromID(NetworkParameters.ID_REGTEST) ); - Federation mockedOldFederation = new Federation( + Federation mockedOldFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembers(4), Instant.ofEpochMilli(1000), 0L, @@ -2137,14 +2137,14 @@ void createFederation_pendingExists() throws IOException, BridgeIllegalArgumentE void createFederation_withPendingActivation() throws IOException, BridgeIllegalArgumentException { VotingMocksProvider mocksProvider = new VotingMocksProvider("create", new byte[][]{}, false); - Federation mockedNewFederation = new Federation( + Federation mockedNewFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembers(2), Instant.ofEpochMilli(2000), 10L, NetworkParameters.fromID(NetworkParameters.ID_REGTEST) ); - Federation mockedOldFederation = new Federation( + Federation mockedOldFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembers(4), Instant.ofEpochMilli(1000), 0L, @@ -2178,14 +2178,14 @@ void createFederation_withPendingActivation() throws IOException, BridgeIllegalA void createFederation_withExistingRetiringFederation() throws IOException, BridgeIllegalArgumentException { VotingMocksProvider mocksProvider = new VotingMocksProvider("create", new byte[][]{}, false); - Federation mockedNewFederation = new Federation( + Federation mockedNewFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembers(2), Instant.ofEpochMilli(2000), 10L, NetworkParameters.fromID(NetworkParameters.ID_REGTEST) ); - Federation mockedOldFederation = new Federation( + Federation mockedOldFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembers(4), Instant.ofEpochMilli(1000), 0L, @@ -2722,14 +2722,14 @@ void commitFederation_ok() throws IOException, BridgeIllegalArgumentException { when(executionBlock.getTimestamp()).thenReturn(15005L); when(executionBlock.getNumber()).thenReturn(15L); - Federation expectedFederation = new Federation(FederationTestUtils.getFederationMembersWithKeys(Arrays.asList( + Federation expectedFederation = new StandardMultisigFederation(FederationTestUtils.getFederationMembersWithKeys(Arrays.asList( BtcECKey.fromPublicOnly(Hex.decode("036bb9eab797eadc8b697f0e82a01d01cabbfaaca37e5bafc06fdc6fdd38af894a")), BtcECKey.fromPublicOnly(Hex.decode("031da807c71c2f303b7f409dd2605b297ac494a563be3b9ca5f52d95a43d183cc5")), BtcECKey.fromPublicOnly(Hex.decode("025eefeeeed5cdc40822880c7db1d0a88b7b986945ed3fc05a0b45fe166fe85e12")), BtcECKey.fromPublicOnly(Hex.decode("03c67ad63527012fd4776ae892b5dc8c56f80f1be002dc65cd520a2efb64e37b49")))), Instant.ofEpochMilli(15005L), 15L, NetworkParameters.fromID(NetworkParameters.ID_REGTEST)); - Federation newFederation = new Federation(FederationTestUtils.getFederationMembersWithKeys(Arrays.asList( + Federation newFederation = new StandardMultisigFederation(FederationTestUtils.getFederationMembersWithKeys(Arrays.asList( BtcECKey.fromPublicOnly(Hex.decode("0346cb6b905e4dee49a862eeb2288217d06afcd4ace4b5ca77ebedfbc6afc1c19d")), BtcECKey.fromPublicOnly(Hex.decode("0269a0dbe7b8f84d1b399103c466fb20531a56b1ad3a7b44fe419e74aad8c46db7")), BtcECKey.fromPublicOnly(Hex.decode("026192d8ab41bd402eb0431457f6756a3f3ce15c955c534d2b87f1e0372d8ba338")))), @@ -2876,7 +2876,7 @@ void commitFederation_hashMismatch() throws IOException, BridgeIllegalArgumentEx @Test void getActiveFederationWallet() throws IOException { - Federation expectedFederation = new Federation(FederationTestUtils.getFederationMembersWithBtcKeys(Arrays.asList(new BtcECKey[]{ + Federation expectedFederation = new StandardMultisigFederation(FederationTestUtils.getFederationMembersWithBtcKeys(Arrays.asList(new BtcECKey[]{ BtcECKey.fromPublicOnly(Hex.decode("036bb9eab797eadc8b697f0e82a01d01cabbfaaca37e5bafc06fdc6fdd38af894a")), BtcECKey.fromPublicOnly(Hex.decode("031da807c71c2f303b7f409dd2605b297ac494a563be3b9ca5f52d95a43d183cc5")) })), Instant.ofEpochMilli(5005L), 0L, NetworkParameters.fromID(NetworkParameters.ID_REGTEST)); @@ -2909,14 +2909,14 @@ void getActiveFederationWallet() throws IOException { @Test void getRetiringFederationWallet_nonEmpty() throws IOException { - Federation mockedNewFederation = new Federation( + Federation mockedNewFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembers(2), Instant.ofEpochMilli(2000), 10L, NetworkParameters.fromID(NetworkParameters.ID_REGTEST) ); - Federation expectedFederation = new Federation(FederationTestUtils.getFederationMembersWithBtcKeys(Arrays.asList(new BtcECKey[]{ + Federation expectedFederation = new StandardMultisigFederation(FederationTestUtils.getFederationMembersWithBtcKeys(Arrays.asList(new BtcECKey[]{ BtcECKey.fromPublicOnly(Hex.decode("036bb9eab797eadc8b697f0e82a01d01cabbfaaca37e5bafc06fdc6fdd38af894a")), BtcECKey.fromPublicOnly(Hex.decode("031da807c71c2f303b7f409dd2605b297ac494a563be3b9ca5f52d95a43d183cc5")) })), Instant.ofEpochMilli(5005L), 0L, NetworkParameters.fromID(NetworkParameters.ID_REGTEST)); @@ -3745,7 +3745,7 @@ private BridgeSupport getBridgeSupportWithMocksForFederationTests( BridgeEventLogger eventLogger) throws IOException { BridgeConstants constantsMock = mock(BridgeConstants.class); - when(constantsMock.getGenesisFederation()).thenReturn(mockedGenesisFederation); + when(constantsMock.getGenesisFederation()).thenReturn((StandardMultisigFederation) mockedGenesisFederation); when(constantsMock.getBtcParams()).thenReturn(NetworkParameters.fromID(NetworkParameters.ID_REGTEST)); when(constantsMock.getFederationChangeAuthorizer()).thenReturn(bridgeConstants.getFederationChangeAuthorizer()); diff --git a/rskj-core/src/test/java/co/rsk/peg/BridgeTest.java b/rskj-core/src/test/java/co/rsk/peg/BridgeTest.java index e073d92caee..2bfee1299fc 100644 --- a/rskj-core/src/test/java/co/rsk/peg/BridgeTest.java +++ b/rskj-core/src/test/java/co/rsk/peg/BridgeTest.java @@ -238,7 +238,7 @@ void registerBtcTransaction_beforeRskip199_rejectsExternalCalls() ActivationConfig activations = spy(ActivationConfigsForTest.genesis()); doReturn(false).when(activations).isActive(eq(RSKIP199), anyLong()); - Federation activeFederation = new Federation( + Federation activeFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembers(3), Instant.ofEpochMilli(1000), 0L, @@ -284,7 +284,7 @@ void registerBtcTransaction_beforeRskip199_acceptsCallFromFederationMember() List federationKeys = Arrays.asList(fed1Key, new BtcECKey(), new BtcECKey()); federationKeys.sort(BtcECKey.PUBKEY_COMPARATOR); - Federation activeFederation = new Federation( + Federation activeFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithKeys(federationKeys), Instant.ofEpochMilli(1000), 0L, diff --git a/rskj-core/src/test/java/co/rsk/peg/BridgeUtilsLegacyTest.java b/rskj-core/src/test/java/co/rsk/peg/BridgeUtilsLegacyTest.java index 61c25b21ae1..5f59ad6f9f3 100644 --- a/rskj-core/src/test/java/co/rsk/peg/BridgeUtilsLegacyTest.java +++ b/rskj-core/src/test/java/co/rsk/peg/BridgeUtilsLegacyTest.java @@ -456,7 +456,7 @@ void calculatePegoutTxSize_before_rskip_271() { when(activations.isActive(ConsensusRule.RSKIP271)).thenReturn(false); List keys = PegTestUtils.createRandomBtcECKeys(13); - Federation federation = new Federation( + Federation federation = new StandardMultisigFederation( FederationMember.getFederationMembersFromKeys(keys), Instant.now(), 0, @@ -478,7 +478,7 @@ void calculatePegoutTxSize_after_rskip_271() { when(activations.isActive(ConsensusRule.RSKIP271)).thenReturn(true); List keys = PegTestUtils.createRandomBtcECKeys(13); - Federation federation = new Federation( + Federation federation = new StandardMultisigFederation( FederationMember.getFederationMembersFromKeys(keys), Instant.now(), 0, @@ -493,7 +493,7 @@ void calculatePegoutTxSize_ZeroInput_ZeroOutput() { when(activations.isActive(ConsensusRule.RSKIP271)).thenReturn(false); List keys = PegTestUtils.createRandomBtcECKeys(13); - Federation federation = new Federation( + Federation federation = new StandardMultisigFederation( FederationMember.getFederationMembersFromKeys(keys), Instant.now(), 0, 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 faed33c78a1..c7ae74957fc 100644 --- a/rskj-core/src/test/java/co/rsk/peg/BridgeUtilsTest.java +++ b/rskj-core/src/test/java/co/rsk/peg/BridgeUtilsTest.java @@ -249,7 +249,7 @@ void testIsValidPegInTxForTwoFederations() { BtcECKey.fromPrivate(Hex.decode("fa02")) ); federation1Keys.sort(BtcECKey.PUBKEY_COMPARATOR); - Federation federation1 = new Federation( + Federation federation1 = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(federation1Keys), Instant.ofEpochMilli(1000L), 0L, @@ -262,7 +262,7 @@ void testIsValidPegInTxForTwoFederations() { BtcECKey.fromPrivate(Hex.decode("fb03")) ); federation2Keys.sort(BtcECKey.PUBKEY_COMPARATOR); - Federation federation2 = new Federation( + Federation federation2 = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(federation2Keys), Instant.ofEpochMilli(2000L), 0L, @@ -574,7 +574,7 @@ void testIsValidPegInTx_hasChangeUtxoFromFlyoverErpFederation_beforeRskip201_isP BtcECKey.fromPrivate(Hex.decode("fa02")) ); erpFederationKeys.sort(BtcECKey.PUBKEY_COMPARATOR); - Federation erpFederation = new Federation( + Federation erpFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(erpFederationKeys), Instant.ofEpochMilli(1000L), 0L, @@ -616,7 +616,7 @@ void testIsValidPegInTx_hasChangeUtxoFromFlyoverErpFederation_afterRskip201_notP BtcECKey.fromPrivate(Hex.decode("fa02")) ); erpFederationKeys.sort(BtcECKey.PUBKEY_COMPARATOR); - Federation erpFederation = new Federation( + Federation erpFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(erpFederationKeys), Instant.ofEpochMilli(1000L), 0L, @@ -658,7 +658,7 @@ void testIsValidPegInTx_hasChangeUtxoFromErpFederation_beforeRskip201_isPegin() BtcECKey.fromPrivate(Hex.decode("fa02")) ); erpFederationKeys.sort(BtcECKey.PUBKEY_COMPARATOR); - Federation erpFederation = new Federation( + Federation erpFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(erpFederationKeys), Instant.ofEpochMilli(1000L), 0L, @@ -691,7 +691,7 @@ void testIsValidPegInTx_hasChangeUtxoFromErpFederation_afterRskip201_notPegin() BtcECKey.fromPrivate(Hex.decode("fa02")) ); erpFederationKeys.sort(BtcECKey.PUBKEY_COMPARATOR); - Federation erpFederation = new Federation( + Federation erpFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(erpFederationKeys), Instant.ofEpochMilli(1000L), 0L, @@ -724,7 +724,7 @@ void testIsValidPegInTx_hasChangeUtxoFromFlyoverRetiredFederation_beforeRskip201 BtcECKey.fromPrivate(Hex.decode("fa02")) ); retiredFederationKeys.sort(BtcECKey.PUBKEY_COMPARATOR); - Federation retiredFederation = new Federation( + Federation retiredFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(retiredFederationKeys), Instant.ofEpochMilli(1000L), 0L, @@ -769,7 +769,7 @@ void testIsValidPegInTx_hasChangeUtxoFromFlyoverRetiredFederation_afterRskip201_ BtcECKey.fromPrivate(Hex.decode("fa02")) ); retiredFederationKeys.sort(BtcECKey.PUBKEY_COMPARATOR); - Federation retiredFederation = new Federation( + Federation retiredFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(retiredFederationKeys), Instant.ofEpochMilli(1000L), 0L, @@ -814,7 +814,7 @@ void testIsValidPegInTx_hasChangeUtxoFromFlyoverErpRetiredFederation_beforeRskip BtcECKey.fromPrivate(Hex.decode("fa02")) ); retiredFederationKeys.sort(BtcECKey.PUBKEY_COMPARATOR); - Federation retiredFederation = new Federation( + Federation retiredFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(retiredFederationKeys), Instant.ofEpochMilli(1000L), 0L, @@ -827,7 +827,7 @@ void testIsValidPegInTx_hasChangeUtxoFromFlyoverErpRetiredFederation_beforeRskip ); erpFederationPublicKeys.sort(BtcECKey.PUBKEY_COMPARATOR); - Federation erpFederation = new ErpFederation( + Federation erpFederation = new LegacyErpFederation( FederationTestUtils.getFederationMembersWithBtcKeys(retiredFederationKeys), Instant.ofEpochMilli(1000L), 0L, @@ -875,7 +875,7 @@ void testIsValidPegInTx_hasChangeUtxoFromFlyoverErpRetiredFederation_afterRskip2 BtcECKey.fromPrivate(Hex.decode("fa02")) ); retiredFederationKeys.sort(BtcECKey.PUBKEY_COMPARATOR); - Federation retiredFederation = new Federation( + Federation retiredFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(retiredFederationKeys), Instant.ofEpochMilli(1000L), 0L, @@ -888,7 +888,7 @@ void testIsValidPegInTx_hasChangeUtxoFromFlyoverErpRetiredFederation_afterRskip2 ); erpFederationPublicKeys.sort(BtcECKey.PUBKEY_COMPARATOR); - Federation erpFederation = new ErpFederation( + Federation erpFederation = new LegacyErpFederation( FederationTestUtils.getFederationMembersWithBtcKeys(retiredFederationKeys), Instant.ofEpochMilli(1000L), 0L, @@ -935,7 +935,7 @@ void testIsValidPegInTx_hasChangeUtxoFromErpRetiredFederation_beforeRskip201_isP BtcECKey.fromPrivate(Hex.decode("fa02")) ); retiredFederationKeys.sort(BtcECKey.PUBKEY_COMPARATOR); - Federation retiredFederation = new Federation( + Federation retiredFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(retiredFederationKeys), Instant.ofEpochMilli(1000L), 0L, @@ -948,7 +948,7 @@ void testIsValidPegInTx_hasChangeUtxoFromErpRetiredFederation_beforeRskip201_isP ); erpFederationPublicKeys.sort(BtcECKey.PUBKEY_COMPARATOR); - Federation erpFederation = new ErpFederation( + Federation erpFederation = new LegacyErpFederation( FederationTestUtils.getFederationMembersWithBtcKeys(retiredFederationKeys), Instant.ofEpochMilli(1000L), 0L, @@ -991,7 +991,7 @@ void testIsValidPegInTx_hasChangeUtxoFromErpRetiredFederation_afterRskip201_notP BtcECKey.fromPrivate(Hex.decode("fa02")) ); retiredFederationKeys.sort(BtcECKey.PUBKEY_COMPARATOR); - Federation retiredFederation = new Federation( + Federation retiredFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(retiredFederationKeys), Instant.ofEpochMilli(1000L), 0L, @@ -1004,7 +1004,7 @@ void testIsValidPegInTx_hasChangeUtxoFromErpRetiredFederation_afterRskip201_notP ); erpFederationPublicKeys.sort(BtcECKey.PUBKEY_COMPARATOR); - Federation erpFederation = new ErpFederation( + Federation erpFederation = new LegacyErpFederation( FederationTestUtils.getFederationMembersWithBtcKeys(retiredFederationKeys), Instant.ofEpochMilli(1000L), 0L, @@ -1308,7 +1308,7 @@ void testIsMigrationTx_sending_funds_from_retired_p2sh_fed_to_active_p2sh_fed() BtcECKey.fromPrivate(Hex.decode("fc02")) ).sorted(BtcECKey.PUBKEY_COMPARATOR).collect(Collectors.toList()); - Federation retiredFederation = new P2shErpFederation( + ErpFederation retiredFederation = new P2shErpFederation( FederationTestUtils.getFederationMembersWithBtcKeys(retiredFederationKeys), Instant.ofEpochMilli(1000L), 1L, @@ -1438,7 +1438,7 @@ void testIsMigrationTx_sending_funds_from_retired_standard_fed_to_active_p2sh_fe BtcECKey.fromPrivate(Hex.decode("fc02")) ).sorted(BtcECKey.PUBKEY_COMPARATOR).collect(Collectors.toList()); - Federation retiredFederation = new Federation( + Federation retiredFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(retiredFederationKeys), Instant.ofEpochMilli(1000L), 1L, @@ -1487,7 +1487,7 @@ void testIsMigrationTx_sending_funds_from_retired_standard_fed_to_active_p2sh_fe migrationTx, activeFederation, null, - retiredFederation.getStandardP2SHScript(), + retiredFederation.getP2SHScript(), btcContext, bridgeConstantsMainnet, activations @@ -1505,7 +1505,7 @@ void testIsMigrationTx_sending_funds_from_retiring_standard_fed_to_active_p2sh_f BtcECKey.fromPrivate(Hex.decode("fc02")) ).sorted(BtcECKey.PUBKEY_COMPARATOR).collect(Collectors.toList()); - Federation retiringFederation = new Federation( + Federation retiringFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(retiringFederationKeys), Instant.ofEpochMilli(1000L), 1L, @@ -1562,7 +1562,7 @@ void testIsMigrationTx_sending_funds_from_retired_standard_fed_to_active_standar BtcECKey.fromPrivate(Hex.decode("fc02")) ).sorted(BtcECKey.PUBKEY_COMPARATOR).collect(Collectors.toList()); - Federation retiredFederation = new Federation( + Federation retiredFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(retiredFederationKeys), Instant.ofEpochMilli(1000L), 1L, @@ -1574,7 +1574,7 @@ void testIsMigrationTx_sending_funds_from_retired_standard_fed_to_active_standar BtcECKey.fromPrivate(Hex.decode("fa02")) ).sorted(BtcECKey.PUBKEY_COMPARATOR).collect(Collectors.toList()); - Federation activeFederation = new Federation( + Federation activeFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(activeFederationKeys), Instant.ofEpochMilli(1000L), 1L, @@ -1598,7 +1598,7 @@ void testIsMigrationTx_sending_funds_from_retired_standard_fed_to_active_standar migrationTx, activeFederation, null, - retiredFederation.getStandardP2SHScript(), + retiredFederation.getP2SHScript(), btcContext, bridgeConstantsMainnet, activations @@ -1626,7 +1626,7 @@ void testIsMigrationTx_sending_funds_from_retiring_standard_fed_to_active_standa BtcECKey.fromPrivate(Hex.decode("fc02")) ).sorted(BtcECKey.PUBKEY_COMPARATOR).collect(Collectors.toList()); - Federation retiringFederation = new Federation( + Federation retiringFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(retiringFederationKeys), Instant.ofEpochMilli(1000L), 1L, @@ -1638,7 +1638,7 @@ void testIsMigrationTx_sending_funds_from_retiring_standard_fed_to_active_standa BtcECKey.fromPrivate(Hex.decode("fa02")) ).sorted(BtcECKey.PUBKEY_COMPARATOR).collect(Collectors.toList()); - Federation activeFederation = new Federation( + Federation activeFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(activeFederationKeys), Instant.ofEpochMilli(1000L), 1L, @@ -1677,7 +1677,7 @@ void testIsMigrationTx() { BtcECKey.fromPrivate(Hex.decode("fa01")), BtcECKey.fromPrivate(Hex.decode("fa02")) ).sorted(BtcECKey.PUBKEY_COMPARATOR).collect(Collectors.toList()); - Federation activeFederation = new Federation( + Federation activeFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(activeFederationKeys), Instant.ofEpochMilli(2000L), 2L, @@ -1689,7 +1689,7 @@ void testIsMigrationTx() { BtcECKey.fromPrivate(Hex.decode("fb02")), BtcECKey.fromPrivate(Hex.decode("fb03")) ).sorted(BtcECKey.PUBKEY_COMPARATOR).collect(Collectors.toList()); - Federation retiringFederation = new Federation( + Federation retiringFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(retiringFederationKeys), Instant.ofEpochMilli(1000L), 1L, @@ -1700,7 +1700,7 @@ void testIsMigrationTx() { BtcECKey.fromPrivate(Hex.decode("fc01")), BtcECKey.fromPrivate(Hex.decode("fc02")) ).sorted(BtcECKey.PUBKEY_COMPARATOR).collect(Collectors.toList()); - Federation retiredFederation = new Federation( + Federation retiredFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(retiredFederationKeys), Instant.ofEpochMilli(1000L), 1L, @@ -1831,7 +1831,7 @@ void testIsPegOutTx() { BtcECKey.fromPrivate(Hex.decode("fa02")), BtcECKey.fromPrivate(Hex.decode("fa03")) ).sorted(BtcECKey.PUBKEY_COMPARATOR).collect(Collectors.toList()); - Federation federation2 = new Federation( + Federation federation2 = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(activeFederationKeys), Instant.ofEpochMilli(2000L), 2L, @@ -1868,7 +1868,7 @@ void testIsPegOutTx_fromFlyoverFederation() { BtcECKey.fromPrivate(Hex.decode("fa03")) ); flyoverFederationKeys.sort(BtcECKey.PUBKEY_COMPARATOR); - Federation flyoverFederation = new Federation( + Federation flyoverFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(flyoverFederationKeys), Instant.ofEpochMilli(1000L), 0L, @@ -1926,7 +1926,7 @@ void testIsPegOutTx_fromErpFederation() { BtcECKey.fromPrivate(Hex.decode("fa03")) ); defaultFederationKeys.sort(BtcECKey.PUBKEY_COMPARATOR); - Federation defaultFederation = new Federation( + Federation defaultFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(defaultFederationKeys), Instant.ofEpochMilli(1000L), 0L, @@ -1940,7 +1940,7 @@ void testIsPegOutTx_fromErpFederation() { ); erpFederationPublicKeys.sort(BtcECKey.PUBKEY_COMPARATOR); - Federation erpFederation = new ErpFederation( + ErpFederation erpFederation = new LegacyErpFederation( FederationTestUtils.getFederationMembersWithBtcKeys(defaultFederationKeys), Instant.ofEpochMilli(1000L), 0L, @@ -2002,7 +2002,7 @@ void testIsPegOutTx_fromFlyoverErpFederation() { BtcECKey.fromPrivate(Hex.decode("fa03")) ); defaultFederationKeys.sort(BtcECKey.PUBKEY_COMPARATOR); - Federation defaultFederation = new Federation( + Federation defaultFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(defaultFederationKeys), Instant.ofEpochMilli(1000L), 0L, @@ -2016,7 +2016,7 @@ void testIsPegOutTx_fromFlyoverErpFederation() { ); erpFederationPublicKeys.sort(BtcECKey.PUBKEY_COMPARATOR); - Federation erpFederation = new ErpFederation( + Federation erpFederation = new LegacyErpFederation( FederationTestUtils.getFederationMembersWithBtcKeys(defaultFederationKeys), Instant.ofEpochMilli(1000L), 0L, @@ -2116,7 +2116,7 @@ void testChangeBetweenFederations() { .map(BtcECKey::fromPrivate) .sorted(BtcECKey.PUBKEY_COMPARATOR) .collect(Collectors.toList()); - Federation federation1 = new Federation( + Federation federation1 = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(federation1Keys), Instant.ofEpochMilli(1000L), 0L, networkParameters ); @@ -2126,7 +2126,7 @@ void testChangeBetweenFederations() { .map(BtcECKey::fromPrivate) .sorted(BtcECKey.PUBKEY_COMPARATOR) .collect(Collectors.toList()); - Federation federation2 = new Federation( + Federation federation2 = new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(federation2Keys), Instant.ofEpochMilli(2000L), 0L, networkParameters ); @@ -2536,7 +2536,7 @@ void isInputSignedByThisFederator_isSigned() { // Arrange BtcECKey federator1Key = new BtcECKey(); BtcECKey federator2Key = new BtcECKey(); - Federation federation = new Federation( + Federation federation = new StandardMultisigFederation( FederationMember.getFederationMembersFromKeys(Arrays.asList(federator1Key, federator2Key)), Instant.now(), 0, @@ -2584,7 +2584,7 @@ void isInputSignedByThisFederator_isSignedByAnotherFederator() { // Arrange BtcECKey federator1Key = new BtcECKey(); BtcECKey federator2Key = new BtcECKey(); - Federation federation = new Federation( + Federation federation = new StandardMultisigFederation( FederationMember.getFederationMembersFromKeys(Arrays.asList(federator1Key, federator2Key)), Instant.now(), 0, @@ -2632,7 +2632,7 @@ void isInputSignedByThisFederator_notSigned() { // Arrange BtcECKey federator1Key = new BtcECKey(); BtcECKey federator2Key = new BtcECKey(); - Federation federation = new Federation( + Federation federation = new StandardMultisigFederation( FederationMember.getFederationMembersFromKeys(Arrays.asList(federator1Key, federator2Key)), Instant.now(), 0, @@ -2978,7 +2978,7 @@ void testCalculatePegoutTxSize_ZeroInput_ZeroOutput() { when(activations.isActive(ConsensusRule.RSKIP271)).thenReturn(true); List keys = PegTestUtils.createRandomBtcECKeys(13); - Federation federation = new Federation( + Federation federation = new StandardMultisigFederation( FederationMember.getFederationMembersFromKeys(keys), Instant.now(), 0, @@ -2994,7 +2994,7 @@ void testCalculatePegoutTxSize_2Inputs_2Outputs() { when(activations.isActive(ConsensusRule.RSKIP271)).thenReturn(true); List keys = PegTestUtils.createRandomBtcECKeys(13); - Federation federation = new Federation( + Federation federation = new StandardMultisigFederation( FederationMember.getFederationMembersFromKeys(keys), Instant.now(), 0, @@ -3019,7 +3019,7 @@ void testCalculatePegoutTxSize_9Inputs_2Outputs() { when(activations.isActive(ConsensusRule.RSKIP271)).thenReturn(true); List keys = PegTestUtils.createRandomBtcECKeys(13); - Federation federation = new Federation( + Federation federation = new StandardMultisigFederation( FederationMember.getFederationMembersFromKeys(keys), Instant.now(), 0, @@ -3044,7 +3044,7 @@ void testCalculatePegoutTxSize_10Inputs_20Outputs() { when(activations.isActive(ConsensusRule.RSKIP271)).thenReturn(true); List keys = PegTestUtils.createRandomBtcECKeys(13); - Federation federation = new Federation( + Federation federation = new StandardMultisigFederation( FederationMember.getFederationMembersFromKeys(keys), Instant.now(), 0, @@ -3072,7 +3072,7 @@ void testCalculatePegoutTxSize_50Inputs_200Outputs() { when(activations.isActive(ConsensusRule.RSKIP271)).thenReturn(true); List keys = PegTestUtils.createRandomBtcECKeys(13); - Federation federation = new Federation( + Federation federation = new StandardMultisigFederation( FederationMember.getFederationMembersFromKeys(keys), Instant.now(), 0, @@ -3113,7 +3113,7 @@ void testCalculatePegoutTxSize_50Inputs_200Outputs_erpFederation() { ); erpFederationPublicKeys.sort(BtcECKey.PUBKEY_COMPARATOR); - Federation erpFederation = new ErpFederation( + Federation erpFederation = new LegacyErpFederation( FederationTestUtils.getFederationMembersWithBtcKeys(defaultFederationKeys), Instant.ofEpochMilli(1000L), 0L, @@ -3157,7 +3157,7 @@ void testCalculatePegoutTxSize_100Inputs_50Outputs_erpFederation() { ); erpFederationPublicKeys.sort(BtcECKey.PUBKEY_COMPARATOR); - Federation erpFederation = new ErpFederation( + Federation erpFederation = new LegacyErpFederation( FederationTestUtils.getFederationMembersWithBtcKeys(defaultFederationKeys), Instant.ofEpochMilli(1000L), 0L, @@ -3191,7 +3191,7 @@ void getRegularPegoutTxSize_has_proper_calculations() { BtcECKey key2 = new BtcECKey(); BtcECKey key3 = new BtcECKey(); List keys = Arrays.asList(key1, key2, key3); - Federation fed = new Federation( + Federation fed = new StandardMultisigFederation( FederationMember.getFederationMembersFromKeys(keys), Instant.now(), 0, @@ -3274,7 +3274,7 @@ void scriptCorrectlySpends_invalidScript() { } private void test_getSpendWallet(boolean isFlyoverCompatible) throws UTXOProviderException { - Federation federation = new Federation(FederationTestUtils.getFederationMembersWithBtcKeys(Arrays.asList( + Federation federation = new StandardMultisigFederation(FederationTestUtils.getFederationMembersWithBtcKeys(Arrays.asList( BtcECKey.fromPublicOnly(Hex.decode("036bb9eab797eadc8b697f0e82a01d01cabbfaaca37e5bafc06fdc6fdd38af894a")), BtcECKey.fromPublicOnly(Hex.decode("031da807c71c2f303b7f409dd2605b297ac494a563be3b9ca5f52d95a43d183cc5")))), Instant.ofEpochMilli(5005L), @@ -3305,7 +3305,7 @@ private void test_getSpendWallet(boolean isFlyoverCompatible) throws UTXOProvide } private void test_getNoSpendWallet(boolean isFlyoverCompatible) { - Federation federation = new Federation(FederationTestUtils.getFederationMembersWithBtcKeys(Arrays.asList( + Federation federation = new StandardMultisigFederation(FederationTestUtils.getFederationMembersWithBtcKeys(Arrays.asList( BtcECKey.fromPublicOnly(Hex.decode("036bb9eab797eadc8b697f0e82a01d01cabbfaaca37e5bafc06fdc6fdd38af894a")), BtcECKey.fromPublicOnly(Hex.decode("031da807c71c2f303b7f409dd2605b297ac494a563be3b9ca5f52d95a43d183cc5")))), Instant.ofEpochMilli(5005L), @@ -3534,7 +3534,7 @@ private Genesis getGenesisInstance(TrieStore trieStore) { private ErpFederation createErpFederation() { Federation genesisFederation = bridgeConstantsRegtest.getGenesisFederation(); - return new ErpFederation( + return new LegacyErpFederation( genesisFederation.getMembers(), genesisFederation.getCreationTime(), genesisFederation.getCreationBlockNumber(), diff --git a/rskj-core/src/test/java/co/rsk/peg/ErpFederationTest.java b/rskj-core/src/test/java/co/rsk/peg/ErpFederationTest.java index b097cd091bc..7fe20f8a6db 100644 --- a/rskj-core/src/test/java/co/rsk/peg/ErpFederationTest.java +++ b/rskj-core/src/test/java/co/rsk/peg/ErpFederationTest.java @@ -143,7 +143,7 @@ void getErpPubKeys_uncompressed_public_keys() { .collect(Collectors.toList()); // Recreate federation - ErpFederation federationWithUncompressedKeys = new ErpFederation( + ErpFederation federationWithUncompressedKeys = new LegacyErpFederation( FederationTestUtils.getFederationMembersWithBtcKeys(defaultKeys), ZonedDateTime.parse("2017-06-10T02:30:00Z").toInstant(), 0L, @@ -170,7 +170,7 @@ void getErpRedeemScript_compareOtherImplementation() throws IOException { RawGeneratedRedeemScript[] generatedScripts = new ObjectMapper().readValue(rawRedeemScripts, RawGeneratedRedeemScript[].class); for (RawGeneratedRedeemScript generatedScript : generatedScripts) { - Federation erpFederation = new ErpFederation( + Federation erpFederation = new LegacyErpFederation( FederationTestUtils.getFederationMembersWithBtcKeys(generatedScript.mainFed), ZonedDateTime.parse("2017-06-10T02:30:00Z").toInstant(), 0L, @@ -243,7 +243,7 @@ void createInvalidErpFederation_negativeCsvValue() { List federationMembersFromPks = FederationTestUtils.getFederationMembersFromPks(100, 200, 300); Instant creationTime = ZonedDateTime.parse("2017-06-10T02:30:00Z").toInstant(); NetworkParameters btcParams = NetworkParameters.fromID(NetworkParameters.ID_REGTEST); - assertThrows(VerificationException.class, () -> new ErpFederation( + assertThrows(VerificationException.class, () -> new LegacyErpFederation( federationMembersFromPks, creationTime, 0L, @@ -259,7 +259,7 @@ void createInvalidErpFederation_csvValueZero() { List federationMembersFromPks = FederationTestUtils.getFederationMembersFromPks(100, 200, 300); Instant creationTime = ZonedDateTime.parse("2017-06-10T02:30:00Z").toInstant(); NetworkParameters btcParams = NetworkParameters.fromID(NetworkParameters.ID_REGTEST); - assertThrows(VerificationException.class, () -> new ErpFederation( + assertThrows(VerificationException.class, () -> new LegacyErpFederation( federationMembersFromPks, creationTime, 0L, @@ -275,7 +275,7 @@ void createInvalidErpFederation_csvValueAboveMax() { List federationMembersFromPks = FederationTestUtils.getFederationMembersFromPks(100, 200, 300); Instant creationTime = ZonedDateTime.parse("2017-06-10T02:30:00Z").toInstant(); NetworkParameters btcParams = NetworkParameters.fromID(NetworkParameters.ID_REGTEST); - assertThrows(VerificationException.class, () -> new ErpFederation( + assertThrows(VerificationException.class, () -> new LegacyErpFederation( federationMembersFromPks, creationTime, 0L, @@ -291,7 +291,7 @@ void getRedeemScript_before_RSKIP_284_testnet() { ActivationConfig.ForBlock activations = mock(ActivationConfig.ForBlock.class); when(activations.isActive(ConsensusRule.RSKIP284)).thenReturn(false); - Federation erpFederation = new ErpFederation( + Federation erpFederation = new LegacyErpFederation( FederationTestUtils.getFederationMembersFromPks(100, 200, 300), ZonedDateTime.parse("2017-06-10T02:30:00Z").toInstant(), 0L, @@ -309,7 +309,7 @@ void getRedeemScript_before_RSKIP_284_mainnet() { ActivationConfig.ForBlock activations = mock(ActivationConfig.ForBlock.class); when(activations.isActive(ConsensusRule.RSKIP284)).thenReturn(false); - Federation erpFederation = new ErpFederation( + Federation erpFederation = new LegacyErpFederation( FederationTestUtils.getFederationMembersWithBtcKeys(defaultKeys), ZonedDateTime.parse("2017-06-10T02:30:00Z").toInstant(), 0L, @@ -329,7 +329,7 @@ void getRedeemScript_before_RSKIP_284_mainnet() { @Test void getRedeemScript_after_RSKIP_284_testnet() { - Federation erpFederation = new ErpFederation( + Federation erpFederation = new LegacyErpFederation( FederationTestUtils.getFederationMembersWithBtcKeys(defaultKeys), ZonedDateTime.parse("2017-06-10T02:30:00Z").toInstant(), 0L, @@ -349,7 +349,7 @@ void getRedeemScript_after_RSKIP_284_testnet() { @Test void getRedeemScript_after_RSKIP_284_mainnet() { - Federation erpFederation = new ErpFederation( + Federation erpFederation = new LegacyErpFederation( FederationTestUtils.getFederationMembersWithBtcKeys(defaultKeys), ZonedDateTime.parse("2017-06-10T02:30:00Z").toInstant(), 0L, @@ -378,7 +378,7 @@ void testEquals_basic() { @Test void testEquals_same() { - Federation otherFederation = new ErpFederation( + Federation otherFederation = new LegacyErpFederation( federation.getMembers(), federation.getCreationTime(), federation.getCreationBlockNumber(), @@ -393,7 +393,7 @@ void testEquals_same() { @Test void testEquals_differentNumberOfMembers() { - Federation otherFederation = new ErpFederation( + Federation otherFederation = new LegacyErpFederation( FederationTestUtils.getFederationMembersFromPks(100, 200, 300, 400, 500, 600, 700), federation.getCreationTime(), federation.getCreationBlockNumber(), @@ -408,7 +408,7 @@ void testEquals_differentNumberOfMembers() { @Test void testEquals_differentCreationTime() { - Federation otherFederation = new ErpFederation( + Federation otherFederation = new LegacyErpFederation( federation.getMembers(), Instant.now(), federation.getCreationBlockNumber(), @@ -423,7 +423,7 @@ void testEquals_differentCreationTime() { @Test void testEquals_differentCreationBlockNumber() { - Federation otherFederation = new ErpFederation( + Federation otherFederation = new LegacyErpFederation( federation.getMembers(), federation.getCreationTime(), federation.getCreationBlockNumber() + 1, @@ -438,7 +438,7 @@ void testEquals_differentCreationBlockNumber() { @Test void testEquals_differentNetworkParameters() { - Federation otherFederation = new ErpFederation( + Federation otherFederation = new LegacyErpFederation( federation.getMembers(), federation.getCreationTime(), federation.getCreationBlockNumber(), @@ -453,7 +453,7 @@ void testEquals_differentNetworkParameters() { @Test void testEquals_differentMembers() { - Federation otherFederation = new ErpFederation( + Federation otherFederation = new LegacyErpFederation( FederationTestUtils.getFederationMembersFromPks(101, 201, 301), federation.getCreationTime(), federation.getCreationBlockNumber(), @@ -475,7 +475,7 @@ void testEquals_differentRedeemScript() { when(activationsPost.isActive(ConsensusRule.RSKIP284)).thenReturn(true); // Both federations created before RSKIP284 with the same data, should have the same redeem script - Federation erpFederation = new ErpFederation( + Federation erpFederation = new LegacyErpFederation( FederationTestUtils.getFederationMembersFromPks(100, 200, 300), ZonedDateTime.parse("2017-06-10T02:30:00Z").toInstant(), 0L, @@ -485,7 +485,7 @@ void testEquals_differentRedeemScript() { activationsPre ); - Federation otherErpFederation = new ErpFederation( + Federation otherErpFederation = new LegacyErpFederation( FederationTestUtils.getFederationMembersFromPks(100, 200, 300), ZonedDateTime.parse("2017-06-10T02:30:00Z").toInstant(), 0L, @@ -498,7 +498,7 @@ void testEquals_differentRedeemScript() { assertEquals(erpFederation, otherErpFederation); // One federation created after RSKIP284 with the same data, should have different redeem script - otherErpFederation = new ErpFederation( + otherErpFederation = new LegacyErpFederation( FederationTestUtils.getFederationMembersFromPks(100, 200, 300), ZonedDateTime.parse("2017-06-10T02:30:00Z").toInstant(), 0L, @@ -511,7 +511,7 @@ void testEquals_differentRedeemScript() { Assertions.assertNotEquals(erpFederation, otherErpFederation); // The other federation created after RSKIP284 with the same data, should have same redeem script - erpFederation = new ErpFederation( + erpFederation = new LegacyErpFederation( FederationTestUtils.getFederationMembersFromPks(100, 200, 300), ZonedDateTime.parse("2017-06-10T02:30:00Z").toInstant(), 0L, @@ -551,7 +551,7 @@ void createErpFedWithSameRedeemScriptAsHardcodedOne_after_RSKIP293_fails() { List federationMembersWithBtcKeys = FederationTestUtils.getFederationMembersWithBtcKeys(standardMultisigKeys); Instant creationTime = ZonedDateTime.parse("2017-06-10T02:30:00Z").toInstant(); NetworkParameters btcParams = NetworkParameters.fromID(NetworkParameters.ID_TESTNET); - assertThrows(FederationCreationException.class, () -> new ErpFederation( + assertThrows(FederationCreationException.class, () -> new LegacyErpFederation( federationMembersWithBtcKeys, creationTime, 0L, @@ -704,7 +704,7 @@ void spendFromErpFed_after_RSKIP293_mainnet_using_standard_multisig() { private void createErpFederation(BridgeConstants constants, boolean isRskip293Active) { when(activations.isActive(ConsensusRule.RSKIP293)).thenReturn(isRskip293Active); - Federation erpFederation = new ErpFederation( + Federation erpFederation = new LegacyErpFederation( FederationTestUtils.getFederationMembersWithBtcKeys(defaultKeys), ZonedDateTime.parse("2017-06-10T02:30:00Z").toInstant(), 0L, @@ -744,7 +744,7 @@ private void spendFromErpFed( Collections.singletonList(ConsensusRule.RSKIP293); ActivationConfig activations = ActivationConfigsForTest.hop400(except); - ErpFederation erpFed = new ErpFederation( + ErpFederation erpFed = new LegacyErpFederation( FederationMember.getFederationMembersFromKeys(standardKeys), ZonedDateTime.parse("2017-06-10T02:30:00Z").toInstant(), 0L, @@ -777,7 +777,7 @@ private void spendFromErpFed( } private ErpFederation createDefaultErpFederation() { - return new ErpFederation( + return new LegacyErpFederation( FederationTestUtils.getFederationMembersWithBtcKeys(defaultKeys), ZonedDateTime.parse("2017-06-10T02:30:00Z").toInstant(), 0L, diff --git a/rskj-core/src/test/java/co/rsk/peg/FederationSupportTest.java b/rskj-core/src/test/java/co/rsk/peg/FederationSupportTest.java index 42d49ae32b4..8b2b9aa9c5c 100644 --- a/rskj-core/src/test/java/co/rsk/peg/FederationSupportTest.java +++ b/rskj-core/src/test/java/co/rsk/peg/FederationSupportTest.java @@ -74,7 +74,7 @@ void whenNewFederationIsNullThenActiveFederationIsGenesisFederation() { when(provider.getNewFederation()) .thenReturn(null); when(bridgeConstants.getGenesisFederation()) - .thenReturn(genesisFederation); + .thenReturn((StandardMultisigFederation) genesisFederation); assertThat(federationSupport.getActiveFederation(), is(genesisFederation)); } @@ -165,7 +165,7 @@ void getFederatorPublicKeys() { ECKey rskKey1 = new ECKey(); ECKey mstKey1 = new ECKey(); - Federation theFederation = new Federation( + Federation theFederation = new StandardMultisigFederation( Arrays.asList( new FederationMember(btcKey0, rskKey0, mstKey0), new FederationMember(btcKey1, rskKey1, mstKey1) @@ -235,7 +235,7 @@ void getMemberPublicKeyOfType_OutOfBounds() { } private Federation getNewFakeFederation(long creationBlockNumber) { - return new Federation( + return new StandardMultisigFederation( Collections.emptyList(), Instant.ofEpochMilli(123), creationBlockNumber, NetworkParameters.fromID(NetworkParameters.ID_REGTEST) ); diff --git a/rskj-core/src/test/java/co/rsk/peg/FederationTest.java b/rskj-core/src/test/java/co/rsk/peg/FederationTest.java index 5344712c00b..069c090424a 100644 --- a/rskj-core/src/test/java/co/rsk/peg/FederationTest.java +++ b/rskj-core/src/test/java/co/rsk/peg/FederationTest.java @@ -53,7 +53,7 @@ class FederationTest { @BeforeEach void createFederation() { - federation = new Federation( + federation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersFromPks(100, 200, 300, 400, 500, 600), ZonedDateTime.parse("2017-06-10T02:30:00Z").toInstant(), 0L, @@ -178,7 +178,7 @@ void testEquals_basic() { @Test void testEquals_differentNumberOfMembers() { - Federation otherFederation = new Federation( + Federation otherFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersFromPks(100, 200, 300, 400, 500, 600, 700), ZonedDateTime.parse("2017-06-10T02:30:00Z").toInstant(), 0L, @@ -189,7 +189,7 @@ void testEquals_differentNumberOfMembers() { @Test void testEquals_differentCreationTime() { - Federation otherFederation = new Federation( + Federation otherFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersFromPks(100, 200, 300, 400, 500, 600), ZonedDateTime.parse("2017-06-10T02:30:01Z").toInstant(), 0L, @@ -200,7 +200,7 @@ void testEquals_differentCreationTime() { @Test void testEquals_differentCreationBlockNumber() { - Federation otherFederation = new Federation( + Federation otherFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersFromPks(100, 200, 300, 400, 500, 600), ZonedDateTime.parse("2017-06-10T02:30:01Z").toInstant(), 1L, @@ -211,7 +211,7 @@ void testEquals_differentCreationBlockNumber() { @Test void testEquals_differentNetworkParameters() { - Federation otherFederation = new Federation( + Federation otherFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersFromPks(100, 200, 300, 400, 500, 600), ZonedDateTime.parse("2017-06-10T02:30:00Z").toInstant(), 0L, @@ -225,7 +225,7 @@ void testEquals_differentMembers() { List members = FederationTestUtils.getFederationMembersFromPks(100, 200, 300, 400, 500); members.add(new FederationMember(BtcECKey.fromPrivate(BigInteger.valueOf(610)), ECKey.fromPrivate(BigInteger.valueOf(600)), ECKey.fromPrivate(BigInteger.valueOf(620)))); - Federation otherFederation = new Federation( + Federation otherFederation = new StandardMultisigFederation( members, ZonedDateTime.parse("2017-06-10T02:30:00Z").toInstant(), 0L, @@ -234,7 +234,7 @@ void testEquals_differentMembers() { members.remove(members.size()-1); members.add(new FederationMember(BtcECKey.fromPrivate(BigInteger.valueOf(600)), ECKey.fromPrivate(BigInteger.valueOf(610)), ECKey.fromPrivate(BigInteger.valueOf(620)))); - Federation yetOtherFederation = new Federation( + Federation yetOtherFederation = new StandardMultisigFederation( members, ZonedDateTime.parse("2017-06-10T02:30:00Z").toInstant(), 0L, @@ -248,7 +248,7 @@ void testEquals_differentMembers() { @Test void testEquals_same() { - Federation otherFederation = new Federation( + Federation otherFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersFromPks(100, 200, 300, 400, 500, 600), ZonedDateTime.parse("2017-06-10T02:30:00Z").toInstant(), 0L, diff --git a/rskj-core/src/test/java/co/rsk/peg/FederationTestUtils.java b/rskj-core/src/test/java/co/rsk/peg/FederationTestUtils.java index a860b294a8b..bd83f63d2d5 100644 --- a/rskj-core/src/test/java/co/rsk/peg/FederationTestUtils.java +++ b/rskj-core/src/test/java/co/rsk/peg/FederationTestUtils.java @@ -41,7 +41,7 @@ public class FederationTestUtils { public static Federation getFederation(Integer... federationMemberPks) { - return new Federation( + return new StandardMultisigFederation( getFederationMembersFromPks(federationMemberPks), ZonedDateTime.parse("2017-06-10T02:30:01Z").toInstant(), 0L, diff --git a/rskj-core/src/test/java/co/rsk/peg/FlyoverCompatibleBtcWalletWithStorageTest.java b/rskj-core/src/test/java/co/rsk/peg/FlyoverCompatibleBtcWalletWithStorageTest.java index 3fd1d7cbf11..8c2c5567e20 100644 --- a/rskj-core/src/test/java/co/rsk/peg/FlyoverCompatibleBtcWalletWithStorageTest.java +++ b/rskj-core/src/test/java/co/rsk/peg/FlyoverCompatibleBtcWalletWithStorageTest.java @@ -45,14 +45,14 @@ void setup() { ActivationConfig.ForBlock activations = mock(ActivationConfig.ForBlock.class); when(activations.isActive(ConsensusRule.RSKIP284)).thenReturn(true); - federation = new Federation( + federation = new StandardMultisigFederation( FederationTestUtils.getFederationMembers(3), Instant.ofEpochMilli(1000), 0L, NetworkParameters.fromID(NetworkParameters.ID_REGTEST) ); - erpFederation = new ErpFederation( + erpFederation = new LegacyErpFederation( FederationTestUtils.getFederationMembers(3), Instant.ofEpochMilli(1000), 0L, diff --git a/rskj-core/src/test/java/co/rsk/peg/FlyoverCompatibleBtcWallextWithSingleScriptTest.java b/rskj-core/src/test/java/co/rsk/peg/FlyoverCompatibleBtcWallextWithSingleScriptTest.java index 0335d6c70e1..afb20abf11d 100644 --- a/rskj-core/src/test/java/co/rsk/peg/FlyoverCompatibleBtcWallextWithSingleScriptTest.java +++ b/rskj-core/src/test/java/co/rsk/peg/FlyoverCompatibleBtcWallextWithSingleScriptTest.java @@ -41,14 +41,14 @@ void setup() { ActivationConfig.ForBlock activations = mock(ActivationConfig.ForBlock.class); when(activations.isActive(ConsensusRule.RSKIP284)).thenReturn(true); - federation = new Federation( + federation = new StandardMultisigFederation( FederationTestUtils.getFederationMembers(3), Instant.ofEpochMilli(1000), 0L, NetworkParameters.fromID(NetworkParameters.ID_REGTEST) ); - erpFederation = new ErpFederation( + erpFederation = new LegacyErpFederation( FederationTestUtils.getFederationMembers(3), Instant.ofEpochMilli(1000), 0L, diff --git a/rskj-core/src/test/java/co/rsk/peg/PegTestUtils.java b/rskj-core/src/test/java/co/rsk/peg/PegTestUtils.java index a5181a228df..76e19263bd4 100644 --- a/rskj-core/src/test/java/co/rsk/peg/PegTestUtils.java +++ b/rskj-core/src/test/java/co/rsk/peg/PegTestUtils.java @@ -263,7 +263,7 @@ public static Federation createFederation(BridgeConstants bridgeConstants, Strin public static Federation createFederation(BridgeConstants bridgeConstants, List federationKeys) { federationKeys.sort(BtcECKey.PUBKEY_COMPARATOR); - return new Federation( + return new StandardMultisigFederation( FederationTestUtils.getFederationMembersWithBtcKeys(federationKeys), Instant.ofEpochMilli(1000L), 0L, diff --git a/rskj-core/src/test/java/co/rsk/peg/PendingFederationTest.java b/rskj-core/src/test/java/co/rsk/peg/PendingFederationTest.java index 26c80f27b0d..e0b2d77d73c 100644 --- a/rskj-core/src/test/java/co/rsk/peg/PendingFederationTest.java +++ b/rskj-core/src/test/java/co/rsk/peg/PendingFederationTest.java @@ -298,7 +298,7 @@ private void testBuildFederation( activations ); } else if (isRskip201Active) { - expectedFederation = new ErpFederation( + expectedFederation = new LegacyErpFederation( FederationTestUtils.getFederationMembersFromPks(privateKeys), creationTime, 0L, @@ -308,7 +308,7 @@ private void testBuildFederation( activations ); } else { - expectedFederation = new Federation( + expectedFederation = new StandardMultisigFederation( FederationTestUtils.getFederationMembersFromPks(privateKeys), creationTime, 0L, diff --git a/rskj-core/src/test/java/co/rsk/peg/PowpegMigrationTest.java b/rskj-core/src/test/java/co/rsk/peg/PowpegMigrationTest.java index 4e8f0c19797..0a114606cc1 100644 --- a/rskj-core/src/test/java/co/rsk/peg/PowpegMigrationTest.java +++ b/rskj-core/src/test/java/co/rsk/peg/PowpegMigrationTest.java @@ -135,7 +135,7 @@ private void testChangePowpeg( Federation originalPowpeg; switch (oldPowPegFederationType) { case erp: - originalPowpeg = new ErpFederation( + originalPowpeg = new LegacyErpFederation( originalPowpegMembers, Instant.now(), 0, @@ -591,14 +591,14 @@ private void testChangePowpeg( if (oldPowPegFederationType == FederationType.erp || oldPowPegFederationType == FederationType.p2sh){ assertNotEquals(lastRetiredFederationP2SHScript, originalPowpeg.getP2SHScript()); } - assertEquals(lastRetiredFederationP2SHScript, originalPowpeg.getStandardP2SHScript()); + assertEquals(lastRetiredFederationP2SHScript, originalPowpeg instanceof ErpFederation ? ((ErpFederation) originalPowpeg).getStandardP2SHScript() : originalPowpeg.getP2SHScript()); } else { if (oldPowPegFederationType == FederationType.erp || oldPowPegFederationType == FederationType.p2sh){ assertEquals(lastRetiredFederationP2SHScript, originalPowpeg.getP2SHScript()); - assertNotEquals(lastRetiredFederationP2SHScript, originalPowpeg.getStandardP2SHScript()); + assertNotEquals(lastRetiredFederationP2SHScript, originalPowpeg instanceof ErpFederation ? ((ErpFederation) originalPowpeg).getStandardP2SHScript() : originalPowpeg.getP2SHScript()); } else { assertEquals(lastRetiredFederationP2SHScript, originalPowpeg.getP2SHScript()); - assertEquals(lastRetiredFederationP2SHScript, originalPowpeg.getStandardP2SHScript()); + assertEquals(lastRetiredFederationP2SHScript, originalPowpeg instanceof ErpFederation ? ((ErpFederation) originalPowpeg).getStandardP2SHScript() : originalPowpeg.getP2SHScript()); } } } @@ -620,10 +620,10 @@ private void verifyPegouts(BridgeStorageProvider bridgeStorageProvider) throws I Script inputStandardRedeemScript = RedeemScriptParserFactory.get(result.getChunks()).extractStandardRedeemScript(); Optional spendingFederationOptional = Optional.empty(); - if (inputStandardRedeemScript.equals(activeFederation.getStandardRedeemScript())) { + if (inputStandardRedeemScript.equals(activeFederation instanceof ErpFederation ? ((ErpFederation) activeFederation).getStandardRedeemScript() : activeFederation.getRedeemScript())) { spendingFederationOptional = Optional.of(activeFederation); } else if (retiringFederation != null && - inputStandardRedeemScript.equals(retiringFederation.getStandardRedeemScript())) { + inputStandardRedeemScript.equals(retiringFederation instanceof ErpFederation ? ((ErpFederation) retiringFederation).getStandardRedeemScript() : retiringFederation.getRedeemScript()) ) { spendingFederationOptional = Optional.of(retiringFederation); } else { fail("pegout scriptsig does not match any Federation"); diff --git a/rskj-core/src/test/java/co/rsk/peg/ReleaseTransactionBuilderTest.java b/rskj-core/src/test/java/co/rsk/peg/ReleaseTransactionBuilderTest.java index 481f50c57aa..8d2ef553fe8 100644 --- a/rskj-core/src/test/java/co/rsk/peg/ReleaseTransactionBuilderTest.java +++ b/rskj-core/src/test/java/co/rsk/peg/ReleaseTransactionBuilderTest.java @@ -90,7 +90,7 @@ void setup() { @Test void first_output_pay_fees() { - Federation federation = new Federation( + Federation federation = new StandardMultisigFederation( FederationMember.getFederationMembersFromKeys(Arrays.asList( new BtcECKey(), new BtcECKey(), @@ -164,7 +164,7 @@ void build_pegout_tx_from_erp_federation() { // Use mainnet constants to test a real situation BridgeConstants bridgeConstants = BridgeMainNetConstants.getInstance(); - Federation erpFederation = new ErpFederation( + Federation erpFederation = new LegacyErpFederation( FederationMember.getFederationMembersFromKeys(Arrays.asList( new BtcECKey(), new BtcECKey(), diff --git a/rskj-core/src/test/java/co/rsk/peg/performance/ActiveFederationTest.java b/rskj-core/src/test/java/co/rsk/peg/performance/ActiveFederationTest.java index 5ef18a595bc..96b4a111779 100644 --- a/rskj-core/src/test/java/co/rsk/peg/performance/ActiveFederationTest.java +++ b/rskj-core/src/test/java/co/rsk/peg/performance/ActiveFederationTest.java @@ -20,10 +20,7 @@ import co.rsk.bitcoinj.core.BtcECKey; import co.rsk.bitcoinj.store.BtcBlockStore; -import co.rsk.peg.Bridge; -import co.rsk.peg.BridgeStorageProvider; -import co.rsk.peg.Federation; -import co.rsk.peg.FederationMember; +import co.rsk.peg.*; import org.ethereum.TestUtils; import org.ethereum.core.CallTransaction; import org.ethereum.core.Repository; @@ -117,7 +114,7 @@ private BridgeStorageProviderInitializer buildInitializer(boolean genesis) { int numFederators = Helper.randomInRange(minFederators, maxFederators); List members = getNRandomFederationMembers(numFederators); - federation = new Federation( + federation = new StandardMultisigFederation( members, Instant.ofEpochMilli(TestUtils.generateLong(String.valueOf(executionIndex))), Helper.randomInRange(1, 10), diff --git a/rskj-core/src/test/java/co/rsk/peg/performance/RetiringFederationTest.java b/rskj-core/src/test/java/co/rsk/peg/performance/RetiringFederationTest.java index 669478ce058..227f4d13f5a 100644 --- a/rskj-core/src/test/java/co/rsk/peg/performance/RetiringFederationTest.java +++ b/rskj-core/src/test/java/co/rsk/peg/performance/RetiringFederationTest.java @@ -22,6 +22,7 @@ import co.rsk.peg.Bridge; import co.rsk.peg.BridgeStorageProvider; import co.rsk.peg.Federation; +import co.rsk.peg.StandardMultisigFederation; import org.ethereum.core.CallTransaction; import org.ethereum.core.Repository; import org.ethereum.vm.exception.VMException; @@ -103,7 +104,7 @@ private BridgeStorageProviderInitializer buildInitializer(boolean present) { return (BridgeStorageProvider provider, Repository repository, int executionIndex, BtcBlockStore blockStore) -> { if (present) { int numFederators = Helper.randomInRange(minFederators, maxFederators); - retiringFederation = new Federation( + retiringFederation = new StandardMultisigFederation( ActiveFederationTest.getNRandomFederationMembers(numFederators), Instant.ofEpochMilli(random.nextLong()), Helper.randomInRange(1, 10), diff --git a/rskj-core/src/test/java/co/rsk/peg/utils/BridgeEventLoggerImplTest.java b/rskj-core/src/test/java/co/rsk/peg/utils/BridgeEventLoggerImplTest.java index 7876cc65a4e..a83045a72a9 100644 --- a/rskj-core/src/test/java/co/rsk/peg/utils/BridgeEventLoggerImplTest.java +++ b/rskj-core/src/test/java/co/rsk/peg/utils/BridgeEventLoggerImplTest.java @@ -221,7 +221,7 @@ void logCommitFederation(boolean isRSKIP383Active) { List oldFederationMembers = FederationTestUtils.getFederationMembersWithBtcKeys(oldFederationKeys); - Federation oldFederation = new Federation( + Federation oldFederation = new StandardMultisigFederation( oldFederationMembers, Instant.ofEpochMilli(15005L), 15L, @@ -236,7 +236,7 @@ void logCommitFederation(boolean isRSKIP383Active) { List newFederationMembers = FederationTestUtils.getFederationMembersWithBtcKeys(newFederationKeys); - Federation newFederation = new Federation( + Federation newFederation = new StandardMultisigFederation( newFederationMembers, Instant.ofEpochMilli(5005L), 0L, diff --git a/rskj-core/src/test/java/co/rsk/peg/utils/BridgeEventLoggerLegacyImplTest.java b/rskj-core/src/test/java/co/rsk/peg/utils/BridgeEventLoggerLegacyImplTest.java index ea3473dfe26..dfc52e60c63 100644 --- a/rskj-core/src/test/java/co/rsk/peg/utils/BridgeEventLoggerLegacyImplTest.java +++ b/rskj-core/src/test/java/co/rsk/peg/utils/BridgeEventLoggerLegacyImplTest.java @@ -207,7 +207,7 @@ void testLogCommitFederationBeforeRskip146() { List oldFederationMembers = FederationTestUtils.getFederationMembersWithBtcKeys(oldFederationKeys); - Federation oldFederation = new Federation(oldFederationMembers, + Federation oldFederation = new StandardMultisigFederation(oldFederationMembers, Instant.ofEpochMilli(15005L), 15L, NetworkParameters.fromID(NetworkParameters.ID_REGTEST)); List newFederationKeys = Arrays.asList( @@ -218,7 +218,7 @@ void testLogCommitFederationBeforeRskip146() { List newFederationMembers = FederationTestUtils.getFederationMembersWithBtcKeys(newFederationKeys); - Federation newFederation = new Federation( + Federation newFederation = new StandardMultisigFederation( newFederationMembers, Instant.ofEpochMilli(5005L), 0L,