Search in sources :

Example 1 with RepositoryBtcBlockStoreWithCache

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

the class ReceiveHeadersTest method doReceiveHeaders.

private ExecutionStats doReceiveHeaders(String caseName, int times, int numHeaders, int forkDepth) throws VMException {
    String name = String.format("%s-forkdepth-%d-headers-%d", caseName, forkDepth, numHeaders);
    ExecutionStats stats = new ExecutionStats(name);
    int totalHeaders = numHeaders + forkDepth;
    return executeAndAverage(name, times, generateABIEncoder(totalHeaders, totalHeaders, forkDepth), buildInitializer(1000, 2000), Helper.getZeroValueTxBuilder(Helper.getRandomFederatorECKey()), Helper.getRandomHeightProvider(10), stats, (EnvironmentBuilder.Environment environment, byte[] result) -> {
        BridgeStorageProvider bridgeStorageProvider = new BridgeStorageProvider((Repository) environment.getBenchmarkedRepository(), PrecompiledContracts.BRIDGE_ADDR, constants.getBridgeConstants(), activationConfig.forBlock(0));
        btcBlockStore = new RepositoryBtcBlockStoreWithCache(BridgeRegTestConstants.getInstance().getBtcParams(), (Repository) environment.getBenchmarkedRepository(), new HashMap<>(), PrecompiledContracts.BRIDGE_ADDR, bridgeConstants, bridgeStorageProvider, activationConfig.forBlock(0));
        Sha256Hash bestBlockHash = null;
        try {
            bestBlockHash = btcBlockStore.getChainHead().getHeader().getHash();
        } catch (BlockStoreException e) {
            Assert.fail(e.getMessage());
        }
        Assert.assertEquals(expectedBestBlock.getHash(), bestBlockHash);
    });
}
Also used : RepositoryBtcBlockStoreWithCache(co.rsk.peg.RepositoryBtcBlockStoreWithCache) Repository(org.ethereum.core.Repository) BlockStoreException(co.rsk.bitcoinj.store.BlockStoreException) HashMap(java.util.HashMap) BridgeStorageProvider(co.rsk.peg.BridgeStorageProvider) Sha256Hash(co.rsk.bitcoinj.core.Sha256Hash)

Aggregations

Sha256Hash (co.rsk.bitcoinj.core.Sha256Hash)1 BlockStoreException (co.rsk.bitcoinj.store.BlockStoreException)1 BridgeStorageProvider (co.rsk.peg.BridgeStorageProvider)1 RepositoryBtcBlockStoreWithCache (co.rsk.peg.RepositoryBtcBlockStoreWithCache)1 HashMap (java.util.HashMap)1 Repository (org.ethereum.core.Repository)1