Search in sources :

Example 11 with BridgeStorageProvider

use of co.rsk.peg.BridgeStorageProvider in project rskj by rsksmart.

the class RetiringFederationTest method buildInitializer.

private BridgeStorageProviderInitializer buildInitializer(boolean present) {
    final int minFederators = 10;
    final int maxFederators = 16;
    return (BridgeStorageProvider provider, Repository repository, int executionIndex) -> {
        if (present) {
            int numFederators = Helper.randomInRange(minFederators, maxFederators);
            List<BtcECKey> federatorKeys = new ArrayList<>();
            for (int i = 0; i < numFederators; i++) {
                federatorKeys.add(new BtcECKey());
            }
            retiringFederation = new Federation(federatorKeys, Instant.ofEpochMilli(new Random().nextLong()), Helper.randomInRange(1, 10), networkParameters);
            provider.setNewFederation(bridgeConstants.getGenesisFederation());
            provider.setOldFederation(retiringFederation);
        } else {
            retiringFederation = null;
        }
    };
}
Also used : Repository(org.ethereum.core.Repository) Random(java.util.Random) Federation(co.rsk.peg.Federation) BridgeStorageProvider(co.rsk.peg.BridgeStorageProvider) ArrayList(java.util.ArrayList) List(java.util.List) BtcECKey(co.rsk.bitcoinj.core.BtcECKey)

Aggregations

BridgeStorageProvider (co.rsk.peg.BridgeStorageProvider)11 Repository (org.ethereum.core.Repository)11 IOException (java.io.IOException)5 Random (java.util.Random)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 BtcECKey (co.rsk.bitcoinj.core.BtcECKey)3 BlockStoreException (co.rsk.bitcoinj.store.BlockStoreException)3 BtcBlockStore (co.rsk.bitcoinj.store.BtcBlockStore)3 RskSystemProperties (co.rsk.config.RskSystemProperties)3 Federation (co.rsk.peg.Federation)3 RepositoryBlockStore (co.rsk.peg.RepositoryBlockStore)3 BtcBlockChain (co.rsk.bitcoinj.core.BtcBlockChain)2 Context (co.rsk.bitcoinj.core.Context)2 Script (co.rsk.bitcoinj.script.Script)2 Keccak256 (co.rsk.crypto.Keccak256)2 ReleaseRequestQueue (co.rsk.peg.ReleaseRequestQueue)2 Test (org.junit.Test)2 BtcBlock (co.rsk.bitcoinj.core.BtcBlock)1 Coin (co.rsk.bitcoinj.core.Coin)1