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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations