Search in sources :

Example 91 with AionTransaction

use of org.aion.base.AionTransaction in project aion by aionnetwork.

the class PendingTxCacheTest method benchmark1.

@Test
public void benchmark1() {
    PendingTxCache cache = new PendingTxCache();
    int input = 80_000;
    int remove = 5;
    System.out.println("Gen 80K txs");
    List<AionTransaction> txn = getMockTransaction(0, input, 0);
    System.out.println("adding 80K txs to cache");
    long t1 = System.currentTimeMillis();
    for (AionTransaction tx : txn) {
        cache.addCacheTx(tx);
    }
    long t2 = System.currentTimeMillis() - t1;
    System.out.println("add 80K txs took " + t2 + " ms cacheSize: " + cache.cacheSize());
    assertTrue(cache.cacheTxSize() == input);
    System.out.println("Gen another 80K txs");
    txn = getMockTransaction(0, input, 1);
    t1 = System.currentTimeMillis();
    for (AionTransaction tx : txn) {
        cache.addCacheTx(tx);
    }
    t2 = System.currentTimeMillis() - t1;
    System.out.println("add another 80K txs took " + t2 + " ms cacheSize: " + cache.cacheSize());
    assertTrue(cache.cacheTxSize() == (input << 1));
    System.out.println("flush starting");
    Map<AionAddress, BigInteger> flushMap = new HashMap<>();
    flushMap.put(new AionAddress(key.get(0).getAddress()), BigInteger.valueOf(remove));
    flushMap.put(new AionAddress(key.get(1).getAddress()), BigInteger.valueOf(remove));
    t1 = System.currentTimeMillis();
    cache.flush(flushMap);
    t2 = System.currentTimeMillis() - t1;
    System.out.println("flush took " + t2 + " ms");
    Map<BigInteger, AionTransaction> cacheMap = cache.getCacheTx(new AionAddress(key.get(0).getAddress()));
    assertTrue(cacheMap.size() == input - remove);
    cacheMap = cache.getCacheTx(new AionAddress(key.get(1).getAddress()));
    assertTrue(cacheMap.size() == input - remove);
}
Also used : AionAddress(org.aion.types.AionAddress) HashMap(java.util.HashMap) BigInteger(java.math.BigInteger) AionTransaction(org.aion.base.AionTransaction) Test(org.junit.Test)

Example 92 with AionTransaction

use of org.aion.base.AionTransaction 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);
    for (AionTransaction tx : txn) {
        cache.addCacheTx(tx);
    }
    assertTrue(cache.cacheTxSize() == 659);
    AionTransaction tx = getMockTransaction(50, 1, 0).get(0);
    cache.addCacheTx(tx);
    assertTrue(cache.cacheTxSize() == 659);
    Map<BigInteger, AionTransaction> cacheMap = cache.getCacheTx(new AionAddress(key.get(0).getAddress()));
    assertTrue(cacheMap.size() == 659);
}
Also used : AionAddress(org.aion.types.AionAddress) BigInteger(java.math.BigInteger) AionTransaction(org.aion.base.AionTransaction) Test(org.junit.Test)

Example 93 with AionTransaction

use of org.aion.base.AionTransaction in project aion by aionnetwork.

the class PendingTxCacheTest method maxPendingSizeTest4.

@Test
public void maxPendingSizeTest4() {
    PendingTxCache cache = new PendingTxCache(1);
    List<AionTransaction> txn = getMockTransaction(0, 659, 0);
    for (AionTransaction tx : txn) {
        cache.addCacheTx(tx);
    }
    assertTrue(cache.cacheTxSize() == 659);
    AionTransaction tx = getMockBigTransaction(50, 1, 0, 2000).get(0);
    cache.addCacheTx(tx);
    assertTrue(cache.cacheTxSize() == 652);
    Map<BigInteger, AionTransaction> cacheMap = cache.getCacheTx(new AionAddress(key.get(0).getAddress()));
    assertTrue(cacheMap.size() == 652);
}
Also used : AionAddress(org.aion.types.AionAddress) BigInteger(java.math.BigInteger) AionTransaction(org.aion.base.AionTransaction) Test(org.junit.Test)

Example 94 with AionTransaction

use of org.aion.base.AionTransaction in project aion by aionnetwork.

the class PendingTxCacheTest method addCacheTxTest4.

@Test
public void addCacheTxTest4() {
    PendingTxCache cache = new PendingTxCache(1);
    List<AionTransaction> txn = getMockTransaction(0, 10, 0);
    txn.addAll(getMockTransaction(5, 10, 0));
    for (AionTransaction tx : txn) {
        cache.addCacheTx(tx);
    }
    assertTrue(cache.cacheTxSize() == 15);
    Map<BigInteger, AionTransaction> cacheMap = cache.getCacheTx(new AionAddress(key.get(0).getAddress()));
    assertTrue(cacheMap.size() == 15);
}
Also used : AionAddress(org.aion.types.AionAddress) BigInteger(java.math.BigInteger) AionTransaction(org.aion.base.AionTransaction) Test(org.junit.Test)

Example 95 with AionTransaction

use of org.aion.base.AionTransaction in project aion by aionnetwork.

the class PendingTxCacheTest method maxPendingSizeTest3.

@Test
public void maxPendingSizeTest3() {
    PendingTxCache cache = new PendingTxCache(1);
    List<AionTransaction> txn = getMockTransaction(0, 659, 0);
    for (AionTransaction tx : txn) {
        cache.addCacheTx(tx);
    }
    assertTrue(cache.cacheTxSize() == 659);
    AionTransaction tx = getMockBigTransaction(50, 1, 0, 200).get(0);
    cache.addCacheTx(tx);
    assertTrue(cache.cacheTxSize() == 658);
    Map<BigInteger, AionTransaction> cacheMap = cache.getCacheTx(new AionAddress(key.get(0).getAddress()));
    assertTrue(cacheMap.size() == 658);
}
Also used : AionAddress(org.aion.types.AionAddress) BigInteger(java.math.BigInteger) AionTransaction(org.aion.base.AionTransaction) Test(org.junit.Test)

Aggregations

AionTransaction (org.aion.base.AionTransaction)437 Test (org.junit.Test)308 AionAddress (org.aion.types.AionAddress)273 BigInteger (java.math.BigInteger)174 MiningBlock (org.aion.zero.impl.types.MiningBlock)149 ArrayList (java.util.ArrayList)127 ImportResult (org.aion.zero.impl.core.ImportResult)115 AionTxExecSummary (org.aion.base.AionTxExecSummary)103 Block (org.aion.zero.impl.types.Block)102 RepositoryCache (org.aion.base.db.RepositoryCache)89 AionBlockSummary (org.aion.zero.impl.types.AionBlockSummary)87 AionTxReceipt (org.aion.base.AionTxReceipt)75 ECKey (org.aion.crypto.ECKey)52 AionRepositoryImpl (org.aion.zero.impl.db.AionRepositoryImpl)46 BlockContext (org.aion.zero.impl.types.BlockContext)43 PooledTransaction (org.aion.base.PooledTransaction)40 AccountState (org.aion.base.AccountState)39 Properties (java.util.Properties)35 HashMap (java.util.HashMap)33 DataWord (org.aion.util.types.DataWord)29