Search in sources :

Example 96 with AionAddress

use of org.aion.types.AionAddress 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 97 with AionAddress

use of org.aion.types.AionAddress 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 98 with AionAddress

use of org.aion.types.AionAddress 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 99 with AionAddress

use of org.aion.types.AionAddress 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 100 with AionAddress

use of org.aion.types.AionAddress 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

AionAddress (org.aion.types.AionAddress)491 Test (org.junit.Test)364 AionTransaction (org.aion.base.AionTransaction)275 BigInteger (java.math.BigInteger)194 ImportResult (org.aion.zero.impl.core.ImportResult)110 AionTxExecSummary (org.aion.base.AionTxExecSummary)97 RepositoryCache (org.aion.base.db.RepositoryCache)90 MiningBlock (org.aion.zero.impl.types.MiningBlock)89 AionBlockSummary (org.aion.zero.impl.types.AionBlockSummary)80 ArrayList (java.util.ArrayList)76 ECKey (org.aion.crypto.ECKey)74 AionTxReceipt (org.aion.base.AionTxReceipt)60 Block (org.aion.zero.impl.types.Block)60 AccountState (org.aion.base.AccountState)56 HashMap (java.util.HashMap)42 DataWord (org.aion.util.types.DataWord)39 PrecompiledTransactionResult (org.aion.precompiled.PrecompiledTransactionResult)36 InternalTransaction (org.aion.types.InternalTransaction)32 ByteArrayWrapper (org.aion.util.types.ByteArrayWrapper)29 BlockContext (org.aion.zero.impl.types.BlockContext)29