Search in sources :

Example 21 with Account

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

the class ImmutableTransactionTest method createImmutableTransaction.

private static Transaction createImmutableTransaction() {
    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).immutable().build();
    return tx;
}
Also used : Account(org.ethereum.core.Account) ImmutableTransaction(org.ethereum.core.ImmutableTransaction) Transaction(org.ethereum.core.Transaction) TransactionBuilder(co.rsk.test.builders.TransactionBuilder) AccountBuilder(co.rsk.test.builders.AccountBuilder)

Example 22 with Account

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

the class WalletTest method lockAccount.

@Test
public void lockAccount() {
    Wallet wallet = WalletFactory.createWallet();
    byte[] address = wallet.addAccount("passphrase").getBytes();
    Assert.assertNotNull(address);
    Assert.assertTrue(wallet.unlockAccount(new RskAddress(address), "passphrase"));
    Account account = wallet.getAccount(new RskAddress(address));
    Assert.assertNotNull(account);
    Assert.assertArrayEquals(address, account.getAddress().getBytes());
    Assert.assertTrue(wallet.lockAccount(new RskAddress(address)));
    Account account2 = wallet.getAccount(new RskAddress(address));
    Assert.assertNull(account2);
}
Also used : Account(org.ethereum.core.Account) Test(org.junit.Test)

Example 23 with Account

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

the class WalletTest method addAccountWithPassphrase.

@Test
public void addAccountWithPassphrase() {
    Wallet wallet = WalletFactory.createWallet();
    byte[] address = wallet.addAccount("passphrase").getBytes();
    Assert.assertNotNull(address);
    List<byte[]> addresses = wallet.getAccountAddresses();
    Assert.assertNotNull(addresses);
    Assert.assertFalse(addresses.isEmpty());
    Assert.assertEquals(1, addresses.size());
    byte[] addr = addresses.get(0);
    Assert.assertNotNull(addr);
    Assert.assertArrayEquals(address, addr);
    Account account = wallet.getAccount(new RskAddress(address), "passphrase");
    Assert.assertNotNull(account);
    Assert.assertArrayEquals(address, account.getAddress().getBytes());
}
Also used : Account(org.ethereum.core.Account) Test(org.junit.Test)

Example 24 with Account

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

the class WalletTest method addAndUnlockAccountWithPassphraseAndTwoAccountsWithSeed.

@Test
public void addAndUnlockAccountWithPassphraseAndTwoAccountsWithSeed() {
    Wallet wallet = WalletFactory.createWallet();
    RskAddress addr1 = wallet.addAccount("passphrase");
    Assert.assertNotNull(addr1);
    byte[] address2 = wallet.addAccountWithSeed("seed");
    Assert.assertNotNull(address2);
    byte[] address3 = wallet.addAccountWithSeed("seed2");
    Assert.assertNotNull(address3);
    wallet.unlockAccount(addr1, "passphrase", 10000);
    List<byte[]> addresses = wallet.getAccountAddresses();
    Assert.assertNotNull(addresses);
    Assert.assertFalse(addresses.isEmpty());
    Assert.assertEquals(3, addresses.size());
    byte[] addr = addresses.get(0);
    Assert.assertNotNull(addr);
    Assert.assertArrayEquals(address2, addr);
    addr = addresses.get(1);
    Assert.assertNotNull(addr);
    Assert.assertArrayEquals(address3, addr);
    addr = addresses.get(2);
    Assert.assertNotNull(addr);
    Assert.assertArrayEquals(addr1.getBytes(), addr);
    Account account = wallet.getAccount(addr1, "passphrase");
    Assert.assertNotNull(account);
    Assert.assertEquals(addr1, account.getAddress());
}
Also used : Account(org.ethereum.core.Account) Test(org.junit.Test)

Example 25 with Account

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

the class WalletTest method getUnknownAccount.

@Test
public void getUnknownAccount() {
    Wallet wallet = WalletFactory.createWallet();
    RskAddress addr = new RskAddress("0x0000000000000000000000000000000000000023");
    Account account = wallet.getAccount(addr);
    Assert.assertNull(account);
}
Also used : Account(org.ethereum.core.Account) Test(org.junit.Test)

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