use of co.rsk.db.RepositorySnapshot in project rskj by rsksmart.
the class WorldDslProcessorTest method processAccountNewCommandWithBalance.
@Test
public void processAccountNewCommandWithBalance() throws DslProcessorException {
World world = new World();
WorldDslProcessor processor = new WorldDslProcessor(world);
DslParser parser = new DslParser("account_new acc1 1000000");
processor.processCommands(parser);
Account account = world.getAccountByName("acc1");
Assert.assertNotNull(account);
RepositorySnapshot repository = world.getRepositoryLocator().snapshotAt(world.getBlockChain().getBestBlock().getHeader());
Assert.assertEquals(new BigInteger("1000000"), repository.getBalance(account.getAddress()).asBigInteger());
}
use of co.rsk.db.RepositorySnapshot in project rskj by rsksmart.
the class WorldDslProcessorTest method processAccountNewCommandWithBalanceAndCodeWithOtherAccountAddress.
@Test
public void processAccountNewCommandWithBalanceAndCodeWithOtherAccountAddress() throws DslProcessorException {
World world = new World();
WorldDslProcessor processor = new WorldDslProcessor(world);
DslParser parser0 = new DslParser("account_new acc0");
processor.processCommands(parser0);
DslParser parser = new DslParser("account_new acc1 1000000 0102[acc0]0304");
processor.processCommands(parser);
Account account0 = world.getAccountByName("acc0");
Account account = world.getAccountByName("acc1");
Assert.assertNotNull(account);
RepositorySnapshot repository = world.getRepositoryLocator().snapshotAt(world.getBlockChain().getBestBlock().getHeader());
Assert.assertEquals(new BigInteger("1000000"), repository.getBalance(account.getAddress()).asBigInteger());
byte[] code = repository.getCode(account.getAddress());
byte[] expected = new byte[4 + 20];
expected[0] = 0x01;
expected[1] = 0x02;
System.arraycopy(account0.getAddress().getBytes(), 0, expected, 2, Address.LENGTH);
expected[22] = 0x03;
expected[23] = 0x04;
Assert.assertNotNull(code);
Assert.assertArrayEquals(expected, code);
}
Aggregations