Search in sources :

Example 86 with Transaction

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

the class MinerUtilsTest method validTransactionAccWrapNonceTest.

@Test
public void validTransactionAccWrapNonceTest() {
    Transaction tx = Tx.create(config, 0, 50000, 5, 1, 0, 0);
    // Mockito.when(tx.checkGasPrice(Mockito.any(BigInteger.class))).thenReturn(true);
    List<Transaction> txs = new LinkedList<>();
    txs.add(tx);
    Map<RskAddress, BigInteger> accountNounces = new HashMap();
    accountNounces.put(tx.getSender(), BigInteger.valueOf(0));
    Repository repository = Mockito.mock(Repository.class);
    Coin minGasPrice = Coin.valueOf(1L);
    List<Transaction> res = new MinerUtils().filterTransactions(new LinkedList<>(), txs, accountNounces, repository, minGasPrice);
    Assert.assertEquals(1, res.size());
}
Also used : Coin(co.rsk.core.Coin) Repository(org.ethereum.core.Repository) Transaction(org.ethereum.core.Transaction) RskAddress(co.rsk.core.RskAddress) BigInteger(java.math.BigInteger) Test(org.junit.Test)

Example 87 with Transaction

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

the class TransactionsMessage method encode.

private void encode() {
    List<byte[]> encodedElements = new ArrayList<>();
    for (Transaction tx : transactions) {
        encodedElements.add(tx.getEncoded());
    }
    byte[][] encodedElementArray = encodedElements.toArray(new byte[encodedElements.size()][]);
    this.encoded = RLP.encodeList(encodedElementArray);
}
Also used : ImmutableTransaction(org.ethereum.core.ImmutableTransaction) Transaction(org.ethereum.core.Transaction) ArrayList(java.util.ArrayList)

Example 88 with Transaction

use of org.ethereum.core.Transaction 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);
}
Also used : Account(org.ethereum.core.Account) Transaction(org.ethereum.core.Transaction) TransactionsMessage(org.ethereum.net.eth.message.TransactionsMessage) AccountBuilder(co.rsk.test.builders.AccountBuilder)

Example 89 with Transaction

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

the class TxsPerAccountTest method retrieveTransactionsReadyToBeSendTwoNonces.

@Test
public void retrieveTransactionsReadyToBeSendTwoNonces() {
    TxsPerAccount txspa = new TxsPerAccount();
    Transaction tx = buildTransaction(1);
    Transaction tx2 = buildTransaction(2);
    txspa.getTransactions().add(tx);
    txspa.getTransactions().add(tx2);
    List<Transaction> txs = txspa.readyToBeSent(BigInteger.ONE);
    Assert.assertNotNull(txs);
    Assert.assertFalse(txs.isEmpty());
    Assert.assertEquals(2, txs.size());
    Assert.assertEquals(tx, txs.get(0));
    Assert.assertEquals(tx2, txs.get(1));
    Assert.assertNotNull(txspa.getNextNonce());
    Assert.assertEquals(BigInteger.valueOf(3), txspa.getNextNonce());
}
Also used : Transaction(org.ethereum.core.Transaction) Test(org.junit.Test)

Example 90 with Transaction

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

the class TxsPerAccountTest method retrieveTransactionsReadyToBeSendAndRemoveNonce.

@Test
public void retrieveTransactionsReadyToBeSendAndRemoveNonce() {
    TxsPerAccount txspa = new TxsPerAccount();
    Transaction tx = buildTransaction(1);
    Transaction tx2 = buildTransaction(1);
    txspa.getTransactions().add(tx);
    txspa.getTransactions().add(tx2);
    List<Transaction> txs = txspa.readyToBeSent(BigInteger.ONE);
    Assert.assertNotNull(txs);
    Assert.assertFalse(txs.isEmpty());
    Assert.assertEquals(1, txs.size());
    Assert.assertNotNull(txspa.getNextNonce());
    Assert.assertEquals(BigInteger.valueOf(2), txspa.getNextNonce());
    txspa.removeNonce(BigInteger.ONE);
    Assert.assertNotNull(txspa.getTransactions());
    Assert.assertTrue(txspa.getTransactions().isEmpty());
    Assert.assertNull(txspa.getNextNonce());
}
Also used : Transaction(org.ethereum.core.Transaction) Test(org.junit.Test)

Aggregations

Transaction (org.ethereum.core.Transaction)131 Test (org.junit.Test)82 BigInteger (java.math.BigInteger)33 Coin (co.rsk.core.Coin)23 Account (org.ethereum.core.Account)20 ArrayList (java.util.ArrayList)17 Block (org.ethereum.core.Block)17 RskAddress (co.rsk.core.RskAddress)15 JsonNode (com.fasterxml.jackson.databind.JsonNode)15 Repository (org.ethereum.core.Repository)12 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)11 AccountState (org.ethereum.core.AccountState)10 RemascTransaction (co.rsk.remasc.RemascTransaction)9 TransactionBuilder (co.rsk.test.builders.TransactionBuilder)9 ImmutableTransaction (org.ethereum.core.ImmutableTransaction)8 ECKey (org.ethereum.crypto.ECKey)8 Keccak256 (co.rsk.crypto.Keccak256)7 AccountBuilder (co.rsk.test.builders.AccountBuilder)7 DslParser (co.rsk.test.dsl.DslParser)6 WorldDslProcessor (co.rsk.test.dsl.WorldDslProcessor)6