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());
}
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);
}
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);
}
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());
}
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());
}
Aggregations