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


Java ByteUtil.appendByte方法代码示例

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


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

示例1: testDUPN_1

import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
/**
 * Generic test function for DUP1-16
 *
 * @param n in DUPn
 */
private void testDUPN_1(int n) {

    VM vm = new VM(ConfigHelper.CONFIG);
    byte operation = (byte) (OpCode.DUP1.val() + n - 1);
    String programCode = "";
    for (int i = 0; i < n; i++) {
        programCode += "60" + (12 + i);
    }
    program = new Program(ConfigHelper.CONFIG, ByteUtil.appendByte(Hex.decode(programCode.getBytes()), operation), invoke);
    String expected = "0000000000000000000000000000000000000000000000000000000000000012";
    int expectedLen = n + 1;

    for (int i = 0; i < expectedLen; i++) {
        vm.step(program);
    }

    assertEquals(expectedLen, program.getStack().toArray().length);
    assertEquals(expected, Hex.toHexString(program.stackPop().getData()).toUpperCase());
    for (int i = 0; i < expectedLen - 2; i++) {
        assertNotEquals(expected, Hex.toHexString(program.stackPop().getData()).toUpperCase());
    }
    assertEquals(expected, Hex.toHexString(program.stackPop().getData()).toUpperCase());
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:29,代码来源:VMTest.java

示例2: testSWAPN_1

import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
/**
 * Generic test function for SWAP1-16
 *
 * @param n in SWAPn
 */
private void testSWAPN_1(int n) {

    VM vm = new VM(ConfigHelper.CONFIG);
    byte operation = (byte) (OpCode.SWAP1.val() + n - 1);

    String programCode = "";
    String top = new DataWord(0x10 + n).toString();
    for (int i = n; i > -1; --i) {
        programCode += "60" + oneByteToHexString((byte) (0x10 + i));

    }

    programCode += Hex.toHexString(new byte[]{   (byte)(OpCode.SWAP1.val() + n - 1)   });

    program = new Program(ConfigHelper.CONFIG, ByteUtil.appendByte(Hex.decode(programCode), operation), invoke);

    for (int i = 0; i < n + 2; ++i) {
        vm.step(program);
    }

    assertEquals(n + 1, program.getStack().toArray().length);
    assertEquals(top, Hex.toHexString(program.stackPop().getData()));
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:29,代码来源:VMTest.java

示例3: testDUPN_1

import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
/**
 * Generic test function for DUP1-16
 *
 * @param n in DUPn
 */
private void testDUPN_1(int n) {

    VM vm = new VM();
    byte operation = (byte) (OpCode.DUP1.val() + n - 1);
    String programCode = "";
    for (int i = 0; i < n; i++) {
        programCode += "60" + (12 + i);
    }
    program = new Program(ByteUtil.appendByte(Hex.decode(programCode.getBytes()), operation), invoke);
    String expected = "0000000000000000000000000000000000000000000000000000000000000012";
    int expectedLen = n + 1;

    for (int i = 0; i < expectedLen; i++) {
        vm.step(program);
    }

    assertEquals(expectedLen, program.getStack().toArray().length);
    assertEquals(expected, Hex.toHexString(program.stackPop().getData()).toUpperCase());
    for (int i = 0; i < expectedLen - 2; i++) {
        assertNotEquals(expected, Hex.toHexString(program.stackPop().getData()).toUpperCase());
    }
    assertEquals(expected, Hex.toHexString(program.stackPop().getData()).toUpperCase());
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:29,代码来源:VMTest.java

示例4: testSWAPN_1

import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
/**
 * Generic test function for SWAP1-16
 *
 * @param n in SWAPn
 */
private void testSWAPN_1(int n) {

    VM vm = new VM();
    byte operation = (byte) (OpCode.SWAP1.val() + n - 1);

    String programCode = "";
    String top = new DataWord(0x10 + n).toString();
    for (int i = n; i > -1; --i) {
        programCode += "60" + oneByteToHexString((byte) (0x10 + i));

    }

    programCode += Hex.toHexString(new byte[]{   (byte)(OpCode.SWAP1.val() + n - 1)   });

    program = new Program(ByteUtil.appendByte(Hex.decode(programCode), operation), invoke);

    for (int i = 0; i < n + 2; ++i) {
        vm.step(program);
    }

    assertEquals(n + 1, program.getStack().toArray().length);
    assertEquals(top, Hex.toHexString(program.stackPop().getData()));
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:29,代码来源:VMTest.java


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