use of org.ethereum.vm.program.Program in project rskj by rsksmart.
the class VMExecutionTest method swapnFourthItem.
@Test
public void swapnFourthItem() {
Program program = executeCode("PUSH1 0x01 PUSH1 0x02 PUSH1 0x03 PUSH1 0x04 PUSH1 0x02 SWAPN", 6);
Stack stack = program.getStack();
Assert.assertEquals(4, stack.size());
Assert.assertEquals(new DataWord(1), stack.peek());
Assert.assertEquals(new DataWord(4), stack.get(0));
Assert.assertEquals(new DataWord(2), stack.get(1));
Assert.assertEquals(new DataWord(3), stack.get(2));
}
use of org.ethereum.vm.program.Program in project rskj by rsksmart.
the class VMExecutionTest method callDataCopyBasicGasCost.
@Test
public void callDataCopyBasicGasCost() {
Program program = executeCode(// push some values for CALLDATACOPY
"PUSH1 0x00 PUSH1 0x00 PUSH1 0x01 " + // call CALLDATACOPY
"0x37", 4);
Assert.assertNotNull(program);
Assert.assertNotNull(program.getResult());
Assert.assertNull(program.getResult().getException());
Assert.assertEquals(12, program.getResult().getGasUsed());
}
use of org.ethereum.vm.program.Program in project rskj by rsksmart.
the class VMExecutionTest method testSub.
@Test
public void testSub() {
Program program = executeCode("PUSH1 1 PUSH1 2 SUB", 3);
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 executeCode.
private Program executeCode(byte[] code, int nsteps) {
VM vm = new VM(vmConfig, precompiledContracts);
Program program = new Program(vmConfig, precompiledContracts, mock(BlockchainConfig.class), code, invoke, null);
for (int k = 0; k < nsteps; k++) vm.step(program);
return program;
}
use of org.ethereum.vm.program.Program in project rskj by rsksmart.
the class VMExecutionTest method testCode.
private void testCode(byte[] code, int nsteps, String expected) {
Program program = executeCode(code, nsteps);
assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase());
}
Aggregations