use of org.ethereum.core.Account in project rskj by rsksmart.
the class WalletTest method addAccountWithRandomPrivateKey.
@Test
public void addAccountWithRandomPrivateKey() {
Wallet wallet = WalletFactory.createWallet();
byte[] address = wallet.addAccount().getBytes();
Assert.assertNotNull(address);
Account account = wallet.getAccount(new RskAddress(address));
Assert.assertNotNull(account);
Assert.assertArrayEquals(address, account.getAddress().getBytes());
}
use of org.ethereum.core.Account in project rskj by rsksmart.
the class Wallet method addAccount.
public RskAddress addAccount() {
Account account = new Account(new ECKey());
saveAccount(account);
return account.getAddress();
}
use of org.ethereum.core.Account in project rskj by rsksmart.
the class WriterMessageRecorderTest method createEthMessage.
public static Message createEthMessage() {
Account acc1 = new AccountBuilder().name("acc1").build();
Account acc2 = new AccountBuilder().name("acc2").build();
Transaction tx = new co.rsk.test.builders.TransactionBuilder().sender(acc1).receiver(acc2).value(BigInteger.valueOf(1000000)).build();
return new TransactionsMessage(config, tx);
}
use of org.ethereum.core.Account in project rskj by rsksmart.
the class TransactionPoolImplTest method addAndExecuteTwoPendingTransaction.
@Test
public void addAndExecuteTwoPendingTransaction() {
BlockChainImpl blockchain = createBlockchain();
Coin balance = Coin.valueOf(1000000);
TransactionPoolImpl transactionPool = createSampleNewTransactionPoolWithAccounts(2, balance, blockchain);
transactionPool.processBest(blockchain.getBestBlock());
Transaction tx1 = createSampleTransaction(1, 2, 1000, 0);
Transaction tx2 = createSampleTransaction(1, 2, 3000, 1);
Account receiver = createAccount(2);
transactionPool.addTransaction(tx1);
transactionPool.addTransaction(tx2);
Repository repository = transactionPool.getRepository();
Assert.assertEquals(BigInteger.valueOf(1004000), repository.getBalance(receiver.getAddress()).asBigInteger());
}
use of org.ethereum.core.Account in project rskj by rsksmart.
the class TransactionPoolImplTest method createSampleNewTransactionPoolWithAccounts.
private static TransactionPoolImpl createSampleNewTransactionPoolWithAccounts(int naccounts, Coin balance, BlockChainImpl blockChain) {
Block best = blockChain.getStatus().getBestBlock();
Repository repository = blockChain.getRepository();
Repository track = repository.startTracking();
for (int k = 1; k <= naccounts; k++) {
Account account = createAccount(k);
track.createAccount(account.getAddress());
track.addBalance(account.getAddress(), balance);
}
track.commit();
best.setStateRoot(repository.getRoot());
best.flushRLP();
TransactionPoolImpl transactionPool = new TransactionPoolImpl(config, blockChain.getRepository(), blockChain.getBlockStore(), null, new ProgramInvokeFactoryImpl(), new BlockExecutorTest.SimpleEthereumListener(), 10, 100);
blockChain.setTransactionPool(transactionPool);
return transactionPool;
}
Aggregations