Search in sources :

Example 46 with AccountBuilder

use of co.rsk.test.builders.AccountBuilder in project rskj by rsksmart.

the class TransactionFactoryHelper method createSampleTransaction.

public static Transaction createSampleTransaction(long nonce) {
    Account sender = new AccountBuilder().name("sender").build();
    Account receiver = new AccountBuilder().name("receiver").build();
    Transaction tx = new TransactionBuilder().nonce(nonce).sender(sender).receiver(receiver).value(BigInteger.TEN).build();
    return tx;
}
Also used : Account(org.ethereum.core.Account) Transaction(org.ethereum.core.Transaction) TransactionBuilder(co.rsk.test.builders.TransactionBuilder) AccountBuilder(co.rsk.test.builders.AccountBuilder)

Example 47 with AccountBuilder

use of co.rsk.test.builders.AccountBuilder in project rskj by rsksmart.

the class AccountBuilderTest method createAccountWithNameAsSeed.

@Test
public void createAccountWithNameAsSeed() {
    Account account = new AccountBuilder().name("acc1").build();
    Assert.assertNotNull(account);
    Assert.assertTrue(account.getEcKey().hasPrivKey());
}
Also used : Account(org.ethereum.core.Account) AccountBuilder(co.rsk.test.builders.AccountBuilder) Test(org.junit.Test)

Example 48 with AccountBuilder

use of co.rsk.test.builders.AccountBuilder in project rskj by rsksmart.

the class TransactionBuilderTest method buildTransaction.

@Test
public void buildTransaction() {
    Account sender = new AccountBuilder().name("sender").build();
    Account receiver = new AccountBuilder().name("receiver").build();
    Transaction tx = new TransactionBuilder().sender(sender).receiver(receiver).value(BigInteger.TEN).nonce(2).build();
    Assert.assertNotNull(tx);
    Assert.assertArrayEquals(sender.getAddress().getBytes(), tx.getSender().getBytes());
    Assert.assertArrayEquals(receiver.getAddress().getBytes(), tx.getReceiveAddress().getBytes());
    Assert.assertEquals(BigInteger.TEN, tx.getValue().asBigInteger());
    Assert.assertEquals(BigInteger.ONE, tx.getGasPrice().asBigInteger());
    Assert.assertEquals(BigInteger.valueOf(2), new BigInteger(1, tx.getNonce()));
    Assert.assertEquals(BigInteger.valueOf(21000), new BigInteger(1, tx.getGasLimit()));
    Assert.assertNotNull(tx.getData());
    Assert.assertEquals(0, tx.getData().length);
}
Also used : Account(org.ethereum.core.Account) Transaction(org.ethereum.core.Transaction) TransactionBuilder(co.rsk.test.builders.TransactionBuilder) BigInteger(java.math.BigInteger) AccountBuilder(co.rsk.test.builders.AccountBuilder) Test(org.junit.Test)

Example 49 with AccountBuilder

use of co.rsk.test.builders.AccountBuilder in project rskj by rsksmart.

the class WorldDslProcessor method processAccountNewCommand.

private void processAccountNewCommand(DslCommand cmd) {
    AccountBuilder builder = new AccountBuilder(world);
    String name = cmd.getArgument(0);
    builder.name(name);
    if (cmd.getArity() > 1)
        builder.balance(new Coin(new BigInteger(cmd.getArgument(1))));
    Account account = builder.build();
    world.saveAccount(name, account);
}
Also used : Coin(co.rsk.core.Coin) Account(org.ethereum.core.Account) BigInteger(java.math.BigInteger) AccountBuilder(co.rsk.test.builders.AccountBuilder)

Aggregations

AccountBuilder (co.rsk.test.builders.AccountBuilder)49 Test (org.junit.Test)37 World (co.rsk.test.World)33 BlockBuilder (co.rsk.test.builders.BlockBuilder)26 TransactionBuilder (co.rsk.test.builders.TransactionBuilder)24 Account (org.ethereum.core.Account)14 TransactionPoolImpl (co.rsk.core.bc.TransactionPoolImpl)13 ArrayList (java.util.ArrayList)12 BlockChainImpl (co.rsk.core.bc.BlockChainImpl)10 SimpleEthereum (org.ethereum.rpc.Simples.SimpleEthereum)8 Transaction (org.ethereum.core.Transaction)7 TransactionResultDTO (org.ethereum.rpc.dto.TransactionResultDTO)5 BigInteger (java.math.BigInteger)4 HashMapDB (org.ethereum.datasource.HashMapDB)4 ReceiptStore (org.ethereum.db.ReceiptStore)4 ReceiptStoreImpl (org.ethereum.db.ReceiptStoreImpl)4 RskAddress (co.rsk.core.RskAddress)3 Coin (co.rsk.core.Coin)2 TransactionReceiptDTO (org.ethereum.rpc.dto.TransactionReceiptDTO)2 TestContract (co.rsk.util.TestContract)1