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);
});
}
Aggregations