use of org.ethereum.core.Transaction in project rskj by rsksmart.
the class TxValidatorMinimumGasPriceValidatorTest method invalidMinimumGasPrice.
@Test
public void invalidMinimumGasPrice() {
Transaction tx1 = Mockito.mock(Transaction.class);
Transaction tx2 = Mockito.mock(Transaction.class);
Transaction tx3 = Mockito.mock(Transaction.class);
Mockito.when(tx1.getGasPrice()).thenReturn(Coin.valueOf(9));
Mockito.when(tx2.getGasPrice()).thenReturn(Coin.valueOf(0));
Mockito.when(tx3.getGasPrice()).thenReturn(null);
TxValidatorMinimuGasPriceValidator tvmgpv = new TxValidatorMinimuGasPriceValidator();
Assert.assertFalse(tvmgpv.validate(tx1, null, null, Coin.valueOf(10L), Long.MAX_VALUE, false));
Assert.assertFalse(tvmgpv.validate(tx2, null, null, Coin.valueOf(10L), Long.MAX_VALUE, false));
Assert.assertFalse(tvmgpv.validate(tx3, null, null, Coin.valueOf(10L), Long.MAX_VALUE, false));
}
use of org.ethereum.core.Transaction in project rskj by rsksmart.
the class TxValidatorMinimumGasPriceValidatorTest method validMinimumGasPrice.
@Test
public void validMinimumGasPrice() {
Transaction tx1 = Mockito.mock(Transaction.class);
Transaction tx2 = Mockito.mock(Transaction.class);
Transaction tx3 = Mockito.mock(Transaction.class);
Mockito.when(tx1.getGasPrice()).thenReturn(Coin.valueOf(10));
Mockito.when(tx2.getGasPrice()).thenReturn(Coin.valueOf(11));
Mockito.when(tx3.getGasPrice()).thenReturn(Coin.valueOf(500000000));
TxValidatorMinimuGasPriceValidator tvmgpv = new TxValidatorMinimuGasPriceValidator();
Assert.assertTrue(tvmgpv.validate(tx1, null, null, Coin.valueOf(10L), Long.MAX_VALUE, false));
Assert.assertTrue(tvmgpv.validate(tx2, null, null, Coin.valueOf(10L), Long.MAX_VALUE, false));
Assert.assertTrue(tvmgpv.validate(tx3, null, null, Coin.valueOf(10L), Long.MAX_VALUE, false));
}
use of org.ethereum.core.Transaction in project rskj by rsksmart.
the class TxValidatorNonceRangeValidatorTest method nonceOutOfRange.
@Test
public void nonceOutOfRange() {
Transaction tx1 = Mockito.mock(Transaction.class);
Transaction tx2 = Mockito.mock(Transaction.class);
AccountState as = Mockito.mock(AccountState.class);
Mockito.when(tx1.getNonceAsInteger()).thenReturn(BigInteger.valueOf(0));
Mockito.when(tx2.getNonceAsInteger()).thenReturn(BigInteger.valueOf(6));
Mockito.when(as.getNonce()).thenReturn(BigInteger.valueOf(1));
TxValidatorNonceRangeValidator tvnrv = new TxValidatorNonceRangeValidator();
Assert.assertFalse(tvnrv.validate(tx1, as, null, null, Long.MAX_VALUE, false));
Assert.assertFalse(tvnrv.validate(tx2, as, null, null, Long.MAX_VALUE, false));
}
use of org.ethereum.core.Transaction in project rskj by rsksmart.
the class TxValidatorNonceRangeValidatorTest method nonceInRange.
@Test
public void nonceInRange() {
Transaction tx1 = Mockito.mock(Transaction.class);
Transaction tx2 = Mockito.mock(Transaction.class);
AccountState as = Mockito.mock(AccountState.class);
Mockito.when(tx1.getNonceAsInteger()).thenReturn(BigInteger.valueOf(0));
Mockito.when(tx2.getNonceAsInteger()).thenReturn(BigInteger.valueOf(3));
Mockito.when(as.getNonce()).thenReturn(BigInteger.valueOf(0));
TxValidatorNonceRangeValidator tvnrv = new TxValidatorNonceRangeValidator();
Assert.assertTrue(tvnrv.validate(tx1, as, null, null, Long.MAX_VALUE, false));
Assert.assertTrue(tvnrv.validate(tx2, as, null, null, Long.MAX_VALUE, false));
}
use of org.ethereum.core.Transaction in project rskj by rsksmart.
the class TransactionUtils method createTransaction.
public static Transaction createTransaction(byte[] privateKey, String toAddress, BigInteger value, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit) {
Transaction tx = Transaction.create(new RskSystemProperties(), toAddress, value, nonce, gasPrice, gasLimit);
tx.sign(privateKey);
return tx;
}
Aggregations