当前位置: 首页>>代码示例>>Java>>正文


Java Memory类代码示例

本文整理汇总了Java中org.ethereum.vm.program.Memory的典型用法代码示例。如果您正苦于以下问题:Java Memory类的具体用法?Java Memory怎么用?Java Memory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Memory类属于org.ethereum.vm.program包,在下文中一共展示了Memory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: memorySave_1

import org.ethereum.vm.program.Memory; //导入依赖的package包/类
@Test
public void memorySave_1() {

    Memory memoryBuffer = new Memory();
    byte[] data = {1, 1, 1, 1};

    memoryBuffer.write(0, data, data.length, false);

    assertTrue(1 == memoryBuffer.getChunks().size());

    byte[] chunk = memoryBuffer.getChunks().get(0);
    assertTrue(chunk[0] == 1);
    assertTrue(chunk[1] == 1);
    assertTrue(chunk[2] == 1);
    assertTrue(chunk[3] == 1);
    assertTrue(chunk[4] == 0);

    assertTrue(memoryBuffer.size() == 32);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:20,代码来源:MemoryTest.java

示例2: memorySave_2

import org.ethereum.vm.program.Memory; //导入依赖的package包/类
@Test
public void memorySave_2() {

    Memory memoryBuffer = new Memory();
    byte[] data = Hex.decode("0101010101010101010101010101010101010101010101010101010101010101");

    memoryBuffer.write(0, data, data.length, false);

    assertTrue(1 == memoryBuffer.getChunks().size());

    byte[] chunk = memoryBuffer.getChunks().get(0);
    assertTrue(chunk[0] == 1);
    assertTrue(chunk[1] == 1);

    assertTrue(chunk[30] == 1);
    assertTrue(chunk[31] == 1);
    assertTrue(chunk[32] == 0);

    assertTrue(memoryBuffer.size() == 32);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:21,代码来源:MemoryTest.java

示例3: memorySave_3

import org.ethereum.vm.program.Memory; //导入依赖的package包/类
@Test
public void memorySave_3() {

    Memory memoryBuffer = new Memory();
    byte[] data = Hex.decode("010101010101010101010101010101010101010101010101010101010101010101");

    memoryBuffer.write(0, data, data.length, false);

    assertTrue(1 == memoryBuffer.getChunks().size());

    byte[] chunk = memoryBuffer.getChunks().get(0);
    assertTrue(chunk[0] == 1);
    assertTrue(chunk[1] == 1);

    assertTrue(chunk[30] == 1);
    assertTrue(chunk[31] == 1);
    assertTrue(chunk[32] == 1);
    assertTrue(chunk[33] == 0);

    assertTrue(memoryBuffer.size() == 64);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:22,代码来源:MemoryTest.java

示例4: memorySave_4

import org.ethereum.vm.program.Memory; //导入依赖的package包/类
@Test
public void memorySave_4() {

    Memory memoryBuffer = new Memory();
    byte[] data = new byte[1024];
    Arrays.fill(data, (byte) 1);

    memoryBuffer.write(0, data, data.length, false);

    assertTrue(1 == memoryBuffer.getChunks().size());

    byte[] chunk = memoryBuffer.getChunks().get(0);
    assertTrue(chunk[0] == 1);
    assertTrue(chunk[1] == 1);

    assertTrue(chunk[1022] == 1);
    assertTrue(chunk[1023] == 1);

    assertTrue(memoryBuffer.size() == 1024);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:21,代码来源:MemoryTest.java

示例5: memorySave_8

import org.ethereum.vm.program.Memory; //导入依赖的package包/类
@Test
public void memorySave_8() {

    Memory memoryBuffer = new Memory();

    byte[] data1 = new byte[128];
    Arrays.fill(data1, (byte) 1);

    memoryBuffer.extendAndWrite(0, 256, data1);

    int ones = 0; int zeroes = 0;
    for (int i = 0; i < memoryBuffer.size(); ++i){
        if (memoryBuffer.readByte(i) == 1) ++ones;
        if (memoryBuffer.readByte(i) == 0) ++zeroes;
    }

    assertTrue(ones == zeroes);
    assertTrue(256 == memoryBuffer.size());
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:20,代码来源:MemoryTest.java

示例6: memoryChunk_1

import org.ethereum.vm.program.Memory; //导入依赖的package包/类
@Test
public void memoryChunk_1(){
    Memory memoryBuffer = new Memory();

    byte[] data1 = new byte[32];
    Arrays.fill(data1, (byte) 1);

    byte[] data2 = new byte[32];
    Arrays.fill(data2, (byte) 2);

    memoryBuffer.write(0, data1, data1.length, false);
    memoryBuffer.write(32, data2, data2.length, false);

    byte[] data = memoryBuffer.read(0, 64);

    assertArrayEquals(
            Hex.decode("0101010101010101010101010101010101010101010101010101010101010101" +
                    "0202020202020202020202020202020202020202020202020202020202020202"),
            data
    );

    assertEquals(64, memoryBuffer.size());
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:24,代码来源:MemoryTest.java

示例7: memoryChunk_2

import org.ethereum.vm.program.Memory; //导入依赖的package包/类
@Test
public void memoryChunk_2(){
    Memory memoryBuffer = new Memory();

    byte[] data1 = new byte[32];
    Arrays.fill(data1, (byte) 1);

    memoryBuffer.write(0, data1, data1.length, false);
    assertTrue(32 == memoryBuffer.size());

    byte[] data = memoryBuffer.read(0, 64);

    assertArrayEquals(
            Hex.decode("0101010101010101010101010101010101010101010101010101010101010101" +
                    "0000000000000000000000000000000000000000000000000000000000000000"),
            data
    );

    assertEquals(64, memoryBuffer.size());
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:21,代码来源:MemoryTest.java

示例8: memoryChunk_3

import org.ethereum.vm.program.Memory; //导入依赖的package包/类
@Test
public void memoryChunk_3(){

    Memory memoryBuffer = new Memory();

    byte[] data1 = new byte[1024];
    Arrays.fill(data1, (byte) 1);

    byte[] data2 = new byte[1024];
    Arrays.fill(data2, (byte) 2);

    memoryBuffer.write(0, data1, data1.length, false);
    memoryBuffer.write(1024, data2, data2.length, false);

    byte[] data = memoryBuffer.read(0, 2048);

    int ones = 0; int twos = 0;
    for (int i = 0; i < data.length; ++i){
        if (data[i] == 1) ++ones;
        if (data[i] == 2) ++twos;
    }

    assertTrue(ones == twos);
    assertTrue(2048 == memoryBuffer.size());
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:26,代码来源:MemoryTest.java

示例9: memorySave_6

import org.ethereum.vm.program.Memory; //导入依赖的package包/类
@Test
public void memorySave_6() {

    Memory memoryBuffer = new Memory();

    byte[] data1 = new byte[1024];
    Arrays.fill(data1, (byte) 1);

    byte[] data2 = new byte[1024];
    Arrays.fill(data2, (byte) 2);

    memoryBuffer.write(0, data1, data1.length, false);
    memoryBuffer.write(1024, data2, data2.length, false);

    assertTrue(2 == memoryBuffer.getChunks().size());

    byte[] chunk1 = memoryBuffer.getChunks().get(0);
    assertTrue(chunk1[0] == 1);
    assertTrue(chunk1[1] == 1);

    assertTrue(chunk1[1022] == 1);
    assertTrue(chunk1[1023] == 1);

    byte[] chunk2 = memoryBuffer.getChunks().get(1);
    assertTrue(chunk2[0] == 2);
    assertTrue(chunk2[1] == 2);

    assertTrue(chunk2[1022] == 2);
    assertTrue(chunk2[1023] == 2);

    assertTrue(memoryBuffer.size() == 2048);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:33,代码来源:MemoryTest.java

示例10: memorySave_7

import org.ethereum.vm.program.Memory; //导入依赖的package包/类
@Test
public void memorySave_7() {

    Memory memoryBuffer = new Memory();

    byte[] data1 = new byte[1024];
    Arrays.fill(data1, (byte) 1);

    byte[] data2 = new byte[1024];
    Arrays.fill(data2, (byte) 2);

    byte[] data3 = new byte[1];
    Arrays.fill(data3, (byte) 3);

    memoryBuffer.write(0, data1, data1.length, false);
    memoryBuffer.write(1024, data2, data2.length, false);
    memoryBuffer.write(2048, data3, data3.length, false);

    assertTrue(3 == memoryBuffer.getChunks().size());

    byte[] chunk1 = memoryBuffer.getChunks().get(0);
    assertTrue(chunk1[0] == 1);
    assertTrue(chunk1[1] == 1);

    assertTrue(chunk1[1022] == 1);
    assertTrue(chunk1[1023] == 1);

    byte[] chunk2 = memoryBuffer.getChunks().get(1);
    assertTrue(chunk2[0] == 2);
    assertTrue(chunk2[1] == 2);

    assertTrue(chunk2[1022] == 2);
    assertTrue(chunk2[1023] == 2);

    byte[] chunk3 = memoryBuffer.getChunks().get(2);
    assertTrue(chunk3[0] == 3);

    assertTrue(memoryBuffer.size() == 2080);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:40,代码来源:MemoryTest.java

示例11: memoryLoad_1

import org.ethereum.vm.program.Memory; //导入依赖的package包/类
@Test
public void memoryLoad_1() {

    Memory memoryBuffer = new Memory();
    DataWord value = memoryBuffer.readWord(100);
    assertTrue(value.intValue() == 0);
    assertTrue(memoryBuffer.getChunks().size() == 1);
    assertTrue(memoryBuffer.size() == 32 * 5);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:10,代码来源:MemoryTest.java

示例12: memoryLoad_2

import org.ethereum.vm.program.Memory; //导入依赖的package包/类
@Test
public void memoryLoad_2() {

    Memory memoryBuffer = new Memory();
    DataWord value = memoryBuffer.readWord(2015);
    assertTrue(value.intValue() == 0);
    assertTrue(memoryBuffer.getChunks().size() == 2);
    assertTrue(memoryBuffer.size() == 2048);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:10,代码来源:MemoryTest.java

示例13: memoryLoad_3

import org.ethereum.vm.program.Memory; //导入依赖的package包/类
@Test
public void memoryLoad_3() {

    Memory memoryBuffer = new Memory();
    DataWord value = memoryBuffer.readWord(2016);
    assertTrue(value.intValue() == 0);
    assertTrue(memoryBuffer.getChunks().size() == 2);
    assertTrue(memoryBuffer.size() == 2048);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:10,代码来源:MemoryTest.java

示例14: memoryLoad_4

import org.ethereum.vm.program.Memory; //导入依赖的package包/类
@Test
public void memoryLoad_4() {

    Memory memoryBuffer = new Memory();
    DataWord value = memoryBuffer.readWord(2017);
    assertTrue(value.intValue() == 0);
    assertTrue(memoryBuffer.getChunks().size() == 3);
    assertTrue(memoryBuffer.size() == 2080);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:10,代码来源:MemoryTest.java

示例15: memoryLoad_5

import org.ethereum.vm.program.Memory; //导入依赖的package包/类
@Test
public void memoryLoad_5() {

    Memory memoryBuffer = new Memory();

    byte[] data1 = new byte[1024];
    Arrays.fill(data1, (byte) 1);

    byte[] data2 = new byte[1024];
    Arrays.fill(data2, (byte) 2);

    memoryBuffer.write(0, data1, data1.length, false);
    memoryBuffer.write(1024, data2, data2.length, false);

    assertTrue(memoryBuffer.getChunks().size() == 2);
    assertTrue(memoryBuffer.size() == 2048);

    DataWord val1 = memoryBuffer.readWord(0x3df);
    DataWord val2 = memoryBuffer.readWord(0x3e0);
    DataWord val3 = memoryBuffer.readWord(0x3e1);

    assertArrayEquals(
            Hex.decode("0101010101010101010101010101010101010101010101010101010101010101"),
            val1.getData());

    assertArrayEquals(
            Hex.decode("0101010101010101010101010101010101010101010101010101010101010101"),
            val2.getData());

    assertArrayEquals(
            Hex.decode("0101010101010101010101010101010101010101010101010101010101010102"),
            val3.getData());
    assertTrue(memoryBuffer.size() == 2048);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:35,代码来源:MemoryTest.java


注:本文中的org.ethereum.vm.program.Memory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。