Search in sources :

Example 26 with ITransaction

use of org.aion.base.type.ITransaction in project aion by aionnetwork.

the class PendingTxCacheTest method flushTest2.

@Test
public void flushTest2() {
    PendingTxCache cache = new PendingTxCache(1);
    List<AionTransaction> txn = getMockTransaction(0, 10, 0);
    List<AionTransaction> newCache = new ArrayList<>();
    for (ITransaction tx : txn) {
        newCache.add(cache.addCacheTx((AionTransaction) tx).get(0));
    }
    assertTrue(newCache.size() == 10);
    Map<Address, BigInteger> map = new HashMap<>();
    map.put(Address.wrap(key.get(1).getAddress()), BigInteger.TWO);
    cache.flush(map);
    Map<BigInteger, AionTransaction> cacheMap = cache.geCacheTx(Address.wrap(key.get(0).getAddress()));
    assertTrue(cacheMap.size() == 10);
}
Also used : Address(org.aion.base.type.Address) HashMap(java.util.HashMap) ITransaction(org.aion.base.type.ITransaction) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) AionTransaction(org.aion.zero.types.AionTransaction) Test(org.junit.Test)

Example 27 with ITransaction

use of org.aion.base.type.ITransaction in project aion by aionnetwork.

the class PendingTxCacheTest method maxPendingSizeTest2.

@Test
public void maxPendingSizeTest2() {
    PendingTxCache cache = new PendingTxCache(1);
    List<AionTransaction> txn = getMockTransaction(0, 659, 0);
    List<AionTransaction> newCache = new ArrayList<>();
    for (ITransaction tx : txn) {
        newCache.add(cache.addCacheTx((AionTransaction) tx).get(0));
    }
    assertTrue(newCache.size() == 659);
    AionTransaction tx = getMockTransaction(50, 1, 0).get(0);
    newCache = cache.addCacheTx(tx);
    assertTrue(newCache.size() == 659);
    Map<BigInteger, AionTransaction> cacheMap = cache.geCacheTx(Address.wrap(key.get(0).getAddress()));
    assertTrue(cacheMap.size() == 659);
}
Also used : ITransaction(org.aion.base.type.ITransaction) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) AionTransaction(org.aion.zero.types.AionTransaction) Test(org.junit.Test)

Example 28 with ITransaction

use of org.aion.base.type.ITransaction in project aion by aionnetwork.

the class PendingTxCacheTest method maxPendingSizeTest1.

@Test
public void maxPendingSizeTest1() {
    PendingTxCache cache = new PendingTxCache(1);
    List<AionTransaction> txn = getMockTransaction(0, 680, 0);
    List<AionTransaction> newCache = new ArrayList<>();
    for (ITransaction tx : txn) {
        newCache.add(cache.addCacheTx((AionTransaction) tx).get(0));
    }
    Map<BigInteger, AionTransaction> cacheMap = cache.geCacheTx(Address.wrap(key.get(0).getAddress()));
    assertTrue(cacheMap.size() == 659);
}
Also used : ITransaction(org.aion.base.type.ITransaction) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) AionTransaction(org.aion.zero.types.AionTransaction) Test(org.junit.Test)

Example 29 with ITransaction

use of org.aion.base.type.ITransaction in project aion by aionnetwork.

the class PendingTxCacheTest method addCacheTxTest2.

@Test
public void addCacheTxTest2() {
    PendingTxCache cache = new PendingTxCache(1);
    List<AionTransaction> txn = getMockTransaction(0, 10, 0);
    txn.addAll(getMockTransaction(0, 10, 1));
    List<AionTransaction> newCache = new ArrayList<>();
    for (ITransaction tx : txn) {
        newCache.add(cache.addCacheTx((AionTransaction) tx).get(0));
    }
    assertTrue(newCache.size() == txn.size());
}
Also used : ITransaction(org.aion.base.type.ITransaction) ArrayList(java.util.ArrayList) AionTransaction(org.aion.zero.types.AionTransaction) Test(org.junit.Test)

Aggregations

ITransaction (org.aion.base.type.ITransaction)29 AionTransaction (org.aion.zero.types.AionTransaction)26 Test (org.junit.Test)26 BigInteger (java.math.BigInteger)22 TxPoolA0 (org.aion.txpool.zero.TxPoolA0)19 Address (org.aion.base.type.Address)13 ArrayList (java.util.ArrayList)7 ECKey (org.aion.crypto.ECKey)5 ByteArrayWrapper (org.aion.base.util.ByteArrayWrapper)3 HashMap (java.util.HashMap)2 SimpleEntry (java.util.AbstractMap.SimpleEntry)1 Entry (java.util.Map.Entry)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 AccountState (org.aion.txpool.common.AccountState)1 TxDependList (org.aion.txpool.common.TxDependList)1