Skip to content

Commit

Permalink
- Renamed testing erp federation
Browse files Browse the repository at this point in the history
- Set a constant value as creation time for the erp federation
  • Loading branch information
nathanieliov authored and marcos-iov committed Jun 6, 2024
1 parent 42ac32d commit 2759629
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class BridgeSupportPegoutTransactionCreatedEventTest {

private static final BridgeConstants bridgeMainnetConstants = BridgeMainNetConstants.getInstance();
private static final NetworkParameters btcMainnetParams = bridgeMainnetConstants.getBtcParams();
private static final ErpFederation TEST_ERP_FEDERATION = FederationTestUtils.getTestGenesisErpFederation(btcMainnetParams);
private static final ErpFederation ERP_FEDERATION = FederationTestUtils.getErpFederation(btcMainnetParams);

private BridgeStorageProvider provider;
private BridgeEventLogger eventLogger;
Expand All @@ -78,15 +78,15 @@ void init() throws IOException {

List<UTXO> fedUTXOs = createUTXOs(
10,
TEST_ERP_FEDERATION.getAddress()
ERP_FEDERATION.getAddress()
);
when(provider.getNewFederationBtcUTXOs())
.thenReturn(fedUTXOs);
when(provider.getNewFederation())
.thenReturn(TEST_ERP_FEDERATION);
.thenReturn(ERP_FEDERATION);

BlockGenerator blockGenerator = new BlockGenerator();
rskCurrentBlock = blockGenerator.createBlock(TEST_ERP_FEDERATION.getCreationBlockNumber(), 1);
rskCurrentBlock = blockGenerator.createBlock(ERP_FEDERATION.getCreationBlockNumber(), 1);

pegoutCreationRskTxHash = PegTestUtils.createHash3(1);
executionRskTx = mock(Transaction.class);
Expand Down Expand Up @@ -152,7 +152,7 @@ void updateCollections_whenPegoutMigrationIsCreated_shouldLogPegoutTransactionCr

PegoutsWaitingForConfirmations pegoutsWaitingForConfirmations = provider.getPegoutsWaitingForConfirmations();

Federation oldFederation = TEST_ERP_FEDERATION;
Federation oldFederation = ERP_FEDERATION;
when(provider.getOldFederation())
.thenReturn(oldFederation);

Expand Down Expand Up @@ -226,7 +226,7 @@ void updateCollections_whenPegoutMigrationAndBatchAreCreated_shouldLogPegoutTran
when(provider.getReleaseRequestQueue())
.thenReturn(new ReleaseRequestQueue(pegoutRequests));

Federation oldFederation = TEST_ERP_FEDERATION;
Federation oldFederation = ERP_FEDERATION;
when(provider.getOldFederation())
.thenReturn(oldFederation);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class UtxoUtilsTest {
private final static Coin MAX_BTC = BridgeMainNetConstants.getInstance().getMaxRbtc();
private static final BridgeConstants bridgeMainnetConstants = BridgeMainNetConstants.getInstance();
private static final NetworkParameters btcMainnetParams = bridgeMainnetConstants.getBtcParams();
private static final ErpFederation TEST_ERP_FEDERATION = FederationTestUtils.getTestGenesisErpFederation(btcMainnetParams);
private static final ErpFederation TEST_ERP_FEDERATION = FederationTestUtils.getErpFederation(btcMainnetParams);
private static final int FIRST_OUTPUT_INDEX = 0;
private static final Address testAddress = BitcoinTestUtils.createP2PKHAddress(btcMainnetParams, "test");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import co.rsk.bitcoinj.script.ScriptBuilder;
import co.rsk.peg.bitcoin.BitcoinTestUtils;
import java.math.BigInteger;
import java.time.Duration;
import java.time.Instant;
import java.time.ZonedDateTime;
import java.util.ArrayList;
Expand All @@ -48,23 +47,20 @@ public final class FederationTestUtils {
private FederationTestUtils() {
}

public static final List<BtcECKey> TEST_GENESIS_FED_SIGNERS = BitcoinTestUtils.getBtcEcKeysFromSeeds(
new String[]{"fa01", "fa02", "fa03", "fa04", "fa05", "fa06", "fa07", "fa08", "fa09"}, true
);

public static List<BtcECKey> TEST_GENESIS_ERP_SIGNERS = BitcoinTestUtils.getBtcEcKeysFromSeeds(
new String[]{"fb01", "fb02", "fb03"}, true
);
public static ErpFederation getErpFederation(NetworkParameters networkParameters) {
final List<BtcECKey> fedSigners = BitcoinTestUtils.getBtcEcKeysFromSeeds(
new String[]{"fa01", "fa02", "fa03", "fa04", "fa05", "fa06", "fa07", "fa08", "fa09"}, true
);
final List<BtcECKey> erpSigners = BitcoinTestUtils.getBtcEcKeysFromSeeds(
new String[]{"fb01", "fb02", "fb03"}, true
);

public static ErpFederation getTestGenesisErpFederation(NetworkParameters networkParameters) {
List<FederationMember> fedMember = FederationTestUtils.getFederationMembersWithBtcKeys(
TEST_GENESIS_FED_SIGNERS);

Instant fedCreationTime30daysAgo = Instant.now().minus(Duration.ofDays(30));
fedSigners);

FederationArgs federationArgs = new FederationArgs(
fedMember,
fedCreationTime30daysAgo,
ZonedDateTime.parse("1970-01-18T12:49:08.400Z").toInstant(),
0,
networkParameters
);
Expand All @@ -73,7 +69,7 @@ public static ErpFederation getTestGenesisErpFederation(NetworkParameters networ

return FederationFactory.buildP2shErpFederation(
federationArgs,
TEST_GENESIS_ERP_SIGNERS,
erpSigners,
erpFedActivationDelay
);
}
Expand Down

0 comments on commit 2759629

Please sign in to comment.