本文整理汇总了Java中org.ethereum.vm.program.Memory.read方法的典型用法代码示例。如果您正苦于以下问题:Java Memory.read方法的具体用法?Java Memory.read怎么用?Java Memory.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ethereum.vm.program.Memory
的用法示例。
在下文中一共展示了Memory.read方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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());
}
示例2: 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());
}
示例3: 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());
}
示例4: memoryChunk_4
import org.ethereum.vm.program.Memory; //导入方法依赖的package包/类
@Test
public void memoryChunk_4(){
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, 2049);
int ones = 0; int twos = 0; int zero = 0;
for (int i = 0; i < data.length; ++i){
if (data[i] == 1) ++ones;
if (data[i] == 2) ++twos;
if (data[i] == 0) ++zero;
}
assertTrue(zero == 1);
assertTrue(ones == twos);
assertTrue(2080 == memoryBuffer.size());
}
示例5: 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);
}
示例6: 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);
}
示例7: 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);
}