Search in sources :

Example 61 with Coin

use of co.rsk.core.Coin in project rskj by rsksmart.

the class MinerUtilsTest method validTransactionAccWrapNonceTest.

@Test
public void validTransactionAccWrapNonceTest() {
    Transaction tx = Tx.create(config, 0, 50000, 5, 1, 0, 0);
    // Mockito.when(tx.checkGasPrice(Mockito.any(BigInteger.class))).thenReturn(true);
    List<Transaction> txs = new LinkedList<>();
    txs.add(tx);
    Map<RskAddress, BigInteger> accountNounces = new HashMap();
    accountNounces.put(tx.getSender(), BigInteger.valueOf(0));
    Repository repository = Mockito.mock(Repository.class);
    Coin minGasPrice = Coin.valueOf(1L);
    List<Transaction> res = new MinerUtils().filterTransactions(new LinkedList<>(), txs, accountNounces, repository, minGasPrice);
    Assert.assertEquals(1, res.size());
}
Also used : Coin(co.rsk.core.Coin) Repository(org.ethereum.core.Repository) Transaction(org.ethereum.core.Transaction) RskAddress(co.rsk.core.RskAddress) BigInteger(java.math.BigInteger) Test(org.junit.Test)

Example 62 with Coin

use of co.rsk.core.Coin in project rskj by rsksmart.

the class MinimumGasPriceCalculatorTest method mgpOnRage.

@Test
public void mgpOnRage() {
    MinimumGasPriceCalculator mgpCalculator = new MinimumGasPriceCalculator();
    Coin prev = Coin.valueOf(1000L);
    Coin target = Coin.valueOf(995L);
    Coin mgp = mgpCalculator.calculate(prev, target);
    Assert.assertEquals(target, mgp);
}
Also used : Coin(co.rsk.core.Coin) Test(org.junit.Test)

Example 63 with Coin

use of co.rsk.core.Coin in project rskj by rsksmart.

the class MinimumGasPriceCalculatorTest method increaseMgp.

@Test
public void increaseMgp() {
    MinimumGasPriceCalculator mgpCalculator = new MinimumGasPriceCalculator();
    Coin prev = Coin.valueOf(1000L);
    Coin target = Coin.valueOf(2000L);
    Coin mgp = mgpCalculator.calculate(prev, target);
    Assert.assertEquals(Coin.valueOf(1010), mgp);
}
Also used : Coin(co.rsk.core.Coin) Test(org.junit.Test)

Example 64 with Coin

use of co.rsk.core.Coin in project rskj by rsksmart.

the class MinimumGasPriceCalculatorTest method decreaseMGP.

@Test
public void decreaseMGP() {
    MinimumGasPriceCalculator mgpCalculator = new MinimumGasPriceCalculator();
    Coin prev = Coin.valueOf(1000L);
    Coin target = Coin.valueOf(900L);
    Coin mgp = mgpCalculator.calculate(prev, target);
    Assert.assertEquals(Coin.valueOf(990), mgp);
}
Also used : Coin(co.rsk.core.Coin) Test(org.junit.Test)

Example 65 with Coin

use of co.rsk.core.Coin in project rskj by rsksmart.

the class MinimumGasPriceCalculatorTest method previousMgpEqualsTarget.

@Test
public void previousMgpEqualsTarget() {
    MinimumGasPriceCalculator mgpCalculator = new MinimumGasPriceCalculator();
    Coin prev = Coin.valueOf(1000L);
    Coin target = Coin.valueOf(1000L);
    Coin mgp = mgpCalculator.calculate(prev, target);
    Assert.assertEquals(target, mgp);
}
Also used : Coin(co.rsk.core.Coin) Test(org.junit.Test)

Aggregations

Coin (co.rsk.core.Coin)95 Test (org.junit.Test)46 RskAddress (co.rsk.core.RskAddress)37 BigInteger (java.math.BigInteger)32 Repository (org.ethereum.core.Repository)23 Transaction (org.ethereum.core.Transaction)23 Program (org.ethereum.vm.program.Program)12 AccountState (org.ethereum.core.AccountState)10 ArrayList (java.util.ArrayList)9 Ignore (org.junit.Ignore)9 ProgramInvokeMockImpl (org.ethereum.vm.program.invoke.ProgramInvokeMockImpl)8 Account (org.ethereum.core.Account)7 BlockExecutor (co.rsk.core.bc.BlockExecutor)6 BlockChainBuilder (co.rsk.test.builders.BlockChainBuilder)6 Keccak256 (co.rsk.crypto.Keccak256)5 Block (org.ethereum.core.Block)5 DataWord (org.ethereum.vm.DataWord)5 ProgramInvoke (org.ethereum.vm.program.invoke.ProgramInvoke)5 BlockGenerator (co.rsk.blockchain.utils.BlockGenerator)4 RskSystemProperties (co.rsk.config.RskSystemProperties)4