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


Java Memory.readByte方法代码示例

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


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

示例1: 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

示例2: memoryWriteLimited_1

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

    Memory memoryBuffer = new Memory();
    memoryBuffer.extend(0, 3072);

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

    memoryBuffer.write(2720, data1, data1.length, true);

    byte lastZero = memoryBuffer.readByte(2719);
    byte firstOne = memoryBuffer.readByte(2721);

    assertTrue(memoryBuffer.size() == 3072);
    assertTrue(lastZero == 0);
    assertTrue(firstOne == 1);

    byte[] data = memoryBuffer.read(2720, 352);

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

    assertTrue(ones == data.length);
    assertTrue(zero == 0);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:30,代码来源:MemoryTest.java

示例3: memoryWriteLimited_2

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

    Memory memoryBuffer = new Memory();
    memoryBuffer.extend(0, 3072);

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

    memoryBuffer.write(2720, data1, 300, true);

    byte lastZero = memoryBuffer.readByte(2719);
    byte firstOne = memoryBuffer.readByte(2721);

    assertTrue(memoryBuffer.size() == 3072);
    assertTrue(lastZero == 0);
    assertTrue(firstOne == 1);

    byte[] data = memoryBuffer.read(2720, 352);

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

    assertTrue(ones == 300);
    assertTrue(zero == 52);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:30,代码来源:MemoryTest.java

示例4: memoryWriteLimited_3

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

    Memory memoryBuffer = new Memory();
    memoryBuffer.extend(0, 128);

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

    memoryBuffer.write(10, data1, 40, true);

    byte lastZero = memoryBuffer.readByte(9);
    byte firstOne = memoryBuffer.readByte(10);

    assertTrue(memoryBuffer.size() == 128);
    assertTrue(lastZero == 0);
    assertTrue(firstOne == 1);

    byte[] data = memoryBuffer.read(10, 30);

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

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


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