Search in sources :

Example 11 with Stack

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

the class VMExecutionTest method testJumpSkippingInvalidJump.

@Test
public void testJumpSkippingInvalidJump() {
    Program program = executeCode("PUSH1 0x05 JUMP PUSH1 0xa0 JUMPDEST PUSH1 0x01", 4);
    Stack stack = program.getStack();
    Assert.assertEquals(1, stack.size());
    Assert.assertEquals(new DataWord(1), 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 12 with Stack

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

the class VMExecutionTest method dupnFourthItem.

@Test
public void dupnFourthItem() {
    Program program = executeCode("PUSH1 0x01 PUSH1 0x02 PUSH1 0x03 PUSH1 0x04 PUSH1 0x03 DUPN", 6);
    Stack stack = program.getStack();
    Assert.assertEquals(5, stack.size());
    Assert.assertEquals(new DataWord(1), stack.peek());
    for (int k = 0; k < 4; 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 13 with Stack

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

the class VMExecutionTest method testPush1.

@Test
public void testPush1() {
    Program program = executeCode("PUSH1 0xa0", 1);
    Stack stack = program.getStack();
    Assert.assertEquals(1, stack.size());
    Assert.assertEquals(new DataWord(0xa0), 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)

Aggregations

Program (org.ethereum.vm.program.Program)13 Stack (org.ethereum.vm.program.Stack)13 DataWord (org.ethereum.vm.DataWord)12 Test (org.junit.Test)12 VmConfig (co.rsk.config.VmConfig)1 RskAddress (co.rsk.core.RskAddress)1 BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1 HashUtil (org.ethereum.crypto.HashUtil)1 ContractDetails (org.ethereum.db.ContractDetails)1 EMPTY_BYTE_ARRAY (org.ethereum.util.ByteUtil.EMPTY_BYTE_ARRAY)1 MsgType (org.ethereum.vm.MessageCall.MsgType)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 Hex (org.spongycastle.util.encoders.Hex)1