use of co.rsk.db.RepositoryLocator in project rskj by rsksmart.
the class RemascProcessMinerFeesTest method oneSiblingIncludedOneBlockLaterAndAnotherIncludedRightAfter.
@Test
public void oneSiblingIncludedOneBlockLaterAndAnotherIncludedRightAfter() {
RskSystemProperties config = spy(new TestSystemProperties());
when(config.getActivationConfig()).thenReturn(ActivationConfigsForTest.allBut(ConsensusRule.RSKIP85));
BlockChainBuilder builder = new BlockChainBuilder().setTesting(true).setGenesis(genesisBlock).setConfig(config);
List<SiblingElement> siblings = Arrays.asList(new SiblingElement(5, 6, this.minerFee), new SiblingElement(5, 7, this.minerFee));
RemascTestRunner testRunner = new RemascTestRunner(builder, this.genesisBlock).txValue(txValue).minerFee(this.minerFee).initialHeight(15).siblingElements(siblings).txSigningKey(this.cowKey).gasPrice(1L);
testRunner.start();
Blockchain blockchain = testRunner.getBlockChain();
RepositoryLocator repositoryLocator = builder.getRepositoryLocator();
RepositorySnapshot repository = repositoryLocator.snapshotAt(blockchain.getBestBlock().getHeader());
Block blockAtHeightSix = blockchain.getBlockByNumber(7);
assertEquals(Coin.valueOf(840L - 9L), testRunner.getAccountBalance(blockAtHeightSix.getCoinbase()));
Block blockAtHeightSeven = blockchain.getBlockByNumber(8);
assertEquals(Coin.valueOf(840L - 9L), testRunner.getAccountBalance(blockAtHeightSeven.getCoinbase()));
Block blockAtHeightFiveMainchain = blockchain.getBlockByNumber(6);
assertEquals(Coin.valueOf(5040L - 51L), testRunner.getAccountBalance(blockAtHeightFiveMainchain.getCoinbase()));
Block blockAtHeightFiveFirstSibling = testRunner.getAddedSiblings().get(0);
assertEquals(Coin.valueOf(5040L - 51L), testRunner.getAccountBalance(blockAtHeightFiveFirstSibling.getCoinbase()));
Block blockAtHeightFiveSecondSibling = testRunner.getAddedSiblings().get(1);
assertEquals(Coin.valueOf(4788L - 48L), testRunner.getAccountBalance(blockAtHeightFiveSecondSibling.getCoinbase()));
this.validateRemascsStorageIsCorrect(getRemascStorageProvider(repository), Coin.valueOf(84000L), Coin.valueOf(252L), 0L);
}
use of co.rsk.db.RepositoryLocator in project rskj by rsksmart.
the class WorldDslProcessor method processBlockChainCommand.
private void processBlockChainCommand(DslCommand cmd) {
Block parent = world.getBlockByName(cmd.getArgument(0));
int k = 1;
while (cmd.getArgument(k) != null) {
String name = cmd.getArgument(k);
int difficulty = k;
if (name != null) {
StringTokenizer difficultyTokenizer = new StringTokenizer(name, ":");
name = difficultyTokenizer.nextToken();
difficulty = difficultyTokenizer.hasMoreTokens() ? parseDifficulty(difficultyTokenizer.nextToken(), k) : k;
}
Block block = blockBuilder.difficulty(difficulty).parent(parent).build();
final ProgramInvokeFactoryImpl programInvokeFactory = new ProgramInvokeFactoryImpl();
final TestSystemProperties config = new TestSystemProperties();
StateRootHandler stateRootHandler = new StateRootHandler(config.getActivationConfig(), new StateRootsStoreImpl(new HashMapDB()));
BlockExecutor executor = new BlockExecutor(config.getActivationConfig(), new RepositoryLocator(world.getTrieStore(), stateRootHandler), new TransactionExecutorFactory(config, world.getBlockStore(), null, new BlockFactory(config.getActivationConfig()), programInvokeFactory, null, world.getBlockTxSignatureCache()));
executor.executeAndFill(block, parent.getHeader());
world.saveBlock(name, block);
parent = block;
k++;
}
}
use of co.rsk.db.RepositoryLocator in project rskj by rsksmart.
the class BlockchainVMTest method createNewBlockchain.
private static NewBlockChainInfo createNewBlockchain() {
World world = new World();
NewBlockChainInfo binfo = new NewBlockChainInfo();
binfo.faucetKey = createFaucetAccount(world);
binfo.blockchain = world.getBlockChain();
binfo.repository = world.getRepository();
binfo.repositoryLocator = new RepositoryLocator(world.getTrieStore(), world.getStateRootHandler());
return binfo;
}
Aggregations