use of org.ethereum.vm.program.Program in project rskj by rsksmart.
the class VMExecutionTest method dupnFirstItem.
@Test
public void dupnFirstItem() {
Program program = executeCode("PUSH1 0x01 PUSH1 0x00 DUPN", 3);
Stack stack = program.getStack();
Assert.assertEquals(2, stack.size());
Assert.assertEquals(new DataWord(1), stack.peek());
Assert.assertEquals(new DataWord(1), stack.get(0));
}
use of org.ethereum.vm.program.Program 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());
}
use of org.ethereum.vm.program.Program 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));
}
use of org.ethereum.vm.program.Program 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());
}
use of org.ethereum.vm.program.Program in project rskj by rsksmart.
the class VMExecutionTest method swapnArgumentIsNotJumpdest.
@Test
public void swapnArgumentIsNotJumpdest() {
byte[] code = compiler.compile("JUMPDEST SWAPN 0x5b 0x5b");
Program program = new Program(vmConfig, precompiledContracts, mock(BlockchainConfig.class), code, invoke, null);
BitSet jumpdestSet = program.getJumpdestSet();
Assert.assertNotNull(jumpdestSet);
Assert.assertEquals(4, jumpdestSet.size());
Assert.assertTrue(jumpdestSet.get(0));
Assert.assertFalse(jumpdestSet.get(1));
Assert.assertTrue(jumpdestSet.get(2));
Assert.assertTrue(jumpdestSet.get(3));
}
Aggregations