Search in sources :

Example 21 with AionTransaction

use of org.aion.zero.types.AionTransaction in project aion by aionnetwork.

the class PendingTxCacheTest method addCacheTxTest.

@Test
public void addCacheTxTest() {
    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() == txn.size());
}
Also used : ITransaction(org.aion.base.type.ITransaction) ArrayList(java.util.ArrayList) AionTransaction(org.aion.zero.types.AionTransaction) Test(org.junit.Test)

Example 22 with AionTransaction

use of org.aion.zero.types.AionTransaction in project aion by aionnetwork.

the class PendingTxCacheTest method addCacheTxTest3.

@Test
public void addCacheTxTest3() {
    PendingTxCache cache = new PendingTxCache(1000);
    List<AionTransaction> txn = new ArrayList<>();
    for (int i = 0; i < key.size(); i++) {
        txn.add(getMockTransaction(0, 1, i).get(0));
    }
    for (AionTransaction tx : txn) {
        cache.addCacheTx(tx);
    }
    assertTrue(cache.getCacheTxAccount().size() == key.size() - 1);
}
Also used : ArrayList(java.util.ArrayList) AionTransaction(org.aion.zero.types.AionTransaction) Test(org.junit.Test)

Example 23 with AionTransaction

use of org.aion.zero.types.AionTransaction in project aion by aionnetwork.

the class PendingTxCacheTest method maxPendingSizeTest6.

@Test
public void maxPendingSizeTest6() {
    PendingTxCache cache = new PendingTxCache(1);
    List<AionTransaction> txn = getMockTransaction(0, 100, 0);
    txn.addAll(getMockTransaction(101, 600, 0));
    List<AionTransaction> newCache = new ArrayList<>();
    for (AionTransaction tx : txn) {
        newCache.add(cache.addCacheTx(tx).get(0));
    }
    assertTrue(newCache.size() == 700);
    Map<BigInteger, AionTransaction> cacheMap = cache.geCacheTx(Address.wrap(key.get(0).getAddress()));
    assertTrue(cacheMap.size() == 659);
    AionTransaction tx = getMockBigTransaction(100, 1, 0, 199_500).get(0);
    newCache = cache.addCacheTx(tx);
    assertTrue(newCache.size() == 659);
}
Also used : ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) AionTransaction(org.aion.zero.types.AionTransaction) Test(org.junit.Test)

Example 24 with AionTransaction

use of org.aion.zero.types.AionTransaction in project aion by aionnetwork.

the class PendingTxCacheTest method maxPendingSizeTest5.

@Test
public void maxPendingSizeTest5() {
    PendingTxCache cache = new PendingTxCache(1);
    List<AionTransaction> txn = getMockTransaction(0, 100, 0);
    txn.addAll(getMockTransaction(101, 600, 0));
    List<AionTransaction> newCache = new ArrayList<>();
    for (AionTransaction tx : txn) {
        newCache.add(cache.addCacheTx(tx).get(0));
    }
    assertTrue(newCache.size() == 700);
    Map<BigInteger, AionTransaction> cacheMap = cache.geCacheTx(Address.wrap(key.get(0).getAddress()));
    assertTrue(cacheMap.size() == 659);
    AionTransaction tx = getMockBigTransaction(100, 1, 0, 2000).get(0);
    newCache = cache.addCacheTx(tx);
    assertTrue(newCache.size() == 652);
}
Also used : ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) AionTransaction(org.aion.zero.types.AionTransaction) Test(org.junit.Test)

Example 25 with AionTransaction

use of org.aion.zero.types.AionTransaction in project aion by aionnetwork.

the class ApiAion method doCall.

public byte[] doCall(ArgTxCall _params) {
    AionTransaction tx = new AionTransaction(_params.getNonce().toByteArray(), _params.getTo(), _params.getValue().toByteArray(), _params.getData(), _params.getNrg(), _params.getNrgPrice());
    AionTxReceipt rec = this.ac.callConstant(tx, this.ac.getAionHub().getBlockchain().getBestBlock());
    return rec.getExecutionResult();
}
Also used : AionTransaction(org.aion.zero.types.AionTransaction) AionTxReceipt(org.aion.zero.types.AionTxReceipt)

Aggregations

AionTransaction (org.aion.zero.types.AionTransaction)75 Test (org.junit.Test)44 BigInteger (java.math.BigInteger)30 ITransaction (org.aion.base.type.ITransaction)26 Address (org.aion.base.type.Address)23 TxPoolA0 (org.aion.txpool.zero.TxPoolA0)21 AionBlock (org.aion.zero.impl.types.AionBlock)17 ArrayList (java.util.ArrayList)16 ECKey (org.aion.crypto.ECKey)12 AionTxReceipt (org.aion.zero.types.AionTxReceipt)7 TxRecpt (org.aion.api.server.types.TxRecpt)4 ImportResult (org.aion.mcf.core.ImportResult)4 AionTxInfo (org.aion.zero.impl.types.AionTxInfo)4 ByteString (com.google.protobuf.ByteString)3 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)2 ByteBuffer (java.nio.ByteBuffer)2 java.util (java.util)2 Entry (java.util.Map.Entry)2 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)2 Collectors (java.util.stream.Collectors)2