Search in sources :

Example 1 with Program

use of org.ethereum.vm.program.Program in project rskj by rsksmart.

the class VMExecutionTest method swapnSecondItem.

@Test
public void swapnSecondItem() {
    Program program = executeCode("PUSH1 0x01 PUSH1 0x02 PUSH1 0x00 SWAPN", 4);
    Stack stack = program.getStack();
    Assert.assertEquals(2, stack.size());
    Assert.assertEquals(new DataWord(1), stack.peek());
    Assert.assertEquals(new DataWord(2), stack.get(0));
}
Also used : Program(org.ethereum.vm.program.Program) DataWord(org.ethereum.vm.DataWord) Stack(org.ethereum.vm.program.Stack) Test(org.junit.Test)

Example 2 with Program

use of org.ethereum.vm.program.Program in project rskj by rsksmart.

the class VMExecutionTest method testMul.

@Test
public void testMul() {
    Program program = executeCode("PUSH1 3 PUSH1 2 MUL", 3);
    Stack stack = program.getStack();
    Assert.assertEquals(1, stack.size());
    Assert.assertEquals(new DataWord(6), stack.peek());
}
Also used : Program(org.ethereum.vm.program.Program) DataWord(org.ethereum.vm.DataWord) Stack(org.ethereum.vm.program.Stack) Test(org.junit.Test)

Example 3 with Program

use of org.ethereum.vm.program.Program in project rskj by rsksmart.

the class VMExecutionTest method testAdd.

@Test
public void testAdd() {
    Program program = executeCode("PUSH1 1 PUSH1 2 ADD", 3);
    Stack stack = program.getStack();
    Assert.assertEquals(1, stack.size());
    Assert.assertEquals(new DataWord(3), stack.peek());
}
Also used : Program(org.ethereum.vm.program.Program) DataWord(org.ethereum.vm.DataWord) Stack(org.ethereum.vm.program.Stack) Test(org.junit.Test)

Example 4 with Program

use of org.ethereum.vm.program.Program in project rskj by rsksmart.

the class VMExecutionTest method dupnTwentiethItem.

@Test
public void dupnTwentiethItem() {
    Program program = executeCode("PUSH1 0x01 PUSH1 0x02 PUSH1 0x03 PUSH1 0x04 PUSH1 0x05 PUSH1 0x06 PUSH1 0x07 PUSH1 0x08 PUSH1 0x09 PUSH1 0x0a PUSH1 0x0b PUSH1 0x0c PUSH1 0x0d PUSH1 0x0e PUSH1 0x0f PUSH1 0x10 PUSH1 0x11 PUSH1 0x12 PUSH1 0x13 PUSH1 0x14 PUSH1 0x13 DUPN", 22);
    Stack stack = program.getStack();
    Assert.assertEquals(21, stack.size());
    Assert.assertEquals(new DataWord(1), stack.peek());
    for (int k = 0; k < 20; k++) Assert.assertEquals(new DataWord(k + 1), stack.get(k));
}
Also used : Program(org.ethereum.vm.program.Program) DataWord(org.ethereum.vm.DataWord) Stack(org.ethereum.vm.program.Stack) Test(org.junit.Test)

Example 5 with Program

use of org.ethereum.vm.program.Program in project rskj by rsksmart.

the class VMExecutionTest method returnDataSizeBasicGasCost.

@Test
public void returnDataSizeBasicGasCost() {
    Program program = executeCode("0x3d", 1);
    Assert.assertNotNull(program);
    Assert.assertNotNull(program.getResult());
    Assert.assertNull(program.getResult().getException());
    Assert.assertEquals(2, program.getResult().getGasUsed());
}
Also used : Program(org.ethereum.vm.program.Program) Test(org.junit.Test)

Aggregations

Program (org.ethereum.vm.program.Program)37 Test (org.junit.Test)27 RskAddress (co.rsk.core.RskAddress)14 DataWord (org.ethereum.vm.DataWord)13 Stack (org.ethereum.vm.program.Stack)13 Coin (co.rsk.core.Coin)12 BigInteger (java.math.BigInteger)12 Repository (org.ethereum.core.Repository)10 ProgramInvokeMockImpl (org.ethereum.vm.program.invoke.ProgramInvokeMockImpl)9 Ignore (org.junit.Ignore)9 BlockchainConfig (org.ethereum.config.BlockchainConfig)7 AccountState (org.ethereum.core.AccountState)5 ProgramInvoke (org.ethereum.vm.program.invoke.ProgramInvoke)4 ContractDetails (org.ethereum.db.ContractDetails)3 VM (org.ethereum.vm.VM)3 RskSystemProperties (co.rsk.config.RskSystemProperties)2 VmConfig (co.rsk.config.VmConfig)2 IOException (java.io.IOException)2 List (java.util.List)2 EMPTY_BYTE_ARRAY (org.ethereum.util.ByteUtil.EMPTY_BYTE_ARRAY)2