VM { public void step(Program program) { if (CONFIG.vmTrace()) { program.saveOpTrace(); } try { OpCode op = OpCode.code(program.getCurrentOp()); if (op == null) { throw Program.Exception.invalidOpCode(program.getCurrentOp()); } program.setLastOp(op.val()); program.stackRequire(op.require()); program.stackMax(op.require(), op.ret()); long oldMemSize = program.getMemSize(); BigInteger newMemSize = BigInteger.ZERO; long copySize = 0; Stack stack = program.getStack(); String hint = ""; long callGas = 0, memWords = 0; long gasCost = op.getTier().asInt(); long gasBefore = program.getGas().longValue(); int stepBefore = program.getPC(); switch (op) { case STOP: case SUICIDE: gasCost = GasCost.STOP; break; case SSTORE: DataWord newValue = stack.get(stack.size() - 2); DataWord oldValue = program.storageLoad(stack.peek()); if (oldValue == null && !newValue.isZero()) gasCost = GasCost.SET_SSTORE; else if (oldValue != null && newValue.isZero()) { program.futureRefundGas(GasCost.REFUND_SSTORE); gasCost = GasCost.CLEAR_SSTORE; } else gasCost = GasCost.RESET_SSTORE; break; case SLOAD: gasCost = GasCost.SLOAD; break; case BALANCE: gasCost = GasCost.BALANCE; break; case MSTORE: newMemSize = memNeeded(stack.peek(), new DataWord(32)); break; case MSTORE8: newMemSize = memNeeded(stack.peek(), new DataWord(1)); break; case MLOAD: newMemSize = memNeeded(stack.peek(), new DataWord(32)); break; case RETURN: gasCost = GasCost.STOP; newMemSize = memNeeded(stack.peek(), stack.get(stack.size() - 2)); break; case SHA3: gasCost = GasCost.SHA3; newMemSize = memNeeded(stack.peek(), stack.get(stack.size() - 2)); DataWord size = stack.get(stack.size() - 2); long chunkUsed = (size.longValue() + 31) / 32; gasCost += chunkUsed * GasCost.SHA3_WORD; break; case CALLDATACOPY: copySize = stack.get(stack.size() - 3).longValue(); newMemSize = memNeeded(stack.peek(), stack.get(stack.size() - 3)); break; case CODECOPY: copySize = stack.get(stack.size() - 3).longValue(); newMemSize = memNeeded(stack.peek(), stack.get(stack.size() - 3)); break; case EXTCODECOPY: copySize = stack.get(stack.size() - 4).longValue(); newMemSize = memNeeded(stack.get(stack.size() - 2), stack.get(stack.size() - 4)); break; case CALL: case CALLCODE: gasCost = GasCost.CALL; DataWord callGasWord = stack.get(stack.size() - 1); if (callGasWord.compareTo(program.getGas()) == 1) { throw Program.Exception.notEnoughOpGas(op, callGasWord, program.getGas()); } gasCost += callGasWord.longValue(); DataWord callAddressWord = stack.get(stack.size() - 2); if (op != CALLCODE && !program.result.getRepository().isExist(callAddressWord.getLast20Bytes())) gasCost += GasCost.NEW_ACCT_CALL; if (!stack.get(stack.size() - 3).isZero() ) gasCost += GasCost.VT_CALL; BigInteger in = memNeeded(stack.get(stack.size() - 4), stack.get(stack.size() - 5)); BigInteger out = memNeeded(stack.get(stack.size() - 6), stack.get(stack.size() - 7)); newMemSize = in.max(out); break; case CREATE: gasCost = GasCost.CREATE; newMemSize = memNeeded(stack.get(stack.size() - 2), stack.get(stack.size() - 3)); break; case LOG0: case LOG1: case LOG2: case LOG3: case LOG4: int nTopics = op.val() - OpCode.LOG0.val(); newMemSize = memNeeded(stack.peek(), stack.get(stack.size() - 2)); BigInteger dataSize = stack.get(stack.size() - 2).value(); BigInteger dataCost = dataSize.multiply(BigInteger.valueOf(GasCost.LOG_DATA_GAS)); if (program.getGas().value().compareTo(dataCost) < 0) { throw Program.Exception.notEnoughOpGas(op, dataCost, program.getGas().value()); } gasCost = GasCost.LOG_GAS + GasCost.LOG_TOPIC_GAS * nTopics + GasCost.LOG_DATA_GAS * stack.get(stack.size() - 2).longValue(); break; case EXP: DataWord exp = stack.get(stack.size() - 2); int bytesOccupied = exp.bytesOccupied(); gasCost = GasCost.EXP_GAS + GasCost.EXP_BYTE_GAS * bytesOccupied; break; default: break; } program.spendGas(gasCost, op.name()); if (newMemSize.compareTo(MAX_GAS) == 1) { throw Program.Exception.gasOverflow(newMemSize, MAX_GAS); } long memoryUsage = (newMemSize.longValue() + 31) / 32 * 32; if (memoryUsage > oldMemSize) { memWords = (memoryUsage / 32); long memWordsOld = (oldMemSize / 32); long memGas = ( GasCost.MEMORY * memWords + memWords * memWords / 512) - (GasCost.MEMORY * memWordsOld + memWordsOld * memWordsOld / 512); program.spendGas(memGas, op.name() + " (memory usage)"); gasCost += memGas; } if (copySize > 0) { long copyGas = GasCost.COPY_GAS * ((copySize + 31) / 32); gasCost += copyGas; program.spendGas(copyGas, op.name() + " (copy usage)"); } if (program.getNumber().intValue() == CONFIG.dumpBlock()) this.dumpLine(op, gasBefore, gasCost + callGas, memWords, program); switch (op) { case STOP: { program.setHReturn(EMPTY_BYTE_ARRAY); program.stop(); } break; case ADD: { DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); if (logger.isInfoEnabled()) hint = word1.value() + " + " + word2.value(); word1.add(word2); program.stackPush(word1); program.step(); } break; case MUL: { DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); if (logger.isInfoEnabled()) hint = word1.value() + " * " + word2.value(); word1.mul(word2); program.stackPush(word1); program.step(); } break; case SUB: { DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); if (logger.isInfoEnabled()) hint = word1.value() + " - " + word2.value(); word1.sub(word2); program.stackPush(word1); program.step(); } break; case DIV: { DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); if (logger.isInfoEnabled()) hint = word1.value() + " / " + word2.value(); word1.div(word2); program.stackPush(word1); program.step(); } break; case SDIV: { DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); if (logger.isInfoEnabled()) hint = word1.sValue() + " / " + word2.sValue(); word1.sDiv(word2); program.stackPush(word1); program.step(); } break; case MOD: { DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); if (logger.isInfoEnabled()) hint = word1.value() + " % " + word2.value(); word1.mod(word2); program.stackPush(word1); program.step(); } break; case SMOD: { DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); if (logger.isInfoEnabled()) hint = word1.sValue() + " #% " + word2.sValue(); word1.sMod(word2); program.stackPush(word1); program.step(); } break; case EXP: { DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); if (logger.isInfoEnabled()) hint = word1.value() + " ** " + word2.value(); word1.exp(word2); program.stackPush(word1); program.step(); } break; case SIGNEXTEND: { DataWord word1 = program.stackPop(); BigInteger k = word1.value(); if (k.compareTo(_32_) < 0) { DataWord word2 = program.stackPop(); if (logger.isInfoEnabled()) hint = word1 + " " + word2.value(); word2.signExtend(k.byteValue()); program.stackPush(word2); } program.step(); } break; case NOT: { DataWord word1 = program.stackPop(); word1.bnot(); if (logger.isInfoEnabled()) hint = "" + word1.value(); program.stackPush(word1); program.step(); } break; case LT: { DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); if (logger.isInfoEnabled()) hint = word1.value() + " < " + word2.value(); if (word1.value().compareTo(word2.value()) == -1) { word1.and(DataWord.ZERO); word1.getData()[31] = 1; } else { word1.and(DataWord.ZERO); } program.stackPush(word1); program.step(); } break; case SLT: { DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); if (logger.isInfoEnabled()) hint = word1.sValue() + " < " + word2.sValue(); if (word1.sValue().compareTo(word2.sValue()) == -1) { word1.and(DataWord.ZERO); word1.getData()[31] = 1; } else { word1.and(DataWord.ZERO); } program.stackPush(word1); program.step(); } break; case SGT: { DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); if (logger.isInfoEnabled()) hint = word1.sValue() + " > " + word2.sValue(); if (word1.sValue().compareTo(word2.sValue()) == 1) { word1.and(DataWord.ZERO); word1.getData()[31] = 1; } else { word1.and(DataWord.ZERO); } program.stackPush(word1); program.step(); } break; case GT: { DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); if (logger.isInfoEnabled()) hint = word1.value() + " > " + word2.value(); if (word1.value().compareTo(word2.value()) == 1) { word1.and(DataWord.ZERO); word1.getData()[31] = 1; } else { word1.and(DataWord.ZERO); } program.stackPush(word1); program.step(); } break; case EQ: { DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); if (logger.isInfoEnabled()) hint = word1.value() + " == " + word2.value(); if (word1.xor(word2).isZero()) { word1.and(DataWord.ZERO); word1.getData()[31] = 1; } else { word1.and(DataWord.ZERO); } program.stackPush(word1); program.step(); } break; case ISZERO: { DataWord word1 = program.stackPop(); if (word1.isZero()) { word1.getData()[31] = 1; } else { word1.and(DataWord.ZERO); } if (logger.isInfoEnabled()) hint = "" + word1.value(); program.stackPush(word1); program.step(); } break; case AND: { DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); if (logger.isInfoEnabled()) hint = word1.value() + " && " + word2.value(); word1.and(word2); program.stackPush(word1); program.step(); } break; case OR: { DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); if (logger.isInfoEnabled()) hint = word1.value() + " || " + word2.value(); word1.or(word2); program.stackPush(word1); program.step(); } break; case XOR: { DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); if (logger.isInfoEnabled()) hint = word1.value() + " ^ " + word2.value(); word1.xor(word2); program.stackPush(word1); program.step(); } break; case BYTE: { DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); final DataWord result; if (word1.value().compareTo(_32_) == -1) { byte tmp = word2.getData()[word1.intValue()]; word2.and(DataWord.ZERO); word2.getData()[31] = tmp; result = word2; } else { result = new DataWord(); } if (logger.isInfoEnabled()) hint = "" + result.value(); program.stackPush(result); program.step(); } break; case ADDMOD: { DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); DataWord word3 = program.stackPop(); word1.addmod(word2, word3); program.stackPush(word1); program.step(); } break; case MULMOD: { DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); DataWord word3 = program.stackPop(); word1.mulmod(word2, word3); program.stackPush(word1); program.step(); } break; case SHA3: { DataWord memOffsetData = program.stackPop(); DataWord lengthData = program.stackPop(); byte[] buffer = program.memoryChunk(memOffsetData.intValue(), lengthData.intValue()); byte[] encoded = sha3(buffer); DataWord word = new DataWord(encoded); if (logger.isInfoEnabled()) hint = word.toString(); program.stackPush(word); program.step(); } break; case ADDRESS: { DataWord address = program.getOwnerAddress(); if (logger.isInfoEnabled()) hint = "address: " + Hex.toHexString(address.getLast20Bytes()); program.stackPush(address); program.step(); } break; case BALANCE: { DataWord address = program.stackPop(); DataWord balance = program.getBalance(address); if (logger.isInfoEnabled()) hint = "address: " + Hex.toHexString(address.getLast20Bytes()) + " balance: " + balance.toString(); program.stackPush(balance); program.step(); } break; case ORIGIN: { DataWord originAddress = program.getOriginAddress(); if (logger.isInfoEnabled()) hint = "address: " + Hex.toHexString(originAddress.getLast20Bytes()); program.stackPush(originAddress); program.step(); } break; case CALLER: { DataWord callerAddress = program.getCallerAddress(); if (logger.isInfoEnabled()) hint = "address: " + Hex.toHexString(callerAddress.getLast20Bytes()); program.stackPush(callerAddress); program.step(); } break; case CALLVALUE: { DataWord callValue = program.getCallValue(); if (logger.isInfoEnabled()) hint = "value: " + callValue; program.stackPush(callValue); program.step(); } break; case CALLDATALOAD: { DataWord dataOffs = program.stackPop(); DataWord value = program.getDataValue(dataOffs); if (logger.isInfoEnabled()) hint = "data: " + value; program.stackPush(value); program.step(); } break; case CALLDATASIZE: { DataWord dataSize = program.getDataSize(); if (logger.isInfoEnabled()) hint = "size: " + dataSize.value(); program.stackPush(dataSize); program.step(); } break; case CALLDATACOPY: { DataWord memOffsetData = program.stackPop(); DataWord dataOffsetData = program.stackPop(); DataWord lengthData = program.stackPop(); byte[] msgData = program.getDataCopy(dataOffsetData, lengthData); if (logger.isInfoEnabled()) hint = "data: " + Hex.toHexString(msgData); program.memorySave(memOffsetData.intValue(), msgData); program.step(); } break; case CODESIZE: case EXTCODESIZE: { int length; if (op == OpCode.CODESIZE) length = program.getCode().length; else { DataWord address = program.stackPop(); length = program.getCodeAt(address).length; } DataWord codeLength = new DataWord(length); if (logger.isInfoEnabled()) hint = "size: " + length; program.stackPush(codeLength); program.step(); } break; case CODECOPY: case EXTCODECOPY: { byte[] fullCode = EMPTY_BYTE_ARRAY; if (op == OpCode.CODECOPY) fullCode = program.getCode(); if (op == OpCode.EXTCODECOPY) { DataWord address = program.stackPop(); fullCode = program.getCodeAt(address); } int memOffset = program.stackPop().intValue(); int codeOffset = program.stackPop().intValue(); int lengthData = program.stackPop().intValue(); int sizeToBeCopied = codeOffset + lengthData > fullCode.length ? (fullCode.length < codeOffset ? 0 : fullCode.length - codeOffset) : lengthData; byte[] codeCopy = new byte[lengthData]; if (codeOffset < fullCode.length) System.arraycopy(fullCode, codeOffset, codeCopy, 0, sizeToBeCopied); if (logger.isInfoEnabled()) hint = "code: " + Hex.toHexString(codeCopy); program.memorySave(memOffset, codeCopy); program.step(); } break; case GASPRICE: { DataWord gasPrice = program.getGasPrice(); if (logger.isInfoEnabled()) hint = "price: " + gasPrice.toString(); program.stackPush(gasPrice); program.step(); } break; case BLOCKHASH: { int blockIndex = program.stackPop().intValue(); DataWord blockHash = program.getBlockHash(blockIndex); if (logger.isInfoEnabled()) hint = "blockHash: " + blockHash; program.stackPush(blockHash); program.step(); } break; case COINBASE: { DataWord coinbase = program.getCoinbase(); if (logger.isInfoEnabled()) hint = "coinbase: " + Hex.toHexString(coinbase.getLast20Bytes()); program.stackPush(coinbase); program.step(); } break; case TIMESTAMP: { DataWord timestamp = program.getTimestamp(); if (logger.isInfoEnabled()) hint = "timestamp: " + timestamp.value(); program.stackPush(timestamp); program.step(); } break; case NUMBER: { DataWord number = program.getNumber(); if (logger.isInfoEnabled()) hint = "number: " + number.value(); program.stackPush(number); program.step(); } break; case DIFFICULTY: { DataWord difficulty = program.getDifficulty(); if (logger.isInfoEnabled()) hint = "difficulty: " + difficulty; program.stackPush(difficulty); program.step(); } break; case GASLIMIT: { DataWord gaslimit = program.getGaslimit(); if (logger.isInfoEnabled()) hint = "gaslimit: " + gaslimit; program.stackPush(gaslimit); program.step(); } break; case POP: { program.stackPop(); program.step(); } break; case DUP1: case DUP2: case DUP3: case DUP4: case DUP5: case DUP6: case DUP7: case DUP8: case DUP9: case DUP10: case DUP11: case DUP12: case DUP13: case DUP14: case DUP15: case DUP16:{ int n = op.val() - OpCode.DUP1.val() + 1; DataWord word_1 = stack.get(stack.size() - n); program.stackPush(word_1.clone()); program.step(); } break; case SWAP1: case SWAP2: case SWAP3: case SWAP4: case SWAP5: case SWAP6: case SWAP7: case SWAP8: case SWAP9: case SWAP10: case SWAP11: case SWAP12: case SWAP13: case SWAP14: case SWAP15: case SWAP16:{ int n = op.val() - OpCode.SWAP1.val() + 2; stack.swap(stack.size() - 1, stack.size() - n); program.step(); } break; case LOG0: case LOG1: case LOG2: case LOG3: case LOG4: { DataWord address = program.programAddress; DataWord memStart = stack.pop(); DataWord memOffset = stack.pop(); int nTopics = op.val() - OpCode.LOG0.val(); List<DataWord> topics = new ArrayList<>(); for (int i = 0; i < nTopics; ++i) { DataWord topic = stack.pop(); topics.add(topic); } byte[] data = program.memoryChunk(memStart.intValue(), memOffset.intValue()); LogInfo logInfo = new LogInfo(address.getLast20Bytes(), topics, data); if (logger.isInfoEnabled()) hint = logInfo.toString(); program.getResult().addLogInfo(logInfo); program.step(); } break; case MLOAD: { DataWord addr = program.stackPop(); DataWord data = program.memoryLoad(addr); if (logger.isInfoEnabled()) hint = "data: " + data; program.stackPush(data); program.step(); } break; case MSTORE: { DataWord addr = program.stackPop(); DataWord value = program.stackPop(); if (logger.isInfoEnabled()) hint = "addr: " + addr + " value: " + value; program.memorySave(addr, value); program.step(); } break; case MSTORE8: { DataWord addr = program.stackPop(); DataWord value = program.stackPop(); byte[] byteVal = {value.getData()[31]}; program.memorySave(addr.intValue(), byteVal); program.step(); } break; case SLOAD: { DataWord key = program.stackPop(); DataWord val = program.storageLoad(key); if (logger.isInfoEnabled()) hint = "key: " + key + " value: " + val; if (val == null) val = key.and(DataWord.ZERO); program.stackPush(val); program.step(); } break; case SSTORE: { DataWord addr = program.stackPop(); DataWord value = program.stackPop(); if (logger.isInfoEnabled()) hint = "[" + program.programAddress.toPrefixString() + "] key: " + addr + " value: " + value; program.storageSave(addr, value); program.step(); } break; case JUMP: { DataWord pos = program.stackPop(); int nextPC = pos.intValue(); program.validateJumpDest(nextPC); if (logger.isInfoEnabled()) hint = "~> " + nextPC; program.setPC(nextPC); } break; case JUMPI: { DataWord pos = program.stackPop(); DataWord cond = program.stackPop(); if (!cond.isZero()) { int nextPC = pos.intValue(); program.validateJumpDest(nextPC); if (logger.isInfoEnabled()) hint = "~> " + nextPC; program.setPC(nextPC); } else { program.step(); } } break; case PC: { int pc = program.getPC(); DataWord pcWord = new DataWord(pc); if (logger.isInfoEnabled()) hint = pcWord.toString(); program.stackPush(pcWord); program.step(); } break; case MSIZE: { int memSize = program.getMemSize(); DataWord wordMemSize = new DataWord(memSize); if (logger.isInfoEnabled()) hint = "" + memSize; program.stackPush(wordMemSize); program.step(); } break; case GAS: { DataWord gas = program.getGas(); if (logger.isInfoEnabled()) hint = "" + gas; program.stackPush(gas); program.step(); } break; case PUSH1: case PUSH2: case PUSH3: case PUSH4: case PUSH5: case PUSH6: case PUSH7: case PUSH8: case PUSH9: case PUSH10: case PUSH11: case PUSH12: case PUSH13: case PUSH14: case PUSH15: case PUSH16: case PUSH17: case PUSH18: case PUSH19: case PUSH20: case PUSH21: case PUSH22: case PUSH23: case PUSH24: case PUSH25: case PUSH26: case PUSH27: case PUSH28: case PUSH29: case PUSH30: case PUSH31: case PUSH32: { program.step(); int nPush = op.val() - PUSH1.val() + 1; byte[] data = program.sweep(nPush); if (logger.isInfoEnabled()) hint = "" + Hex.toHexString(data); program.stackPush(data); } break; case JUMPDEST: { program.step(); } break; case CREATE: { DataWord value = program.stackPop(); DataWord inOffset = program.stackPop(); DataWord inSize = program.stackPop(); if (logger.isInfoEnabled()) logger.info(logString, String.format("%5s", "[" + program.getPC() + "]"), String.format("%-12s", op.name()), program.getGas().value(), program.invokeData.getCallDeep(), hint); program.createContract(value, inOffset, inSize); program.step(); } break; case CALL: case CALLCODE: { DataWord gas = program.stackPop(); DataWord codeAddress = program.stackPop(); DataWord value = program.stackPop(); if( !value.isZero()) { gas = new DataWord(gas.intValue() + GasCost.STIPEND_CALL); } DataWord inDataOffs = program.stackPop(); DataWord inDataSize = program.stackPop(); DataWord outDataOffs = program.stackPop(); DataWord outDataSize = program.stackPop(); if (logger.isInfoEnabled()) { hint = "addr: " + Hex.toHexString(codeAddress.getLast20Bytes()) + " gas: " + gas.shortHex() + " inOff: " + inDataOffs.shortHex() + " inSize: " + inDataSize.shortHex(); logger.info(logString, String.format("%5s", "[" + program.getPC() + "]"), String.format("%-12s", op.name()), program.getGas().value(), program.invokeData.getCallDeep(), hint); } program.memoryExpand(outDataOffs, outDataSize); MessageCall msg = new MessageCall( op.equals(CALL) ? MsgType.CALL : MsgType.STATELESS, gas, codeAddress, value, inDataOffs, inDataSize, outDataOffs, outDataSize); PrecompiledContracts.PrecompiledContract contract = PrecompiledContracts.getContractForAddress(codeAddress); if (contract != null) program.callToPrecompiledAddress(msg, contract); else program.callToAddress(msg); program.step(); } break; case RETURN: { DataWord offset = program.stackPop(); DataWord size = program.stackPop(); byte[] hReturn = program.memoryChunk(offset.intValue(), size.intValue()); program.setHReturn(hReturn); if (logger.isInfoEnabled()) hint = "data: " + Hex.toHexString(hReturn) + " offset: " + offset.value() + " size: " + size.value(); program.step(); program.stop(); } break; case SUICIDE: { DataWord address = program.stackPop(); program.suicide(address); if (logger.isInfoEnabled()) hint = "address: " + Hex.toHexString(program.getOwnerAddress().getLast20Bytes()); program.stop(); } break; default: break; } program.setPreviouslyExecutedOp(op.val()); if (logger.isInfoEnabled() && !op.equals(CALL) && !op.equals(CALLCODE) && !op.equals(CREATE)) logger.info(logString, String.format("%5s", "[" + program.getPC() + "]"), String.format("%-12s", op.name()), program.getGas().longValue(), program.invokeData.getCallDeep(), hint); vmCounter++; } catch (RuntimeException e) { logger.warn("VM halted: [{}]", e.toString()); program.spendAllGas(); program.resetFutureRefund(); program.stop(); throw e; } finally { program.fullTrace(); } }  void step(Program program); void play(Program program);  }
@Test public void testPUSH1() { VM vm = new VM(); program = new Program(Hex.decode("60A0"), invoke); String expected = "00000000000000000000000000000000000000000000000000000000000000A0"; program.fullTrace(); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPUSH2() { VM vm = new VM(); program = new Program(Hex.decode("61A0B0"), invoke); String expected = "000000000000000000000000000000000000000000000000000000000000A0B0"; program.fullTrace(); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPUSH3() { VM vm = new VM(); program = new Program(Hex.decode("62A0B0C0"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000A0B0C0"; program.fullTrace(); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPUSH4() { VM vm = new VM(); program = new Program(Hex.decode("63A0B0C0D0"), invoke); String expected = "00000000000000000000000000000000000000000000000000000000A0B0C0D0"; program.fullTrace(); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPUSH5() { VM vm = new VM(); program = new Program(Hex.decode("64A0B0C0D0E0"), invoke); String expected = "000000000000000000000000000000000000000000000000000000A0B0C0D0E0"; program.fullTrace(); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPUSH6() { VM vm = new VM(); program = new Program(Hex.decode("65A0B0C0D0E0F0"), invoke); String expected = "0000000000000000000000000000000000000000000000000000A0B0C0D0E0F0"; program.fullTrace(); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPUSH7() { VM vm = new VM(); program = new Program(Hex.decode("66A0B0C0D0E0F0A1"), invoke); String expected = "00000000000000000000000000000000000000000000000000A0B0C0D0E0F0A1"; program.fullTrace(); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPUSH8() { VM vm = new VM(); program = new Program(Hex.decode("67A0B0C0D0E0F0A1B1"), invoke); String expected = "000000000000000000000000000000000000000000000000A0B0C0D0E0F0A1B1"; program.fullTrace(); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPUSH9() { VM vm = new VM(); program = new Program(Hex.decode("68A0B0C0D0E0F0A1B1C1"), invoke); String expected = "0000000000000000000000000000000000000000000000A0B0C0D0E0F0A1B1C1"; program.fullTrace(); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPUSH10() { VM vm = new VM(); program = new Program(Hex.decode("69A0B0C0D0E0F0A1B1C1D1"), invoke); String expected = "00000000000000000000000000000000000000000000A0B0C0D0E0F0A1B1C1D1"; program.fullTrace(); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPUSH11() { VM vm = new VM(); program = new Program(Hex.decode("6AA0B0C0D0E0F0A1B1C1D1E1"), invoke); String expected = "000000000000000000000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1"; program.fullTrace(); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPUSH12() { VM vm = new VM(); program = new Program(Hex.decode("6BA0B0C0D0E0F0A1B1C1D1E1F1"), invoke); String expected = "0000000000000000000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1"; program.fullTrace(); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPUSH13() { VM vm = new VM(); program = new Program(Hex.decode("6CA0B0C0D0E0F0A1B1C1D1E1F1A2"), invoke); String expected = "00000000000000000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2"; program.fullTrace(); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPUSH14() { VM vm = new VM(); program = new Program(Hex.decode("6DA0B0C0D0E0F0A1B1C1D1E1F1A2B2"), invoke); String expected = "000000000000000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2"; program.fullTrace(); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPUSH15() { VM vm = new VM(); program = new Program(Hex.decode("6EA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2"), invoke); String expected = "0000000000000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2"; program.fullTrace(); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPUSH16() { VM vm = new VM(); program = new Program(Hex.decode("6FA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2"), invoke); String expected = "00000000000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2"; program.fullTrace(); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPUSH17() { VM vm = new VM(); program = new Program(Hex.decode("70A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2"), invoke); String expected = "000000000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2"; program.fullTrace(); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPUSH18() { VM vm = new VM(); program = new Program(Hex.decode("71A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2"), invoke); String expected = "0000000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2"; program.fullTrace(); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPUSH19() { VM vm = new VM(); program = new Program(Hex.decode("72A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3"), invoke); String expected = "00000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3"; program.fullTrace(); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPUSH20() { VM vm = new VM(); program = new Program(Hex.decode("73A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3"), invoke); String expected = "000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3"; program.fullTrace(); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPUSH21() { VM vm = new VM(); program = new Program(Hex.decode("74A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3"), invoke); String expected = "0000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3"; program.fullTrace(); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPUSH22() { VM vm = new VM(); program = new Program(Hex.decode("75A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3"), invoke); String expected = "00000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3"; program.fullTrace(); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPUSH23() { VM vm = new VM(); program = new Program(Hex.decode("76A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3"), invoke); String expected = "000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3"; program.fullTrace(); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPUSH24() { VM vm = new VM(); program = new Program(Hex.decode("77A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3"), invoke); String expected = "0000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3"; program.fullTrace(); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPUSH25() { VM vm = new VM(); program = new Program(Hex.decode("78A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4"), invoke); String expected = "00000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4"; program.fullTrace(); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPUSH26() { VM vm = new VM(); program = new Program(Hex.decode("79A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4"), invoke); String expected = "000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4"; program.fullTrace(); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPUSH27() { VM vm = new VM(); program = new Program(Hex.decode("7AA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4"), invoke); String expected = "0000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4"; program.fullTrace(); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPUSH28() { VM vm = new VM(); program = new Program(Hex.decode("7BA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4"), invoke); String expected = "00000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4"; program.fullTrace(); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPUSH29() { VM vm = new VM(); program = new Program(Hex.decode("7CA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4"), invoke); String expected = "000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4"; program.fullTrace(); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPUSH30() { VM vm = new VM(); program = new Program(Hex.decode("7DA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4"), invoke); String expected = "0000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4"; program.fullTrace(); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPUSH31() { VM vm = new VM(); program = new Program(Hex.decode("7EA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1"), invoke); String expected = "00A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1"; program.fullTrace(); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPUSH32() { VM vm = new VM(); program = new Program(Hex.decode("7FA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B1"), invoke); String expected = "A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B1"; program.fullTrace(); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPUSHN_1() { VM vm = new VM(); program = new Program(Hex.decode("61AA"), invoke); String expected = "000000000000000000000000000000000000000000000000000000000000AA00"; program.fullTrace(); vm.step(program); assertTrue(program.isStopped()); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPUSHN_2() { VM vm = new VM(); program = new Program(Hex.decode("7fAABB"), invoke); String expected = "AABB000000000000000000000000000000000000000000000000000000000000"; program.fullTrace(); vm.step(program); assertTrue(program.isStopped()); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testAND_1() { VM vm = new VM(); program = new Program(Hex.decode("600A600A16"), invoke); String expected = "000000000000000000000000000000000000000000000000000000000000000A"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testAND_2() { VM vm = new VM(); program = new Program(Hex.decode("60C0600A16"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test(expected = RuntimeException.class) public void testAND_3() { VM vm = new VM(); program = new Program(Hex.decode("60C016"), invoke); try { vm.step(program); vm.step(program); vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test public void testOR_1() { VM vm = new VM(); program = new Program(Hex.decode("60F0600F17"), invoke); String expected = "00000000000000000000000000000000000000000000000000000000000000FF"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testOR_2() { VM vm = new VM(); program = new Program(Hex.decode("60C3603C17"), invoke); String expected = "00000000000000000000000000000000000000000000000000000000000000FF"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test(expected = RuntimeException.class) public void testOR_3() { VM vm = new VM(); program = new Program(Hex.decode("60C017"), invoke); try { vm.step(program); vm.step(program); vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test public void testXOR_1() { VM vm = new VM(); program = new Program(Hex.decode("60FF60FF18"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testXOR_2() { VM vm = new VM(); program = new Program(Hex.decode("600F60F018"), invoke); String expected = "00000000000000000000000000000000000000000000000000000000000000FF"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test(expected = RuntimeException.class) public void testXOR_3() { VM vm = new VM(); program = new Program(Hex.decode("60C018"), invoke); try { vm.step(program); vm.step(program); vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test public void testBYTE_1() { VM vm = new VM(); program = new Program(Hex.decode("65AABBCCDDEEFF601E1A"), invoke); String expected = "00000000000000000000000000000000000000000000000000000000000000EE"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testBYTE_2() { VM vm = new VM(); program = new Program(Hex.decode("65AABBCCDDEEFF60201A"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testBYTE_3() { VM vm = new VM(); program = new Program(Hex.decode("65AABBCCDDEE3A601F1A"), invoke); String expected = "000000000000000000000000000000000000000000000000000000000000003A"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test(expected = StackTooSmallException.class) public void testBYTE_4() { VM vm = new VM(); program = new Program(Hex.decode("65AABBCCDDEE3A1A"), invoke); try { vm.step(program); vm.step(program); vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test public void testISZERO_1() { VM vm = new VM(); program = new Program(Hex.decode("600015"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testISZERO_2() { VM vm = new VM(); program = new Program(Hex.decode("602A15"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test(expected = StackTooSmallException.class) public void testISZERO_3() { VM vm = new VM(); program = new Program(Hex.decode("15"), invoke); try { vm.step(program); vm.step(program); vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test public void testEQ_1() { VM vm = new VM(); program = new Program(Hex.decode("602A602A14"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testEQ_2() { VM vm = new VM(); program = new Program(Hex.decode("622A3B4C622A3B4C14"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testEQ_3() { VM vm = new VM(); program = new Program(Hex.decode("622A3B5C622A3B4C14"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test(expected = StackTooSmallException.class) public void testEQ_4() { VM vm = new VM(); program = new Program(Hex.decode("622A3B4C14"), invoke); try { vm.step(program); vm.step(program); vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test public void testGT_1() { VM vm = new VM(); program = new Program(Hex.decode("6001600211"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testGT_2() { VM vm = new VM(); program = new Program(Hex.decode("6001610F0011"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testGT_3() { VM vm = new VM(); program = new Program(Hex.decode("6301020304610F0011"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test(expected = StackTooSmallException.class) public void testGT_4() { VM vm = new VM(); program = new Program(Hex.decode("622A3B4C11"), invoke); try { vm.step(program); vm.step(program); vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test public void testSGT_1() { VM vm = new VM(); program = new Program(Hex.decode("6001600213"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testSGT_2() { VM vm = new VM(); program = new Program(Hex.decode("7F000000000000000000000000000000000000000000000000000000000000001E" + "7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" + "13"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testSGT_3() { VM vm = new VM(); program = new Program(Hex.decode("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" + "7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF57" + "13"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test(expected = StackTooSmallException.class) public void testSGT_4() { VM vm = new VM(); program = new Program(Hex.decode("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" + "13"), invoke); try { vm.step(program); vm.step(program); vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test public void testLT_1() { VM vm = new VM(); program = new Program(Hex.decode("6001600210"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testLT_2() { VM vm = new VM(); program = new Program(Hex.decode("6001610F0010"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testLT_3() { VM vm = new VM(); program = new Program(Hex.decode("6301020304610F0010"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test(expected = StackTooSmallException.class) public void testLT_4() { VM vm = new VM(); program = new Program(Hex.decode("622A3B4C10"), invoke); try { vm.step(program); vm.step(program); vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test public void testSLT_1() { VM vm = new VM(); program = new Program(Hex.decode("6001600212"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testSLT_2() { VM vm = new VM(); program = new Program(Hex.decode("7F000000000000000000000000000000000000000000000000000000000000001E" + "7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" + "12"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testSLT_3() { VM vm = new VM(); program = new Program(Hex.decode("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" + "7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF57" + "12"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test(expected = StackTooSmallException.class) public void testSLT_4() { VM vm = new VM(); program = new Program(Hex.decode("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" + "12"), invoke); try { vm.step(program); vm.step(program); vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test public void testNOT_1() { VM vm = new VM(); program = new Program(Hex.decode("600119"), invoke); String expected = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE"; vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testNOT_2() { VM vm = new VM(); program = new Program(Hex.decode("61A00319"), invoke); String expected = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5FFC"; vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testNOT_3() { VM vm = new VM(); program = new Program(Hex.decode("61000019"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test(expected = StackTooSmallException.class) public void testBNOT_4() { VM vm = new VM(); program = new Program(Hex.decode("1a"), invoke); try { vm.step(program); vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test public void testPOP_1() { VM vm = new VM(); program = new Program(Hex.decode("61000060016200000250"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPOP_2() { VM vm = new VM(); program = new Program(Hex.decode("6100006001620000025050"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test(expected = StackTooSmallException.class) public void testPOP_3() { VM vm = new VM(); program = new Program(Hex.decode("61000060016200000250505050"), invoke); try { vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test(expected = StackTooSmallException.class) public void testDUPN_2() { VM vm = new VM(); program = new Program(Hex.decode("80"), invoke); try { vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test(expected = StackTooSmallException.class) public void testSWAPN_2() { VM vm = new VM(); program = new Program(Hex.decode("90"), invoke); try { vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test public void testMSTORE_1() { VM vm = new VM(); program = new Program(Hex.decode("611234600052"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000001234"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getMemory())); }
@Test public void tesLog0() { VM vm = new VM(); program = new Program(Hex.decode("61123460005260206000A0"), invoke); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); List<LogInfo> logInfoList = program.getResult().getLogInfoList(); LogInfo logInfo = logInfoList.get(0); assertEquals("cd2a3d9f938e13cd947ec05abc7fe734df8dd826", Hex.toHexString(logInfo.getAddress())); assertEquals(0, logInfo.getTopics().size()); assertEquals("0000000000000000000000000000000000000000000000000000000000001234", Hex.toHexString(logInfo .getData())); }
@Test public void tesLog1() { VM vm = new VM(); program = new Program(Hex.decode("61123460005261999960206000A1"), invoke); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); List<LogInfo> logInfoList = program.getResult().getLogInfoList(); LogInfo logInfo = logInfoList.get(0); assertEquals("cd2a3d9f938e13cd947ec05abc7fe734df8dd826", Hex.toHexString(logInfo.getAddress())); assertEquals(1, logInfo.getTopics().size()); assertEquals("0000000000000000000000000000000000000000000000000000000000001234", Hex.toHexString(logInfo .getData())); }
@Test public void tesLog2() { VM vm = new VM(); program = new Program(Hex.decode("61123460005261999961666660206000A2"), invoke); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); List<LogInfo> logInfoList = program.getResult().getLogInfoList(); LogInfo logInfo = logInfoList.get(0); assertEquals("cd2a3d9f938e13cd947ec05abc7fe734df8dd826", Hex.toHexString(logInfo.getAddress())); assertEquals(2, logInfo.getTopics().size()); assertEquals("0000000000000000000000000000000000000000000000000000000000001234", Hex.toHexString(logInfo .getData())); }
@Test public void tesLog3() { VM vm = new VM(); program = new Program(Hex.decode("61123460005261999961666661333360206000A3"), invoke); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); List<LogInfo> logInfoList = program.getResult().getLogInfoList(); LogInfo logInfo = logInfoList.get(0); assertEquals("cd2a3d9f938e13cd947ec05abc7fe734df8dd826", Hex.toHexString(logInfo.getAddress())); assertEquals(3, logInfo.getTopics().size()); assertEquals("0000000000000000000000000000000000000000000000000000000000001234", Hex.toHexString(logInfo .getData())); }
@Test public void tesLog4() { VM vm = new VM(); program = new Program(Hex.decode("61123460005261999961666661333361555560206000A4"), invoke); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); List<LogInfo> logInfoList = program.getResult().getLogInfoList(); LogInfo logInfo = logInfoList.get(0); assertEquals("cd2a3d9f938e13cd947ec05abc7fe734df8dd826", Hex.toHexString(logInfo.getAddress())); assertEquals(4, logInfo.getTopics().size()); assertEquals("0000000000000000000000000000000000000000000000000000000000001234", Hex.toHexString(logInfo .getData())); }
@Test public void testMSTORE_2() { VM vm = new VM(); program = new Program(Hex.decode("611234600052615566602052"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000001234" + "0000000000000000000000000000000000000000000000000000000000005566"; vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getMemory())); }
@Test public void testMSTORE_3() { VM vm = new VM(); program = new Program(Hex.decode("611234600052615566602052618888600052"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000008888" + "0000000000000000000000000000000000000000000000000000000000005566"; vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getMemory())); }
@Test public void testMSTORE_4() { VM vm = new VM(); program = new Program(Hex.decode("61123460A052"), invoke); String expected = "" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000001234"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.getMemory())); }
@Test(expected = StackTooSmallException.class) public void testMSTORE_5() { VM vm = new VM(); program = new Program(Hex.decode("61123452"), invoke); try { vm.step(program); vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test public void testMLOAD_1() { VM vm = new VM(); program = new Program(Hex.decode("600051"), invoke); String m_expected = "0000000000000000000000000000000000000000000000000000000000000000"; String s_expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); assertEquals(m_expected, Hex.toHexString(program.getMemory())); assertEquals(s_expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testMLOAD_2() { VM vm = new VM(); program = new Program(Hex.decode("602251"), invoke); String m_expected = "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000"; String s_expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); assertEquals(m_expected, Hex.toHexString(program.getMemory()).toUpperCase()); assertEquals(s_expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testMLOAD_3() { VM vm = new VM(); program = new Program(Hex.decode("602051"), invoke); String m_expected = "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000"; String s_expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); assertEquals(m_expected, Hex.toHexString(program.getMemory())); assertEquals(s_expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testMLOAD_4() { VM vm = new VM(); program = new Program(Hex.decode("611234602052602051"), invoke); String m_expected = "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000001234"; String s_expected = "0000000000000000000000000000000000000000000000000000000000001234"; vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); assertEquals(m_expected, Hex.toHexString(program.getMemory())); assertEquals(s_expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testMLOAD_5() { VM vm = new VM(); program = new Program(Hex.decode("611234602052601F51"), invoke); String m_expected = "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000001234"; String s_expected = "0000000000000000000000000000000000000000000000000000000000000012"; vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); assertEquals(m_expected, Hex.toHexString(program.getMemory())); assertEquals(s_expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test(expected = StackTooSmallException.class) public void testMLOAD_6() { VM vm = new VM(); program = new Program(Hex.decode("51"), invoke); try { vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test public void testMSTORE8_1() { VM vm = new VM(); program = new Program(Hex.decode("6011600053"), invoke); String m_expected = "1100000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); assertEquals(m_expected, Hex.toHexString(program.getMemory())); }
@Test public void testMSTORE8_2() { VM vm = new VM(); program = new Program(Hex.decode("6022600153"), invoke); String m_expected = "0022000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); assertEquals(m_expected, Hex.toHexString(program.getMemory())); }
@Test public void testMSTORE8_3() { VM vm = new VM(); program = new Program(Hex.decode("6022602153"), invoke); String m_expected = "0000000000000000000000000000000000000000000000000000000000000000" + "0022000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); assertEquals(m_expected, Hex.toHexString(program.getMemory())); }
@Test(expected = StackTooSmallException.class) public void testMSTORE8_4() { VM vm = new VM(); program = new Program(Hex.decode("602253"), invoke); try { vm.step(program); vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test public void testSSTORE_1() { VM vm = new VM(); program = new Program(Hex.decode("602260AA55"), invoke); String s_expected_key = "00000000000000000000000000000000000000000000000000000000000000AA"; String s_expected_val = "0000000000000000000000000000000000000000000000000000000000000022"; vm.step(program); vm.step(program); vm.step(program); DataWord key = new DataWord(Hex.decode(s_expected_key)); DataWord val = program.getResult().getRepository().getStorageValue(invoke.getOwnerAddress() .getNoLeadZeroesData(), key); assertEquals(s_expected_val, Hex.toHexString(val.getData()).toUpperCase()); }
@Test public void testSSTORE_2() { VM vm = new VM(); program = new Program(Hex.decode("602260AA55602260BB55"), invoke); String s_expected_key = "00000000000000000000000000000000000000000000000000000000000000BB"; String s_expected_val = "0000000000000000000000000000000000000000000000000000000000000022"; vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); Repository repository = program.getResult().getRepository(); DataWord key = new DataWord(Hex.decode(s_expected_key)); DataWord val = repository.getStorageValue(invoke.getOwnerAddress().getNoLeadZeroesData(), key); assertEquals(s_expected_val, Hex.toHexString(val.getData()).toUpperCase()); }
@Test(expected = StackTooSmallException.class) public void testSSTORE_3() { VM vm = new VM(); program = new Program(Hex.decode("602255"), invoke); try { vm.step(program); vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test public void testSLOAD_1() { VM vm = new VM(); program = new Program(Hex.decode("60AA54"), invoke); String s_expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); assertEquals(s_expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testSLOAD_2() { VM vm = new VM(); program = new Program(Hex.decode("602260AA5560AA54"), invoke); String s_expected = "0000000000000000000000000000000000000000000000000000000000000022"; vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); assertEquals(s_expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testSLOAD_3() { VM vm = new VM(); program = new Program(Hex.decode("602260AA55603360CC5560CC54"), invoke); String s_expected = "0000000000000000000000000000000000000000000000000000000000000033"; vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); assertEquals(s_expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test(expected = StackTooSmallException.class) public void testSLOAD_4() { VM vm = new VM(); program = new Program(Hex.decode("56"), invoke); try { vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test public void testPC_1() { VM vm = new VM(); program = new Program(Hex.decode("58"), invoke); String s_expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); assertEquals(s_expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testPC_2() { VM vm = new VM(); program = new Program(Hex.decode("602260AA5260AA5458"), invoke); String s_expected = "0000000000000000000000000000000000000000000000000000000000000008"; vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); assertEquals(s_expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test(expected = BadJumpDestinationException.class) public void testJUMP_1() { VM vm = new VM(); program = new Program(Hex.decode("60AA60BB600E5660CC60DD60EE5B60FF"), invoke); String s_expected = "00000000000000000000000000000000000000000000000000000000000000FF"; vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); assertEquals(s_expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test(expected = BadJumpDestinationException.class) public void testJUMP_2() { VM vm = new VM(); program = new Program(Hex.decode("600C600C905660CC60DD60EE60FF"), invoke); try { vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test public void testJUMPI_1() { VM vm = new VM(); program = new Program(Hex.decode("60016005575B60CC"), invoke); String s_expected = "00000000000000000000000000000000000000000000000000000000000000CC"; vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); assertEquals(s_expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase()); }
@Test public void testJUMPI_2() { VM vm = new VM(); program = new Program(Hex.decode("630000000060445760CC60DD"), invoke); String s_expected_1 = "00000000000000000000000000000000000000000000000000000000000000DD"; String s_expected_2 = "00000000000000000000000000000000000000000000000000000000000000CC"; vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); DataWord item1 = program.stackPop(); DataWord item2 = program.stackPop(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); assertEquals(s_expected_2, Hex.toHexString(item2.getData()).toUpperCase()); }
@Test(expected = StackTooSmallException.class) public void testJUMPI_3() { VM vm = new VM(); program = new Program(Hex.decode("600157"), invoke); try { vm.step(program); vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test(expected = BadJumpDestinationException.class) public void testJUMPI_4() { VM vm = new VM(); program = new Program(Hex.decode("60016022909057"), invoke); try { vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test(expected = BadJumpDestinationException.class) public void testJUMPDEST_1() { VM vm = new VM(); program = new Program(Hex.decode("602360085660015b600255"), invoke); String s_expected_key = "0000000000000000000000000000000000000000000000000000000000000002"; String s_expected_val = "0000000000000000000000000000000000000000000000000000000000000023"; vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); DataWord key = new DataWord(Hex.decode(s_expected_key)); DataWord val = program.getResult().getRepository().getStorageValue(invoke.getOwnerAddress() .getNoLeadZeroesData(), key); assertTrue(program.isStopped()); assertEquals(s_expected_val, Hex.toHexString(val.getData()).toUpperCase()); }
@Test public void testJUMPDEST_2() { VM vm = new VM(); program = new Program(Hex.decode("6023600160095760015b600255"), invoke); String s_expected_key = "0000000000000000000000000000000000000000000000000000000000000002"; String s_expected_val = "0000000000000000000000000000000000000000000000000000000000000023"; vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); DataWord key = new DataWord(Hex.decode(s_expected_key)); DataWord val = program.getResult().getRepository().getStorageValue(invoke.getOwnerAddress() .getNoLeadZeroesData(), key); assertTrue(program.isStopped()); assertEquals(s_expected_val, Hex.toHexString(val.getData()).toUpperCase()); }
@Test public void testADD_1() { VM vm = new VM(); program = new Program(Hex.decode("6002600201"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000004"; vm.step(program); vm.step(program); vm.step(program); DataWord item1 = program.stackPop(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); }
@Test public void testADD_2() { VM vm = new VM(); program = new Program(Hex.decode("611002600201"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000001004"; vm.step(program); vm.step(program); vm.step(program); DataWord item1 = program.stackPop(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); }
@Test public void testADD_3() { VM vm = new VM(); program = new Program(Hex.decode("6110026512345678900901"), invoke); String s_expected_1 = "000000000000000000000000000000000000000000000000000012345678A00B"; vm.step(program); vm.step(program); vm.step(program); DataWord item1 = program.stackPop(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); }
@Test(expected = StackTooSmallException.class) public void testADD_4() { VM vm = new VM(); program = new Program(Hex.decode("61123401"), invoke); try { vm.step(program); vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test public void testADDMOD_1() { VM vm = new VM(); program = new Program(Hex.decode("60026002600308"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); vm.step(program); vm.step(program); vm.step(program); DataWord item1 = program.stackPop(); assertTrue(program.isStopped()); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); }
@Test public void testADDMOD_2() { VM vm = new VM(); program = new Program(Hex.decode("6110006002611002086000"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000004"; vm.step(program); vm.step(program); vm.step(program); vm.step(program); DataWord item1 = program.stackPop(); assertFalse(program.isStopped()); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); }
@Test public void testADDMOD_3() { VM vm = new VM(); program = new Program(Hex.decode("61100265123456789009600208"), invoke); String s_expected_1 = "000000000000000000000000000000000000000000000000000000000000093B"; vm.step(program); vm.step(program); vm.step(program); vm.step(program); DataWord item1 = program.stackPop(); assertTrue(program.isStopped()); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); }
@Test(expected = StackTooSmallException.class) public void testADDMOD_4() { VM vm = new VM(); program = new Program(Hex.decode("61123408"), invoke); try { vm.step(program); vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test public void testMUL_1() { VM vm = new VM(); program = new Program(Hex.decode("6003600202"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000006"; vm.step(program); vm.step(program); vm.step(program); DataWord item1 = program.stackPop(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); }
@Test public void testMUL_2() { VM vm = new VM(); program = new Program(Hex.decode("62222222600302"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000666666"; vm.step(program); vm.step(program); vm.step(program); DataWord item1 = program.stackPop(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); }
@Test public void testMUL_3() { VM vm = new VM(); program = new Program(Hex.decode("622222226233333302"), invoke); String s_expected_1 = "000000000000000000000000000000000000000000000000000006D3A05F92C6"; vm.step(program); vm.step(program); vm.step(program); DataWord item1 = program.stackPop(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); }
@Test(expected = StackTooSmallException.class) public void testMUL_4() { VM vm = new VM(); program = new Program(Hex.decode("600102"), invoke); try { vm.step(program); vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test public void testMULMOD_1() { VM vm = new VM(); program = new Program(Hex.decode("60036002600409"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000002"; vm.step(program); vm.step(program); vm.step(program); vm.step(program); DataWord item1 = program.stackPop(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); }
@Test public void testMULMOD_2() { VM vm = new VM(); program = new Program(Hex.decode("622222226003600409"), invoke); String s_expected_1 = "000000000000000000000000000000000000000000000000000000000000000C"; vm.step(program); vm.step(program); vm.step(program); vm.step(program); DataWord item1 = program.stackPop(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); }
@Test public void testMULMOD_3() { VM vm = new VM(); program = new Program(Hex.decode("62222222623333336244444409"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); vm.step(program); DataWord item1 = program.stackPop(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); }
@Test(expected = StackTooSmallException.class) public void testMULMOD_4() { VM vm = new VM(); program = new Program(Hex.decode("600109"), invoke); try { vm.step(program); vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test public void testDIV_1() { VM vm = new VM(); program = new Program(Hex.decode("6002600404"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000002"; vm.step(program); vm.step(program); vm.step(program); DataWord item1 = program.stackPop(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); }
@Test public void testDIV_2() { VM vm = new VM(); program = new Program(Hex.decode("6033609904"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000003"; vm.step(program); vm.step(program); vm.step(program); DataWord item1 = program.stackPop(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); }
@Test public void testDIV_3() { VM vm = new VM(); program = new Program(Hex.decode("6022609904"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000004"; vm.step(program); vm.step(program); vm.step(program); DataWord item1 = program.stackPop(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); }
@Test public void testDIV_4() { VM vm = new VM(); program = new Program(Hex.decode("6015609904"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000007"; vm.step(program); vm.step(program); vm.step(program); DataWord item1 = program.stackPop(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); }
@Test public void testDIV_5() { VM vm = new VM(); program = new Program(Hex.decode("6004600704"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); vm.step(program); vm.step(program); DataWord item1 = program.stackPop(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); }
@Test(expected = StackTooSmallException.class) public void testDIV_6() { VM vm = new VM(); program = new Program(Hex.decode("600704"), invoke); try { vm.step(program); vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test public void testSDIV_1() { VM vm = new VM(); program = new Program(Hex.decode("6103E87FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC1805" + ""), invoke); String s_expected_1 = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"; vm.step(program); vm.step(program); vm.step(program); DataWord item1 = program.stackPop(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); }
@Test public void testSDIV_2() { VM vm = new VM(); program = new Program(Hex.decode("60FF60FF05"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); vm.step(program); vm.step(program); DataWord item1 = program.stackPop(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); }
@Test public void testSDIV_3() { VM vm = new VM(); program = new Program(Hex.decode("600060FF05"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); DataWord item1 = program.stackPop(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); }
@Test(expected = StackTooSmallException.class) public void testSDIV_4() { VM vm = new VM(); program = new Program(Hex.decode("60FF05"), invoke); try { vm.step(program); vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test public void testSUB_1() { VM vm = new VM(); program = new Program(Hex.decode("6004600603"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000002"; vm.step(program); vm.step(program); vm.step(program); DataWord item1 = program.stackPop(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); }
@Test public void testSUB_2() { VM vm = new VM(); program = new Program(Hex.decode("61444461666603"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000002222"; vm.step(program); vm.step(program); vm.step(program); DataWord item1 = program.stackPop(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); }
@Test public void testSUB_3() { VM vm = new VM(); program = new Program(Hex.decode("614444639999666603"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000099992222"; vm.step(program); vm.step(program); vm.step(program); DataWord item1 = program.stackPop(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); }
@Test(expected = StackTooSmallException.class) public void testSUB_4() { VM vm = new VM(); program = new Program(Hex.decode("639999666603"), invoke); try { vm.step(program); vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test public void testMSIZE_1() { VM vm = new VM(); program = new Program(Hex.decode("59"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); DataWord item1 = program.stackPop(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); }
@Test public void testMSIZE_2() { VM vm = new VM(); program = new Program(Hex.decode("602060305259"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000060"; vm.step(program); vm.step(program); vm.step(program); vm.step(program); DataWord item1 = program.stackPop(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); }
@Test public void testSTOP_1() { VM vm = new VM(); program = new Program(Hex.decode("60206030601060306011602300"), invoke); int expectedSteps = 7; int i = 0; while (!program.isStopped()) { vm.step(program); ++i; } assertEquals(expectedSteps, i); }
@Ignore @Test public void testEXP_1() { VM vm = new VM(); program = new Program(Hex.decode("600360020a"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000008"; vm.step(program); vm.step(program); vm.step(program); DataWord item1 = program.stackPop(); long gas = program.getResult().getGasUsed(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); assertEquals(4, gas); }
@Ignore @Test public void testEXP_2() { VM vm = new VM(); program = new Program(Hex.decode("6000621234560a"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); vm.step(program); vm.step(program); DataWord item1 = program.stackPop(); long gas = program.getResult().getGasUsed(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); assertEquals(3, gas); }
@Ignore @Test public void testEXP_3() { VM vm = new VM(); program = new Program(Hex.decode("61112260010a"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); vm.step(program); vm.step(program); DataWord item1 = program.stackPop(); long gas = program.getResult().getGasUsed(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); assertEquals(5, gas); }
@Test(expected = StackTooSmallException.class) public void testEXP_4() { VM vm = new VM(); program = new Program(Hex.decode("621234560a"), invoke); try { vm.step(program); vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test public void testRETURN_1() { VM vm = new VM(); program = new Program(Hex.decode("61123460005260206000F3"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000001234"; vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); assertEquals(s_expected_1, Hex.toHexString(program.getResult().getHReturn()).toUpperCase()); assertTrue(program.isStopped()); }
@Test public void testRETURN_2() { VM vm = new VM(); program = new Program(Hex.decode("6112346000526020601FF3"), invoke); String s_expected_1 = "3400000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); assertEquals(s_expected_1, Hex.toHexString(program.getResult().getHReturn()).toUpperCase()); assertTrue(program.isStopped()); }
@Test public void testRETURN_3() { VM vm = new VM(); program = new Program(Hex.decode ("7FA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B160005260206000F3"), invoke); String s_expected_1 = "A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B1"; vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); assertEquals(s_expected_1, Hex.toHexString(program.getResult().getHReturn()).toUpperCase()); assertTrue(program.isStopped()); }
@Test public void testRETURN_4() { VM vm = new VM(); program = new Program(Hex.decode ("7FA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B160005260206010F3"), invoke); String s_expected_1 = "E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B100000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); assertEquals(s_expected_1, Hex.toHexString(program.getResult().getHReturn()).toUpperCase()); assertTrue(program.isStopped()); }
@Ignore @Test public void testCODECOPY_1() { VM vm = new VM(); program = new Program(Hex.decode("60036007600039123456"), invoke); String m_expected_1 = "1234560000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); vm.step(program); long gas = program.getResult().getGasUsed(); assertEquals(m_expected_1, Hex.toHexString(program.getMemory()).toUpperCase()); assertEquals(6, gas); }
@Ignore @Test public void testCODECOPY_2() { VM vm = new VM(); program = new Program(Hex.decode ("605E60076000396000605f556014600054601e60205463abcddcba6040545b51602001600a5254516040016014525451606001601e5254516080016028525460a052546016604860003960166000f26000603f556103e75660005460005360200235602054"), invoke); String m_expected_1 = "6000605F556014600054601E60205463ABCDDCBA6040545B51602001600A5254516040016014525451606001601E5254516080016028525460A052546016604860003960166000F26000603F556103E756600054600053602002356020540000"; vm.step(program); vm.step(program); vm.step(program); vm.step(program); long gas = program.getResult().getGasUsed(); assertEquals(m_expected_1, Hex.toHexString(program.getMemory()).toUpperCase()); assertEquals(10, gas); }
@Ignore @Test public void testCODECOPY_3() { VM vm = new VM(); program = new Program(Hex.decode ("605E60076000396000605f556014600054601e60205463abcddcba6040545b51602001600a5254516040016014525451606001601e5254516080016028525460a052546016604860003960166000f26000603f556103e75660005460005360200235"), invoke); vm.step(program); vm.step(program); vm.step(program); vm.step(program); assertEquals(10, program.getResult().getGasUsed()); }
@Ignore @Test public void testCODECOPY_4() { VM vm = new VM(); program = new Program(Hex.decode ("605E60076000396000605f556014600054601e60205463abcddcba6040545b51602001600a5254516040016014525451606001601e5254516080016028525460a052546016604860003960166000f26000603f556103e756600054600053602002351234"), invoke); vm.step(program); vm.step(program); vm.step(program); vm.step(program); assertEquals(10, program.getResult().getGasUsed()); }
@Test public void testCODECOPY_5() { VM vm = new VM(); program = new Program(Hex.decode ("611234600054615566602054607060006020396000605f556014600054601e60205463abcddcba6040545b51602001600a5254516040016014525451606001601e5254516080016028525460a052546016604860003960166000f26000603f556103e756600054600053602002351234"), invoke); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); assertFalse(program.isStopped()); }
@Test(expected = StackTooSmallException.class) public void testCODECOPY_6() { VM vm = new VM(); program = new Program(Hex.decode ("605E6007396000605f556014600054601e60205463abcddcba6040545b51602001600a5254516040016014525451606001601e5254516080016028525460a052546016604860003960166000f26000603f556103e756600054600053602002351234"), invoke); try { vm.step(program); vm.step(program); vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test public void testEXTCODECOPY_1() { VM vm = new VM(); program = new Program(Hex.decode("60036007600073471FD3AD3E9EEADEEC4608B92D16CE6B500704CC3C123456"), invoke); String m_expected_1 = "6000600000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); assertEquals(m_expected_1, Hex.toHexString(program.getMemory()).toUpperCase()); }
@Test public void testEXTCODECOPY_2() { VM vm = new VM(); program = new Program(Hex.decode ("603E6007600073471FD3AD3E9EEADEEC4608B92D16CE6B500704CC3C6000605f556014600054601e60205463abcddcba6040545b51602001600a5254516040016014525451606001601e5254516080016028525460a052546016604860003960166000f26000603f556103e75660005460005360200235602054"), invoke); String m_expected_1 = "6000605F556014600054601E60205463ABCDDCBA6040545B51602001600A5254516040016014525451606001601E5254516080016028525460A0525460160000"; vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); assertEquals(m_expected_1, Hex.toHexString(program.getMemory()).toUpperCase()); }
@Test public void testEXTCODECOPY_3() { VM vm = new VM(); program = new Program(Hex.decode ("605E6007600073471FD3AD3E9EEADEEC4608B92D16CE6B500704CC3C6000605f556014600054601e60205463abcddcba6040545b51602001600a5254516040016014525451606001601e5254516080016028525460a052546016604860003960166000f26000603f556103e75660005460005360200235"), invoke); String m_expected_1 = "6000605F556014600054601E60205463ABCDDCBA6040545B51602001600A5254516040016014525451606001601E5254516080016028525460A052546016604860003960166000F26000603F556103E756600054600053602002350000000000"; vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); assertEquals(m_expected_1, Hex.toHexString(program.getMemory()).toUpperCase()); }
@Test public void testEXTCODECOPY_4() { VM vm = new VM(); program = new Program(Hex.decode ("611234600054615566602054603E6000602073471FD3AD3E9EEADEEC4608B92D16CE6B500704CC3C6000605f556014600054601e60205463abcddcba6040545b51602001600a5254516040016014525451606001601e5254516080016028525460a052546016604860003960166000f26000603f556103e756600054600053602002351234"), invoke); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); assertFalse(program.isStopped()); }
@Test(expected = StackTooSmallException.class) public void testEXTCODECOPY_5() { VM vm = new VM(); program = new Program(Hex.decode("605E600773471FD3AD3E9EEADEEC4608B92D16CE6B500704CC3C"), invoke); try { vm.step(program); vm.step(program); vm.step(program); vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test public void testCODESIZE_1() { VM vm = new VM(); program = new Program(Hex.decode ("385E60076000396000605f556014600054601e60205463abcddcba6040545b51602001600a5254516040016014525451606001601e5254516080016028525460a052546016604860003960166000f26000603f556103e75660005460005360200235"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000062"; vm.step(program); DataWord item1 = program.stackPop(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); }
@Ignore @Test public void testEXTCODESIZE_1() { VM vm = new VM(); program = new Program(Hex.decode ("73471FD3AD3E9EEADEEC4608B92D16CE6B500704CC395E60076000396000605f556014600054601e60205463abcddcba6040545b51602001600a5254516040016014525451606001601e5254516080016028525460a052546016604860003960166000f26000603f556103e75660005460005360200235"), invoke); String s_expected_1 = "000000000000000000000000471FD3AD3E9EEADEEC4608B92D16CE6B500704CC"; vm.step(program); DataWord item1 = program.stackPop(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); }
@Test public void testMOD_1() { VM vm = new VM(); program = new Program(Hex.decode("6003600406"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); vm.step(program); vm.step(program); DataWord item1 = program.stackPop(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); }
@Test public void testMOD_2() { VM vm = new VM(); program = new Program(Hex.decode("61012C6101F406"), invoke); String s_expected_1 = "00000000000000000000000000000000000000000000000000000000000000C8"; vm.step(program); vm.step(program); vm.step(program); DataWord item1 = program.stackPop(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); }
@Test public void testMOD_3() { VM vm = new VM(); program = new Program(Hex.decode("6004600206"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000002"; vm.step(program); vm.step(program); vm.step(program); DataWord item1 = program.stackPop(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); }
@Test(expected = StackTooSmallException.class) public void testMOD_4() { VM vm = new VM(); program = new Program(Hex.decode("600406"), invoke); try { vm.step(program); vm.step(program); vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test public void testSMOD_1() { VM vm = new VM(); program = new Program(Hex.decode("6003600407"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); vm.step(program); vm.step(program); DataWord item1 = program.stackPop(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); }
@Test public void testSMOD_2() { VM vm = new VM(); program = new Program(Hex.decode("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE2" + "7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" + "07"), invoke); String s_expected_1 = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEC"; vm.step(program); vm.step(program); vm.step(program); DataWord item1 = program.stackPop(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); }
@Test public void testSMOD_3() { VM vm = new VM(); program = new Program(Hex.decode("7F000000000000000000000000000000000000000000000000000000000000001E" + "7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" + "07"), invoke); String s_expected_1 = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEC"; vm.step(program); vm.step(program); vm.step(program); DataWord item1 = program.stackPop(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); }
@Test(expected = StackTooSmallException.class) public void testSMOD_4() { VM vm = new VM(); program = new Program(Hex.decode("7F000000000000000000000000000000000000000000000000000000000000001E" + "07"), invoke); try { vm.step(program); vm.step(program); } finally { assertTrue(program.isStopped()); } }