Package org.ethereum.vm

Examples of org.ethereum.vm.Program


        repository.saveCode(contractAddrB, codeB);
        repository.addStorageRow(contractAddrB, key1, value1);

        // Play the program
        VM vm = new VM();
        Program program = new Program(codeB, pi);

        try {
            while(!program.isStopped())
                vm.step(program);
        } catch (RuntimeException e) {
            program.setRuntimeFailure(e);
        }

        System.out.println();
        System.out.println("============ Results ============");

        BigInteger balance = repository.getBalance(callerAddrB);

        System.out.println("*** Used gas: " + program.getResult().getGasUsed());
        System.out.println("*** Contract Balance: " + balance);

        // todo: assert caller balance after contract exec

        repository.close();
        assertEquals(expectedGas, program.getResult().getGasUsed());
    }
View Full Code Here


        // ****************** //
        //  Play the program  //
        // ****************** //
        VM vm = new VM();
        Program program = new Program(codeB, pi);

        try {
            while(!program.isStopped())
                vm.step(program);
        } catch (RuntimeException e) {
            program.setRuntimeFailure(e);
        }


        System.out.println();
        System.out.println("============ Results ============");


        System.out.println("*** Used gas: " + program.getResult().getGasUsed());


        DataWord value_1 = repository.getStorageValue(contractA_addr_bytes, new DataWord(00));
        DataWord value_2 = repository.getStorageValue(contractA_addr_bytes, new DataWord(01));

View Full Code Here

        // ****************** //
        //  Play the program  //
        // ****************** //
        VM vm = new VM();
        Program program = new Program(codeB, pi);

        try {
            while(!program.isStopped())
                vm.step(program);
        } catch (RuntimeException e) {
            program.setRuntimeFailure(e);
        }

        System.out.println();
        System.out.println("============ Results ============");
        System.out.println("*** Used gas: " + program.getResult().getGasUsed());

        DataWord value1 = program.memoryLoad(new DataWord(32));
        DataWord value2 = program.memoryLoad(new DataWord(64));
        DataWord value3 = program.memoryLoad(new DataWord(96));
        DataWord value4 = program.memoryLoad(new DataWord(128));
        DataWord value5 = program.memoryLoad(new DataWord(160));
        DataWord value6 = program.memoryLoad(new DataWord(192));

        repository.close();

        assertEquals(expectedVal_1, value1.longValue());
        assertEquals(expectedVal_2, value2.longValue());
View Full Code Here

        // ****************** //
        //  Play the program  //
        // ****************** //
        VM vm = new VM();
        Program program = new Program(codeA, pi);

    try {
      while (!program.isStopped())
        vm.step(program);
    } catch (RuntimeException e) {
      program.setRuntimeFailure(e);
    }

        System.out.println();
        System.out.println("============ Results ============");

        System.out.println("*** Used gas: " + program.getResult().getGasUsed());
        // TODO: check that the value pushed after exec is the new address
        repository.close();
    }
View Full Code Here

        // ****************** //
        //  Play the program  //
        // ****************** //
        VM vm = new VM();
        Program program = new Program(codeB, pi);

        try {
            while(!program.isStopped())
                vm.step(program);
        } catch (RuntimeException e) {
            program.setRuntimeFailure(e);
        }

        System.out.println();
        System.out.println("============ Results ============");
        System.out.println("*** Used gas: " + program.getResult().getGasUsed());

        DataWord memValue1 = program.memoryLoad(new DataWord(0));
        DataWord memValue2 = program.memoryLoad(new DataWord(32));

        DataWord storeValue1 = repository.getStorageValue(contractB_addr_bytes, new DataWord(00));

        repository.close();

View Full Code Here

  Program program;
  ByteBuffer memory;
 
  @Before
  public void createProgram() {
    program = new Program(ByteUtil.EMPTY_BYTE_ARRAY, pi);
  }
View Full Code Here

 
    @Test // CALLDATASIZE OP
    public void testCALLDATASIZE_1() {

        VM vm = new VM();
        program = new Program(Hex.decode("36"), invoke);
        String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000040";

        vm.step(program);

        DataWord item1 = program.stackPop();
View Full Code Here

    @Test // CALLDATALOAD OP
    public void testCALLDATALOAD_1() {

        VM vm = new VM();
        program =
                new Program(Hex.decode("600035"), invoke);
        String s_expected_1 = "00000000000000000000000000000000000000000000000000000000000000A1";

        vm.step(program);
        vm.step(program);
View Full Code Here

    @Test // CALLDATALOAD OP
    public void testCALLDATALOAD_2() {

        VM vm = new VM();
        program =
                new Program(Hex.decode("600235"), invoke);
        String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000A10000";

        vm.step(program);
        vm.step(program);
View Full Code Here

    @Test // CALLDATALOAD OP
    public void testCALLDATALOAD_3() {

        VM vm = new VM();
        program =
                new Program(Hex.decode("602035"), invoke);
        String s_expected_1 = "00000000000000000000000000000000000000000000000000000000000000B1";

        vm.step(program);
        vm.step(program);
View Full Code Here

TOP

Related Classes of org.ethereum.vm.Program

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.