Search in sources :

Example 51 with Repository

use of org.ethereum.core.Repository in project rskj by rsksmart.

the class RemascStorageProviderTest method setSaveRetrieveAndGetBurnedBalance.

@Test
public void setSaveRetrieveAndGetBurnedBalance() throws IOException {
    RskAddress accountAddress = randomAddress();
    Repository repository = new RepositoryImplForTesting();
    RemascStorageProvider provider = new RemascStorageProvider(repository, accountAddress);
    provider.setBurnedBalance(Coin.valueOf(255));
    provider.save();
    RemascStorageProvider newProvider = new RemascStorageProvider(repository, accountAddress);
    Assert.assertEquals(Coin.valueOf(255), newProvider.getBurnedBalance());
}
Also used : Repository(org.ethereum.core.Repository) RskAddress(co.rsk.core.RskAddress) RepositoryImplForTesting(co.rsk.db.RepositoryImplForTesting) Test(org.junit.Test)

Example 52 with Repository

use of org.ethereum.core.Repository 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 53 with Repository

use of org.ethereum.core.Repository in project rskj by rsksmart.

the class RemascStorageProviderTest method setSaveRetrieveAndGetBrokenSelectionRule.

@Test
public void setSaveRetrieveAndGetBrokenSelectionRule() throws IOException {
    RskAddress accountAddress = randomAddress();
    Repository repository = new RepositoryImplForTesting();
    RemascStorageProvider provider = new RemascStorageProvider(repository, accountAddress);
    provider.setBrokenSelectionRule(Boolean.TRUE);
    provider.save();
    RemascStorageProvider newProvider = new RemascStorageProvider(repository, accountAddress);
    Assert.assertEquals(Boolean.TRUE, newProvider.getBrokenSelectionRule());
}
Also used : Repository(org.ethereum.core.Repository) RskAddress(co.rsk.core.RskAddress) RepositoryImplForTesting(co.rsk.db.RepositoryImplForTesting) Test(org.junit.Test)

Example 54 with Repository

use of org.ethereum.core.Repository in project rskj by rsksmart.

the class Web3ImplRpcTest method getRpcModules.

@Test
public void getRpcModules() {
    Ethereum eth = Web3Mocks.getMockEthereum();
    Blockchain blockchain = Web3Mocks.getMockBlockchain();
    TransactionPool transactionPool = Web3Mocks.getMockTransactionPool();
    PersonalModule pm = new PersonalModuleWalletDisabled();
    Repository repository = Web3Mocks.getMockRepository();
    Web3Impl web3 = new Web3RskImpl(eth, blockchain, transactionPool, new RskSystemProperties(), null, null, pm, null, null, null, repository, null, null, null, null, null, null, null, null);
    Map<String, String> result = web3.rpc_modules();
    Assert.assertNotNull(result);
    Assert.assertFalse(result.isEmpty());
    Assert.assertTrue(result.containsKey("eth"));
    Assert.assertEquals("1.0", result.get("eth"));
}
Also used : TransactionPool(org.ethereum.core.TransactionPool) Repository(org.ethereum.core.Repository) Ethereum(org.ethereum.facade.Ethereum) Blockchain(org.ethereum.core.Blockchain) PersonalModule(co.rsk.rpc.modules.personal.PersonalModule) Web3Impl(org.ethereum.rpc.Web3Impl) PersonalModuleWalletDisabled(co.rsk.rpc.modules.personal.PersonalModuleWalletDisabled) RskSystemProperties(co.rsk.config.RskSystemProperties) Test(org.junit.Test)

Example 55 with Repository

use of org.ethereum.core.Repository in project rskj by rsksmart.

the class AccountBuilder method build.

public Account build() {
    byte[] privateKeyBytes = HashUtil.keccak256(name.getBytes());
    ECKey key = ECKey.fromPrivate(privateKeyBytes);
    Account account = new Account(key);
    if (blockChain != null) {
        Block best = blockChain.getStatus().getBestBlock();
        BlockDifficulty td = blockChain.getStatus().getTotalDifficulty();
        Repository repository = blockChain.getRepository();
        Repository track = repository.startTracking();
        track.createAccount(account.getAddress());
        if (this.balance != null)
            track.addBalance(account.getAddress(), this.balance);
        if (this.code != null)
            track.saveCode(account.getAddress(), this.code);
        track.commit();
        best.setStateRoot(repository.getRoot());
        best.flushRLP();
        blockChain.getBlockStore().saveBlock(best, td, true);
    }
    return account;
}
Also used : Account(org.ethereum.core.Account) BlockDifficulty(co.rsk.core.BlockDifficulty) Repository(org.ethereum.core.Repository) Block(org.ethereum.core.Block) ECKey(org.ethereum.crypto.ECKey)

Aggregations

Repository (org.ethereum.core.Repository)136 Test (org.junit.Test)109 RskAddress (co.rsk.core.RskAddress)59 DataWord (org.ethereum.vm.DataWord)43 BigInteger (java.math.BigInteger)31 RepositoryImpl (co.rsk.db.RepositoryImpl)25 Coin (co.rsk.core.Coin)23 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)19 HashMapDB (org.ethereum.datasource.HashMapDB)12 BridgeStorageProvider (co.rsk.peg.BridgeStorageProvider)11 Transaction (org.ethereum.core.Transaction)11 InvocationOnMock (org.mockito.invocation.InvocationOnMock)11 TrieStoreImpl (co.rsk.trie.TrieStoreImpl)10 ArrayList (java.util.ArrayList)10 Program (org.ethereum.vm.program.Program)10 Block (org.ethereum.core.Block)9 ProgramInvokeMockImpl (org.ethereum.vm.program.invoke.ProgramInvokeMockImpl)9 RskSystemProperties (co.rsk.config.RskSystemProperties)8 IOException (java.io.IOException)8 List (java.util.List)8