Search in sources :

Example 6 with Account

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

the class TransactionPoolImplTest method rejectTransactionPoolTransaction.

@Test
public void rejectTransactionPoolTransaction() {
    BlockChainImpl blockchain = createBlockchain();
    Coin balance = Coin.valueOf(1000000);
    TransactionPoolImpl transactionPool = createSampleNewTransactionPoolWithAccounts(2, balance, blockchain);
    transactionPool.processBest(blockchain.getBestBlock());
    Transaction tx = createSampleTransaction(1, 2, 1000, 0);
    tx.setGasLimit(BigInteger.valueOf(3000001).toByteArray());
    Account receiver = createAccount(2);
    transactionPool.addTransaction(tx);
    Repository repository = transactionPool.getRepository();
    Assert.assertEquals(BigInteger.valueOf(1000000), repository.getBalance(receiver.getAddress()).asBigInteger());
}
Also used : Coin(co.rsk.core.Coin) Account(org.ethereum.core.Account) Repository(org.ethereum.core.Repository) Transaction(org.ethereum.core.Transaction) Test(org.junit.Test)

Example 7 with Account

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

the class TransactionPoolImplTest method usingAccountsWithInitialBalance.

@Test
public void usingAccountsWithInitialBalance() {
    TransactionPoolImpl transactionPool = createSampleNewTransactionPoolWithAccounts(2, Coin.valueOf(10L), createBlockchain());
    Repository repository = transactionPool.getRepository();
    Assert.assertNotNull(repository);
    Account account1 = createAccount(1);
    Account account2 = createAccount(2);
    Assert.assertEquals(BigInteger.TEN, repository.getBalance(account1.getAddress()).asBigInteger());
    Assert.assertEquals(BigInteger.TEN, repository.getBalance(account2.getAddress()).asBigInteger());
}
Also used : Account(org.ethereum.core.Account) Repository(org.ethereum.core.Repository) Test(org.junit.Test)

Example 8 with Account

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

the class TransactionPoolImplTest method updateTransactionPool.

@Test
public void updateTransactionPool() {
    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);
    transactionPool.updateState();
    Repository repository = transactionPool.getRepository();
    Assert.assertEquals(BigInteger.valueOf(1004000), repository.getBalance(receiver.getAddress()).asBigInteger());
}
Also used : Coin(co.rsk.core.Coin) Account(org.ethereum.core.Account) Repository(org.ethereum.core.Repository) Transaction(org.ethereum.core.Transaction) Test(org.junit.Test)

Example 9 with Account

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

the class TransactionPoolImplTest method addAndExecutePendingTransaction.

@Test
public void addAndExecutePendingTransaction() {
    BlockChainImpl blockchain = createBlockchain();
    Coin balance = Coin.valueOf(1000000);
    TransactionPoolImpl transactionPool = createSampleNewTransactionPoolWithAccounts(2, balance, blockchain);
    transactionPool.processBest(blockchain.getBestBlock());
    Transaction tx = createSampleTransaction(1, 2, 1000, 0);
    Account receiver = createAccount(2);
    transactionPool.addTransaction(tx);
    Repository repository = transactionPool.getRepository();
    Assert.assertEquals(BigInteger.valueOf(1001000), repository.getBalance(receiver.getAddress()).asBigInteger());
}
Also used : Coin(co.rsk.core.Coin) Account(org.ethereum.core.Account) Repository(org.ethereum.core.Repository) Transaction(org.ethereum.core.Transaction) Test(org.junit.Test)

Example 10 with Account

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

the class TxPoolModuleImplTest method getAccount.

private Account getAccount(int naccount) {
    Account account = accountMap.get(naccount);
    if (account != null) {
        return account;
    }
    account = createAccount(naccount);
    accountMap.put(naccount, account);
    return account;
}
Also used : Account(org.ethereum.core.Account)

Aggregations

Account (org.ethereum.core.Account)49 Test (org.junit.Test)29 Transaction (org.ethereum.core.Transaction)20 AccountBuilder (co.rsk.test.builders.AccountBuilder)14 TransactionBuilder (co.rsk.test.builders.TransactionBuilder)10 BigInteger (java.math.BigInteger)9 World (co.rsk.test.World)8 Coin (co.rsk.core.Coin)7 DslParser (co.rsk.test.dsl.DslParser)7 WorldDslProcessor (co.rsk.test.dsl.WorldDslProcessor)7 Repository (org.ethereum.core.Repository)7 RskAddress (co.rsk.core.RskAddress)5 ECKey (org.ethereum.crypto.ECKey)4 Block (org.ethereum.core.Block)2 BlockDifficulty (co.rsk.core.BlockDifficulty)1 Nullable (javax.annotation.Nullable)1 Bloom (org.ethereum.core.Bloom)1 ImmutableTransaction (org.ethereum.core.ImmutableTransaction)1 TransactionsMessage (org.ethereum.net.eth.message.TransactionsMessage)1 JsonRpcInvalidParamException (org.ethereum.rpc.exception.JsonRpcInvalidParamException)1