Search in sources :

Example 21 with TxPoolA0

use of org.aion.txpool.zero.TxPoolA0 in project aion by aionnetwork.

the class TxnPoolTest method addTxWithSameNonce.

@Test
public void addTxWithSameNonce() {
    Properties config = new Properties();
    config.put("txn-timeout", "10");
    ITxPool<ITransaction> tp = new TxPoolA0<>(config);
    ITransaction txn = genTransaction(ByteUtils.fromHexString("0000000000000001"));
    txn.setNrgConsume(100);
    List<ITransaction> txnl = new ArrayList<>();
    ((AionTransaction) txn).sign(key.get(0));
    txnl.add(txn);
    ((AionTransaction) txn).sign(key.get(0));
    txnl.add(txn);
    long t = new BigInteger(txn.getTimeStamp()).longValue();
    tp.add(txnl);
    assertTrue(tp.size() == 1);
    List<ITransaction> txl = tp.snapshot();
    assertTrue(txl.size() == 1);
    assertTrue(new BigInteger(txl.get(0).getTimeStamp()).longValue() == t);
}
Also used : ITransaction(org.aion.base.type.ITransaction) BigInteger(java.math.BigInteger) AionTransaction(org.aion.zero.types.AionTransaction) TxPoolA0(org.aion.txpool.zero.TxPoolA0) Test(org.junit.Test)

Aggregations

TxPoolA0 (org.aion.txpool.zero.TxPoolA0)21 AionTransaction (org.aion.zero.types.AionTransaction)21 Test (org.junit.Test)21 ITransaction (org.aion.base.type.ITransaction)19 BigInteger (java.math.BigInteger)14 Address (org.aion.base.type.Address)9 ECKey (org.aion.crypto.ECKey)7