Examples of DataWord


Examples of org.ethereum.vm.DataWord

        Repository repository = worldManager.getRepository();

        repository.createAccount(addr);
        repository.saveCode(addr, code);
        byte[] keyBytes = Hex.decode("cd2a3d9f938e13cd947ec05abc7fe734df8dd826");
        DataWord key = new DataWord(keyBytes);
        byte[] valueBytes = Hex.decode("0F4240");
        DataWord value = new DataWord(valueBytes);
        repository.addStorageRow(addr, key, value);
        DataWord fetchedValue = repository.getStorageValue(addr, key);
        assertEquals(value, fetchedValue);
    }
View Full Code Here

Examples of org.ethereum.vm.DataWord

        repository.createAccount(addr);
        repository.saveCode(addr, code);

        byte[] keyBytes = Hex.decode("03E8");
        DataWord key1 = new DataWord(keyBytes);

        keyBytes = Hex.decode("03E9");
        DataWord key2 = new DataWord(keyBytes);

        keyBytes = Hex.decode("03F0");
        DataWord key3 = new DataWord(keyBytes);

        byte[] valueBytes = Hex.decode("0F4240");
        DataWord value1 = new DataWord(valueBytes);

        valueBytes = Hex.decode("0F4241");
        DataWord value2 = new DataWord(valueBytes);

        valueBytes = Hex.decode("0F4242");
        DataWord value3 = new DataWord(valueBytes);

        repository.addStorageRow(addr, key1, value1);
        repository.addStorageRow(addr, key2, value2);
        repository.addStorageRow(addr, key3, value3);

        DataWord fetchedValue1 = repository.getStorageValue(addr, key1);
        DataWord fetchedValue2 = repository.getStorageValue(addr, key2);
        DataWord fetchedValue3 = repository.getStorageValue(addr, key3);

        AccountState accountState = repository.getAccountState(addr);
        String stateRoot = Hex.toHexString(accountState.getStateRoot());

        assertEquals(value1, fetchedValue1);
View Full Code Here

Examples of org.ethereum.vm.DataWord

        repository.addBalance(Hex.decode(addr_1), BigInteger.valueOf(expectedBalance));
        repository.startTracking();

        repository.createAccount(Hex.decode(addr_2));
        repository.saveCode(Hex.decode(addr_2), Hex.decode(codeString));
        repository.addStorageRow(Hex.decode(addr_2), new DataWord(101), new DataWord(1000001));
        repository.addStorageRow(Hex.decode(addr_2), new DataWord(102), new DataWord(1000002));
        repository.addStorageRow(Hex.decode(addr_2), new DataWord(103), new DataWord(1000003));
        repository.rollback();

        BigInteger balance =  repository.getBalance(Hex.decode(addr_1));
        assertEquals(expectedBalance, balance.longValue());

        DataWord value = repository.getStorageValue(Hex.decode(addr_2), new DataWord(101));
        assertNull(value);
    }
View Full Code Here

Examples of org.ethereum.vm.DataWord

     
      int ITERATIONS = 10000000;
     
      long now1 = System.currentTimeMillis();
      for (int i = 0; i < ITERATIONS; i++) {
        DataWord x = new DataWord(one);
        x.add(x);
      }
      System.out.println("Add1: " + (System.currentTimeMillis() - now1) + "ms");
       
      long now2 = System.currentTimeMillis();
      for (int i = 0; i < ITERATIONS; i++) {
        DataWord x = new DataWord(one);
        x.add2(x);
      }
      System.out.println("Add2: " + (System.currentTimeMillis() - now2) + "ms");
    } else {
      System.out.println("ADD performance test is disabled.");
    }
View Full Code Here

Examples of org.ethereum.vm.DataWord

  @Test
  public void testAdd2() {
    byte[] two = new byte[32];
    two[31] = (byte) 0xff; // 0x000000000000000000000000000000000000000000000000000000000000ff
   
    DataWord x = new DataWord(two);
    x.add(new DataWord(two));
    System.out.println(Hex.toHexString(x.getData()));
   
    DataWord y = new DataWord(two);
    y.add2(new DataWord(two));
    System.out.println(Hex.toHexString(y.getData()));
  }
View Full Code Here

Examples of org.ethereum.vm.DataWord

    byte[] three = new byte[32];
    for (int i = 0; i < three.length; i++) {
      three[i] = (byte) 0xff;
    }
   
    DataWord x = new DataWord(three);
    x.add(new DataWord(three));
    assertEquals(32, x.getData().length);
    System.out.println(Hex.toHexString(x.getData()));

    // FAIL
//    DataWord y = new DataWord(three);
//    y.add2(new DataWord(three));
//    System.out.println(Hex.toHexString(y.getData()));
View Full Code Here

Examples of org.ethereum.vm.DataWord

    for (int i = 0; i < two.length; i++) {
      two[i] = (byte) 0xff;
    }
    two[31] = 0x56; // 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff56
   
    DataWord x = new DataWord(one);// System.out.println(x.value());
    DataWord y = new DataWord(two);// System.out.println(y.value());
    y.mod(x);
    assertEquals(32, y.getData().length);
    assertEquals(expected, Hex.toHexString(y.getData()));
  }
View Full Code Here

Examples of org.ethereum.vm.DataWord

    one[31] = 0x1; // 0x0000000000000000000000000000000000000000000000000000000000000001

    byte[] two = new byte[32];
    two[11] = 0x1; // 0x0000000000000000000000010000000000000000000000000000000000000000

    DataWord x = new DataWord(one);// System.out.println(x.value());
    DataWord y = new DataWord(two);// System.out.println(y.value());
    x.mul(y);
    assertEquals(32, y.getData().length);
    assertEquals("0000000000000000000000010000000000000000000000000000000000000000", Hex.toHexString(y.getData()));
  }
View Full Code Here

Examples of org.ethereum.vm.DataWord

    one[30] = 0x1; // 0x0000000000000000000000000000000000000000000000000000000000000100

    byte[] two = new byte[32];
    two[0] = 0x1; //  0x1000000000000000000000000000000000000000000000000000000000000000

    DataWord x = new DataWord(one);// System.out.println(x.value());
    DataWord y = new DataWord(two);// System.out.println(y.value());
    x.mul(y);
    assertEquals(32, y.getData().length);
    assertEquals("0100000000000000000000000000000000000000000000000000000000000000", Hex.toHexString(y.getData()));
  }
View Full Code Here

Examples of org.ethereum.vm.DataWord

  }
 
  @Test
  public void testSignExtend1() {

    DataWord x = new DataWord(Hex.decode("f2"));
    byte k = 0;
    String expected = "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2";

    x.signExtend(k);
    System.out.println(x.toString());
    assertEquals(expected, x.toString());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.