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


Java Memory.write方法代码示例

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


在下文中一共展示了Memory.write方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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:Aptoide,项目名称:AppCoins-ethereumj,代码行数:21,代码来源: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_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

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

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

示例10: 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:Aptoide,项目名称:AppCoins-ethereumj,代码行数:30,代码来源:MemoryTest.java

示例11: 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:Aptoide,项目名称:AppCoins-ethereumj,代码行数:30,代码来源:MemoryTest.java

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

示例13: 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:Aptoide,项目名称:AppCoins-ethereumj,代码行数:33,代码来源:MemoryTest.java

示例14: memorySave_5

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

    Memory memoryBuffer = new Memory();

    byte[] data = new byte[1025];
    Arrays.fill(data, (byte) 1);

    memoryBuffer.write(0, data, data.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] == 1);
    assertTrue(chunk2[1] == 0);

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


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