use of co.rsk.db.RepositoryImpl in project rskj by rsksmart.
the class RemascStorageProviderTest method setAndGetBurnedBalance.
@Test
public void setAndGetBurnedBalance() {
RskAddress accountAddress = randomAddress();
Repository repository = new RepositoryImpl(config);
RemascStorageProvider provider = new RemascStorageProvider(repository, accountAddress);
provider.setBurnedBalance(Coin.valueOf(1));
Assert.assertEquals(Coin.valueOf(1), provider.getBurnedBalance());
}
use of co.rsk.db.RepositoryImpl in project rskj by rsksmart.
the class RemascStorageProviderTest method getDefaultBrokenSelectionRule.
@Test
public void getDefaultBrokenSelectionRule() {
RskAddress accountAddress = randomAddress();
Repository repository = new RepositoryImpl(config);
RemascStorageProvider provider = new RemascStorageProvider(repository, accountAddress);
Assert.assertEquals(Boolean.FALSE, provider.getBrokenSelectionRule());
}
use of co.rsk.db.RepositoryImpl in project rskj by rsksmart.
the class CommonConfigTest method createRepositoryUsingNewRepository.
@Test
public void createRepositoryUsingNewRepository() {
CommonConfig config = new CommonConfig();
Repository repository = config.repository(this.config);
Assert.assertNotNull(repository);
Assert.assertTrue(repository instanceof RepositoryImpl);
}
use of co.rsk.db.RepositoryImpl in project rskj by rsksmart.
the class NetworkStateExporterTest method testContracts.
@Test
public void testContracts() throws Exception {
Repository repository = new RepositoryImpl(config, new TrieStoreImpl(new HashMapDB()));
String address1String = "1000000000000000000000000000000000000000";
RskAddress addr1 = new RskAddress(address1String);
repository.createAccount(addr1);
repository.addBalance(addr1, Coin.valueOf(1L));
repository.increaseNonce(addr1);
ContractDetails contractDetails = new co.rsk.db.ContractDetailsImpl(config);
contractDetails.setCode(new byte[] { 1, 2, 3, 4 });
contractDetails.put(DataWord.ZERO, DataWord.ONE);
contractDetails.putBytes(DataWord.ONE, new byte[] { 5, 6, 7, 8 });
repository.updateContractDetails(addr1, contractDetails);
AccountState accountState = repository.getAccountState(addr1);
accountState.setStateRoot(contractDetails.getStorageHash());
repository.updateAccountState(addr1, accountState);
Map result = writeAndReadJson(repository);
Assert.assertEquals(1, result.keySet().size());
Map address1Value = (Map) result.get(address1String);
Assert.assertEquals(3, address1Value.keySet().size());
Assert.assertEquals("1", address1Value.get("balance"));
Assert.assertEquals("1", address1Value.get("nonce"));
Map contract = (Map) address1Value.get("contract");
Assert.assertEquals(2, contract.keySet().size());
Assert.assertEquals("01020304", contract.get("code"));
Map data = (Map) contract.get("data");
Assert.assertEquals(2, data.keySet().size());
Assert.assertEquals("01", data.get(Hex.toHexString(DataWord.ZERO.getData())));
Assert.assertEquals("05060708", data.get(Hex.toHexString(DataWord.ONE.getData())));
}
use of co.rsk.db.RepositoryImpl in project rskj by rsksmart.
the class NetworkStateExporterTest method testEmptyRepo.
@Test
public void testEmptyRepo() throws Exception {
Repository repository = new RepositoryImpl(config, new TrieStoreImpl(new HashMapDB()));
Map result = writeAndReadJson(repository);
Assert.assertEquals(0, result.keySet().size());
}
Aggregations