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());
}
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());
}
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());
}
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"));
}
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;
}
Aggregations