Search in sources :

Example 21 with RepositoryImpl

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());
}
Also used : Repository(org.ethereum.core.Repository) RepositoryImpl(co.rsk.db.RepositoryImpl) RskAddress(co.rsk.core.RskAddress) Test(org.junit.Test)

Example 22 with RepositoryImpl

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());
}
Also used : Repository(org.ethereum.core.Repository) RepositoryImpl(co.rsk.db.RepositoryImpl) RskAddress(co.rsk.core.RskAddress) Test(org.junit.Test)

Example 23 with RepositoryImpl

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);
}
Also used : Repository(org.ethereum.core.Repository) RepositoryImpl(co.rsk.db.RepositoryImpl) CommonConfig(org.ethereum.config.CommonConfig) Test(org.junit.Test)

Example 24 with 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())));
}
Also used : TrieStoreImpl(co.rsk.trie.TrieStoreImpl) Repository(org.ethereum.core.Repository) RepositoryImpl(co.rsk.db.RepositoryImpl) AccountState(org.ethereum.core.AccountState) HashMapDB(org.ethereum.datasource.HashMapDB) HashMap(java.util.HashMap) Map(java.util.Map) ContractDetails(org.ethereum.db.ContractDetails) Test(org.junit.Test)

Example 25 with RepositoryImpl

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());
}
Also used : TrieStoreImpl(co.rsk.trie.TrieStoreImpl) Repository(org.ethereum.core.Repository) RepositoryImpl(co.rsk.db.RepositoryImpl) HashMapDB(org.ethereum.datasource.HashMapDB) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Aggregations

RepositoryImpl (co.rsk.db.RepositoryImpl)62 Test (org.junit.Test)54 Repository (org.ethereum.core.Repository)25 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)22 RskAddress (co.rsk.core.RskAddress)19 TrieStoreImpl (co.rsk.trie.TrieStoreImpl)16 HashMapDB (org.ethereum.datasource.HashMapDB)15 co.rsk.bitcoinj.core (co.rsk.bitcoinj.core)13 org.ethereum.core (org.ethereum.core)13 BlockGenerator (co.rsk.blockchain.utils.BlockGenerator)12 LogInfo (org.ethereum.vm.LogInfo)12 SimpleRskTransaction (co.rsk.peg.simples.SimpleRskTransaction)11 BridgeConstants (co.rsk.config.BridgeConstants)10 BridgeEventLogger (co.rsk.peg.utils.BridgeEventLogger)10 DataWord (org.ethereum.vm.DataWord)9 ArrayList (java.util.ArrayList)8 BtcBlockStore (co.rsk.bitcoinj.store.BtcBlockStore)7 ECKey (org.ethereum.crypto.ECKey)7 Keccak256 (co.rsk.crypto.Keccak256)6 SimpleBlockChain (co.rsk.peg.simples.SimpleBlockChain)6