use of co.rsk.core.Coin in project rskj by rsksmart.
the class TransactionPoolImplTest method getAllPendingTransactions.
@Test
public void getAllPendingTransactions() {
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);
transactionPool.addTransaction(tx1);
List<Transaction> txs = new ArrayList<>();
txs.add(tx1);
txs.add(tx2);
transactionPool.addTransactions(txs);
List<Transaction> alltxs = transactionPool.getPendingTransactions();
Assert.assertNotNull(alltxs);
Assert.assertFalse(alltxs.isEmpty());
Assert.assertEquals(2, alltxs.size());
Assert.assertTrue(alltxs.contains(tx1));
Assert.assertTrue(alltxs.contains(tx2));
}
use of co.rsk.core.Coin 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());
}
use of co.rsk.core.Coin in project rskj by rsksmart.
the class TransactionPoolImplTest method removeObsoleteQueuedTransactionsByBlock.
@Test
public void removeObsoleteQueuedTransactionsByBlock() {
BlockChainImpl blockchain = createBlockchain();
Coin balance = Coin.valueOf(1000000);
TransactionPoolImpl transactionPool = createSampleNewTransactionPoolWithAccounts(2, balance, blockchain);
transactionPool.processBest(blockchain.getBestBlock());
Transaction tx1 = createSampleTransaction(1, 2, 1000, 1);
Transaction tx2 = createSampleTransaction(1, 2, 3000, 2);
transactionPool.addTransaction(tx1);
transactionPool.addTransaction(tx2);
Assert.assertEquals(10, transactionPool.getOutdatedThreshold());
List<Transaction> list = transactionPool.getQueuedTransactions();
Assert.assertNotNull(list);
Assert.assertFalse(list.isEmpty());
Assert.assertEquals(2, list.size());
transactionPool.removeObsoleteTransactions(1, 1, 100);
list = transactionPool.getQueuedTransactions();
Assert.assertNotNull(list);
Assert.assertFalse(list.isEmpty());
Assert.assertEquals(2, list.size());
transactionPool.removeObsoleteTransactions(20, transactionPool.getOutdatedThreshold(), 100);
list = transactionPool.getQueuedTransactions();
Assert.assertNotNull(list);
Assert.assertTrue(list.isEmpty());
}
use of co.rsk.core.Coin in project rskj by rsksmart.
the class TransactionPoolImplTest method removeObsoleteQueuedTransactionsByTimeout.
@Test
public void removeObsoleteQueuedTransactionsByTimeout() throws InterruptedException {
BlockChainImpl blockchain = createBlockchain();
Coin balance = Coin.valueOf(1000000);
TransactionPoolImpl transactionPool = createSampleNewTransactionPoolWithAccounts(2, balance, blockchain);
transactionPool.processBest(blockchain.getBestBlock());
Transaction tx1 = createSampleTransaction(1, 2, 1000, 1);
Transaction tx2 = createSampleTransaction(1, 2, 3000, 2);
transactionPool.addTransaction(tx1);
transactionPool.addTransaction(tx2);
Assert.assertEquals(10, transactionPool.getOutdatedThreshold());
List<Transaction> list = transactionPool.getQueuedTransactions();
Assert.assertNotNull(list);
Assert.assertFalse(list.isEmpty());
Assert.assertEquals(2, list.size());
Thread.sleep(3000);
transactionPool.removeObsoleteTransactions(1, 1, 1);
list = transactionPool.getQueuedTransactions();
Assert.assertNotNull(list);
Assert.assertTrue(list.isEmpty());
}
use of co.rsk.core.Coin in project rskj by rsksmart.
the class TransactionPoolImplTest method removeObsoletePendingTransactionsByTimeout.
@Test
public void removeObsoletePendingTransactionsByTimeout() throws InterruptedException {
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);
transactionPool.addTransaction(tx1);
transactionPool.addTransaction(tx2);
Assert.assertEquals(10, transactionPool.getOutdatedThreshold());
List<Transaction> list = transactionPool.getPendingTransactions();
Assert.assertNotNull(list);
Assert.assertFalse(list.isEmpty());
Assert.assertEquals(2, list.size());
Thread.sleep(3000);
transactionPool.removeObsoleteTransactions(1, 1, 1);
list = transactionPool.getPendingTransactions();
Assert.assertNotNull(list);
Assert.assertTrue(list.isEmpty());
}
Aggregations