Skip to content

Commit

Permalink
fix: no private methods for builders
Browse files Browse the repository at this point in the history
  • Loading branch information
julianlen committed Dec 13, 2024
1 parent f5efbd5 commit c70421e
Showing 1 changed file with 18 additions and 25 deletions.
43 changes: 18 additions & 25 deletions rskj-core/src/test/java/co/rsk/peg/RegisterBtcTransactionIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ void setUp() throws Exception{

Federation federation = P2shErpFederationBuilder.builder().build();
FederationStorageProvider federationStorageProvider = getFederationStorageProvider(track, federation);
federationSupport = getFederationSupport(federationStorageProvider, activations, bridgeConstants.getFederationConstants());
FederationConstants federationConstants = bridgeConstants.getFederationConstants();
federationSupport = FederationSupportBuilder.builder()
.withFederationConstants(federationConstants)
.withFederationStorageProvider(federationStorageProvider)
.withActivations(activations)
.build();

bridgeStorageProvider = new BridgeStorageProvider(track, PrecompiledContracts.BRIDGE_ADDR, bridgeConstants.getBtcParams(), activations);
BtcBlockStoreWithCache.Factory btcBlockStoreFactory = new RepositoryBtcBlockStoreWithCache.Factory(bridgeConstants.getBtcParams(), 100, 100);
Expand All @@ -86,7 +91,18 @@ void setUp() throws Exception{

recreateChainFromPmt(btcBlockStoreWithCache, chainHeight, pmtWithTransactions, btcBlockWithPmtHeight, bridgeConstants.getBtcParams());
bridgeStorageProvider.save();
bridgeSupport = getBridgeSupport(bridgeEventLogger, bridgeStorageProvider, activations, federationSupport, feePerKbSupport, rskExecutionBlock, btcBlockStoreFactory, track, btcLockSenderProvider);
bridgeSupport = bridgeSupportBuilder
.withBridgeConstants(bridgeConstants)
.withProvider(bridgeStorageProvider)
.withActivations(activations)
.withEventLogger(bridgeEventLogger)
.withFederationSupport(federationSupport)
.withFeePerKbSupport(feePerKbSupport)
.withExecutionBlock(rskExecutionBlock)
.withBtcBlockStoreFactory(btcBlockStoreFactory)
.withRepository(track)
.withBtcLockSenderProvider(btcLockSenderProvider)
.build();
}

@Test
Expand Down Expand Up @@ -146,14 +162,6 @@ private static UTXO getUtxo(BtcTransaction bitcoinTransaction, TransactionOutput
);
}

private static FederationSupport getFederationSupport(FederationStorageProvider federationStorageProvider, ActivationConfig.ForBlock activationConfig, FederationConstants federationConstants) {
return FederationSupportBuilder.builder()
.withFederationConstants(federationConstants)
.withFederationStorageProvider(federationStorageProvider)
.withActivations(activationConfig)
.build();
}

private FederationStorageProvider getFederationStorageProvider(Repository track, Federation federation) {
FederationStorageProvider federationStorageProvider = createFederationStorageProvider(track);
federationStorageProvider.setNewFederation(federation);
Expand All @@ -169,21 +177,6 @@ private static FeePerKbSupport getFeePerKbSupport(Repository repository, BridgeC
);
}

private BridgeSupport getBridgeSupport(BridgeEventLoggerImpl bridgeEventLogger, BridgeStorageProvider bridgeStorageProvider, ActivationConfig.ForBlock activationsBeforeForks, FederationSupport federationSupport, FeePerKbSupport feePerKbSupport, Block rskExecutionBlock, BtcBlockStoreWithCache.Factory btcBlockStoreFactory, Repository repository, BtcLockSenderProvider btcLockSenderProvider) {
return bridgeSupportBuilder
.withBridgeConstants(bridgeConstants)
.withProvider(bridgeStorageProvider)
.withEventLogger(bridgeEventLogger)
.withActivations(activationsBeforeForks)
.withFederationSupport(federationSupport)
.withFeePerKbSupport(feePerKbSupport)
.withExecutionBlock(rskExecutionBlock)
.withBtcBlockStoreFactory(btcBlockStoreFactory)
.withRepository(repository)
.withBtcLockSenderProvider(btcLockSenderProvider)
.build();
}

private BtcTransaction createPegInTransaction(Address federationAddress, Coin coin, BtcECKey pubKey) {
BtcTransaction btcTx = new BtcTransaction(btcParams);
btcTx.addInput(BitcoinTestUtils.createHash(0), 0, ScriptBuilder.createInputScript(null, pubKey));
Expand Down

0 comments on commit c70421e

Please sign in to comment.