use of org.aion.base.PooledTransaction in project aion by aionnetwork.
the class TxPoolV1Test method add2.
@Test
public void add2() {
Properties config = new Properties();
config.put(TXPOOL_PROPERTY.PROP_TX_TIMEOUT, "100");
TxPoolV1 tp = new TxPoolV1(config);
PooledTransaction pooledTx = genTransaction(new byte[0], 0);
tp.add(pooledTx);
Assert.assertEquals(1, tp.size());
}
use of org.aion.base.PooledTransaction in project aion by aionnetwork.
the class TxPoolV1Test method snapshot.
@Test
public void snapshot() {
Properties config = new Properties();
// 10 sec
config.put(TXPOOL_PROPERTY.PROP_TX_TIMEOUT, "10");
TxPoolV1 tp = new TxPoolV1(config);
List<PooledTransaction> txnl = getMockTransaction(0);
tp.add(txnl);
tp.snapshot();
Assert.assertEquals(1, tp.size());
}
use of org.aion.base.PooledTransaction in project aion by aionnetwork.
the class TxPoolV1Test method addRepeatedTxn2.
@Test
public void addRepeatedTxn2() {
Properties config = new Properties();
config.put(TXPOOL_PROPERTY.PROP_TX_TIMEOUT, "10");
TxPoolV1 tp = new TxPoolV1(config);
List<PooledTransaction> txnl = new ArrayList<>();
int cnt = 10;
for (int i = 0; i < cnt; i++) {
byte[] nonce = new byte[Long.BYTES];
nonce[Long.BYTES - 1] = (byte) i;
PooledTransaction pooledTx = genTransactionWithEnergyPrice(nonce, 1);
txnl.add(pooledTx);
}
tp.add(txnl);
Assert.assertEquals(tp.size(), cnt);
byte[] nonce = new byte[Long.BYTES];
nonce[Long.BYTES - 1] = (byte) 5;
PooledTransaction pooledTx = genTransactionWithEnergyPrice(nonce, 2);
tp.add(pooledTx);
List<AionTransaction> snapshot = tp.snapshot();
Assert.assertEquals(snapshot.size(), cnt);
Assert.assertEquals(snapshot.get(5), pooledTx.tx);
}
use of org.aion.base.PooledTransaction in project aion by aionnetwork.
the class TxPoolV1Test method snapshot4.
@Test
public void snapshot4() {
Properties config = new Properties();
config.put(TXPOOL_PROPERTY.PROP_TX_TIMEOUT, "100");
TxPoolV1 tp = new TxPoolV1(config);
List<PooledTransaction> txnl = new ArrayList<>();
int cnt = 26;
for (int i = 0; i < cnt; i++) {
byte[] nonce = new byte[Long.BYTES];
nonce[Long.BYTES - 1] = (byte) i;
PooledTransaction txn = genTransaction(nonce, Constant.MIN_ENERGY_CONSUME + (1000L - i));
txnl.add(txn);
}
tp.add(txnl);
Assert.assertEquals(tp.size(), cnt);
// sort the inserted txs
List<AionTransaction> snapshot = tp.snapshot();
long nonce = 0;
for (AionTransaction tx : snapshot) {
Assert.assertEquals(tx.getNonceBI().longValue(), nonce++);
}
}
use of org.aion.base.PooledTransaction in project aion by aionnetwork.
the class TxPoolV1Test method noncebyAccountTest2.
@Test
public void noncebyAccountTest2() {
Properties config = new Properties();
config.put(TXPOOL_PROPERTY.PROP_TX_TIMEOUT, "10");
TxPoolV1 tp = new TxPoolV1(config);
List<PooledTransaction> txnl = new ArrayList<>();
int cnt = 100;
for (ECKey aKey1 : key) {
for (int i = 0; i < cnt; i++) {
byte[] nonce = new byte[Long.BYTES];
nonce[Long.BYTES - 1] = (byte) (i + 1);
AionTransaction txn = AionTransaction.create(aKey1, nonce, AddressUtils.wrapAddress("0000000000000000000000000000000000000000000000000000000000000001"), ByteUtils.fromHexString("1"), ByteUtils.fromHexString("1"), Constant.MIN_ENERGY_CONSUME, 1L, TransactionTypes.DEFAULT, null);
PooledTransaction pooledTx = new PooledTransaction(txn, Constant.MIN_ENERGY_CONSUME + 100);
txnl.add(pooledTx);
}
}
tp.add(txnl);
Assert.assertEquals(tp.size(), cnt * key.size());
// sort the inserted txs
tp.snapshot();
for (ECKey aKey : key) {
List<BigInteger> nl = tp.getNonceList(new AionAddress(aKey.getAddress()));
for (int i = 0; i < cnt; i++) {
Assert.assertEquals(nl.get(i), BigInteger.valueOf(i + 1));
}
}
}
Aggregations