use of co.rsk.test.World in project rskj by rsksmart.
the class SimpleNode method createNode.
public static SimpleNode createNode() {
final World world = new World();
BlockChainImpl blockChain = world.getBlockChain();
NodeMessageHandler handler = NodeMessageHandlerUtil.createHandler(blockChain);
return new SimpleNode(handler, blockChain);
}
use of co.rsk.test.World in project rskj by rsksmart.
the class RskForksBridgeTest method before.
@Before
public void before() {
world = new World();
blockChain = world.getBlockChain();
blockStore = world.getBlockStore();
repositoryLocator = world.getRepositoryLocator();
trieStore = world.getTrieStore();
repository = world.getRepository();
bridgeSupportFactory = world.getBridgeSupportFactory();
whitelistManipulationKey = ECKey.fromPrivate(Hex.decode("3890187a3071327cee08467ba1b44ed4c13adb2da0d5ffcc0563c371fa88259c"));
genesis = (Genesis) blockChain.getBestBlock();
// keyHoldingRSKs = new ECKey();
co.rsk.core.Coin balance = new co.rsk.core.Coin(new BigInteger("10000000000000000000"));
repository.addBalance(new RskAddress(fedECPrivateKey.getAddress()), balance);
co.rsk.core.Coin bridgeBalance = co.rsk.core.Coin.fromBitcoin(BridgeRegTestConstants.getInstance().getMaxRbtc());
repository.addBalance(PrecompiledContracts.BRIDGE_ADDR, bridgeBalance);
genesis.setStateRoot(repository.getRoot());
genesis.flushRLP();
blockStore.saveBlock(genesis, genesis.getCumulativeDifficulty(), true);
Transaction whitelistAddressTx = buildWhitelistTx();
Transaction receiveHeadersTx = buildReceiveHeadersTx();
Transaction registerBtctransactionTx = buildRegisterBtcTransactionTx();
blockBase = buildBlock(genesis, whitelistAddressTx, receiveHeadersTx, registerBtctransactionTx);
Assert.assertEquals(ImportResult.IMPORTED_BEST, blockChain.tryToConnect(blockBase));
}
use of co.rsk.test.World in project rskj by rsksmart.
the class RevertOpCodeTest method runAndRevertThenRunFullContract.
@Test
public void runAndRevertThenRunFullContract() throws FileNotFoundException, DslProcessorException {
DslParser parser = DslParser.fromResource("dsl/opcode_revert2.txt");
World world = new World();
WorldDslProcessor processor = new WorldDslProcessor(world);
processor.processCommands(parser);
Assert.assertNotNull(world.getAccountByName("acc1"));
Assert.assertTrue(world.getTransactionByName("contract_with_revert").isContractCreation());
Assert.assertTrue(!world.getTransactionByName("tx02").isContractCreation());
Assert.assertTrue(!world.getTransactionByName("tx03").isContractCreation());
}
use of co.rsk.test.World in project rskj by rsksmart.
the class BridgeTest method callUpdateCollectionsWithTransactionsWaitingForConfirmationWithEnoughConfirmations.
@Test
public void callUpdateCollectionsWithTransactionsWaitingForConfirmationWithEnoughConfirmations() throws IOException {
BtcTransaction tx1 = createTransaction();
BtcTransaction tx2 = createTransaction();
BtcTransaction tx3 = createTransaction();
Repository repository = new RepositoryImpl(config);
Repository track = repository.startTracking();
BridgeStorageProvider provider0 = new BridgeStorageProvider(track, PrecompiledContracts.BRIDGE_ADDR, config.getBlockchainConfig().getCommonConstants().getBridgeConstants());
provider0.getReleaseTransactionSet().add(tx1, 1L);
provider0.getReleaseTransactionSet().add(tx2, 2L);
provider0.getReleaseTransactionSet().add(tx3, 3L);
provider0.save();
track.commit();
track = repository.startTracking();
World world = new World();
List<Block> blocks = new BlockGenerator().getSimpleBlockChain(world.getBlockChain().getBestBlock(), 10);
Transaction rskTx = Transaction.create(config, PrecompiledContracts.BRIDGE_ADDR_STR, AMOUNT, NONCE, GAS_PRICE, GAS_LIMIT, DATA);
rskTx.sign(new ECKey().getPrivKeyBytes());
world.getBlockChain().getBlockStore().saveBlock(blocks.get(1), new BlockDifficulty(BigInteger.ONE), true);
Bridge bridge = new Bridge(config, PrecompiledContracts.BRIDGE_ADDR);
bridge.init(rskTx, blocks.get(9), track, world.getBlockChain().getBlockStore(), null, new LinkedList<>());
bridge.execute(Bridge.UPDATE_COLLECTIONS.encode());
track.commit();
BridgeStorageProvider provider = new BridgeStorageProvider(repository, PrecompiledContracts.BRIDGE_ADDR, config.getBlockchainConfig().getCommonConstants().getBridgeConstants());
Assert.assertEquals(2, provider.getReleaseTransactionSet().getEntries().size());
Assert.assertEquals(1, provider.getRskTxsWaitingForSignatures().size());
}
use of co.rsk.test.World in project rskj by rsksmart.
the class RskForksBridgeTest method buildBlock.
private Block buildBlock(Block parent, long difficulty) {
World world = new World(blockChain, genesis);
BlockBuilder blockBuilder = new BlockBuilder(world).difficulty(difficulty).parent(parent);
return blockBuilder.build();
}
Aggregations