VM { public void step(Program program) { program.fullTrace(); if (CONFIG.vmTrace()) program.saveOpTrace(); try { OpCode op = OpCode.code(program.getCurrentOp()); if (op == null) throw program.new IllegalOperationException(); program.setLastOp(op.val()); long oldMemSize = program.getMemSize(); BigInteger newMemSize = BigInteger.ZERO; Stack<DataWord> stack = program.getStack(); String hint = ""; long callGas = 0, memWords = 0; long gasCost = GasCost.STEP; long gasBefore = program.getGas().longValue(); int stepBefore = program.getPC(); program.stackRequire(op.require()); 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.SSTORE * 2; else if (oldValue != null && newValue.isZero()) gasCost = GasCost.SSTORE * 0; else gasCost = GasCost.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: newMemSize = memNeeded(stack.peek(), stack.get(stack.size()-2)); break; case SHA3: gasCost = GasCost.SHA3; newMemSize = memNeeded(stack.peek(), stack.get(stack.size()-2)); break; case CALLDATACOPY: newMemSize = memNeeded(stack.peek(), stack.get(stack.size()-3)); break; case CODECOPY: newMemSize = memNeeded(stack.peek(), stack.get(stack.size()-3)); break; case EXTCODECOPY: 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.new OutOfGasException(); } callGas = callGasWord.longValue(); 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; default: break; } program.spendGas(gasCost, op.name()); if(newMemSize.compareTo(MAX_GAS) == 1) { throw program.new OutOfGasException(); } long memoryUsage = (newMemSize.longValue() + 31) / 32 * 32; if (memoryUsage > oldMemSize) { memWords = (memoryUsage - oldMemSize) / 32; long memGas = GasCost.MEMORY * memWords; program.spendGas(memGas, op.name() + " (memory usage)"); gasCost += memGas; } if(program.getNumber().intValue() == CONFIG.dumpBlock()) this.dumpLine(op, gasBefore, gasCost+callGas, memWords, program); switch (op) { case STOP:{ program.setHReturn(ByteBuffer.allocate(0)); 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 NEG:{ DataWord word1 = program.stackPop(); word1.negate(); 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 NOT: { 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(); DataWord result = null; 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(); ByteBuffer buffer = program.memoryChunk(memOffsetData, lengthData); byte[] encoded = HashUtil.sha3(buffer.array()); 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.longValue(); 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; if (op == OpCode.CODECOPY) fullCode = program.getCode(); else { DataWord address = program.stackPop(); fullCode = program.getCodeAt(address); } DataWord memOffsetData = program.stackPop(); BigInteger codeOffsetData = program.stackPop().value(); BigInteger lengthData = program.stackPop().value(); if (fullCode == null || BigInteger.valueOf(fullCode.length).compareTo( codeOffsetData.add(lengthData)) < 0) { program.stop(); break; } int length = lengthData.intValue(); int codeOffset = codeOffsetData.intValue(); byte[] codeCopy = new byte[length]; System.arraycopy(fullCode, codeOffset, codeCopy, 0, length); if (logger.isInfoEnabled()) hint = "code: " + Hex.toHexString(codeCopy); program.memorySave(memOffsetData.intValue(), codeCopy); program.step(); } break; case GASPRICE:{ DataWord gasPrice = program.getGasPrice(); if (logger.isInfoEnabled()) hint = "price: " + gasPrice.toString(); program.stackPush(gasPrice); program.step(); } break; case PREVHASH: { DataWord prevHash = program.getPrevHash(); if (logger.isInfoEnabled()) hint = "prevHash: " + prevHash; program.stackPush(prevHash); 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; DataWord word_1 = stack.peek(); stack.set(stack.size() - 1, stack.get(stack.size() - n)); stack.set(stack.size() - n, word_1); 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 = "addr: " + addr + " value: " + value; program.storageSave(addr, value); program.step(); } break; case JUMP:{ DataWord pos = program.stackPop(); int nextPC = pos.intValue(); if (nextPC != 0 && program.getOp(nextPC-1) != OpCode.JUMPDEST.val()) throw new BadJumpDestinationException(); 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(); if (nextPC != 0 && program.getOp(nextPC-1) != OpCode.JUMPDEST.val()) throw new BadJumpDestinationException(); 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); 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, 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(); 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, program.getPC(), String.format("%-12s", op.name()), program.getGas().value(), program.invokeData.getCallDeep(), hint); } MessageCall msg = new MessageCall( op.equals(CALL) ? MsgType.CALL : MsgType.STATELESS, gas, codeAddress, value, inDataOffs, inDataSize, outDataOffs, outDataSize); program.callToAddress(msg); program.step(); } break; case RETURN:{ DataWord offset = program.stackPop(); DataWord size = program.stackPop(); ByteBuffer hReturn = program.memoryChunk(offset, size); program.setHReturn(hReturn); if (logger.isInfoEnabled()) hint = "data: " + Hex.toHexString(hReturn.array()) + " 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; } if (logger.isInfoEnabled() && !op.equals(CALL) && !op.equals(CREATE)) logger.info(logString, stepBefore, String.format("%-12s", op.name()), program.getGas().longValue(), program.invokeData.getCallDeep(), hint); vmCounter++; } catch (RuntimeException e) { if(e instanceof OutOfGasException) program.spendAllGas(); logger.warn("VM halted", e.getMessage()); program.stop(); throw e; } finally { program.fullTrace(); } }  void step(Program program); void play(Program program);  }
@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.stack.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.stack.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.stack.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.stack.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.stack.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.stack.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.stack.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.stack.peek().getData()).toUpperCase() ); }
@Test(expected=RuntimeException.class) public void testPUSHN_1() { VM vm = new VM(); program = new Program(Hex.decode("61AA"), invoke); try { program.fullTrace(); vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test(expected=RuntimeException.class) public void testPUSHN_2() { VM vm = new VM(); program = new Program(Hex.decode("7fAABB"), invoke); try { program.fullTrace(); vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test public void testAND_1() { VM vm = new VM(); program = new Program(Hex.decode("600A600A10"), invoke); String expected = "000000000000000000000000000000000000000000000000000000000000000A"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); }
@Test public void testAND_2() { VM vm = new VM(); program = new Program(Hex.decode("60C0600A10"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); }
@Test(expected=RuntimeException.class) public void testAND_3() { VM vm = new VM(); program = new Program(Hex.decode("60C010"), 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("60F0600F11"), invoke); String expected = "00000000000000000000000000000000000000000000000000000000000000FF"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); }
@Test public void testOR_2() { VM vm = new VM(); program = new Program(Hex.decode("60C3603C11"), invoke); String expected = "00000000000000000000000000000000000000000000000000000000000000FF"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); }
@Test(expected=RuntimeException.class) public void testOR_3() { VM vm = new VM(); program = new Program(Hex.decode("60C011"), 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("60FF60FF12"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); }
@Test public void testXOR_2() { VM vm = new VM(); program = new Program(Hex.decode("600F60F012"), invoke); String expected = "00000000000000000000000000000000000000000000000000000000000000FF"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); }
@Test(expected=RuntimeException.class) public void testXOR_3() { VM vm = new VM(); program = new Program(Hex.decode("60C012"), 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("65AABBCCDDEEFF601E13"), invoke); String expected = "00000000000000000000000000000000000000000000000000000000000000EE"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); }
@Test public void testBYTE_2() { VM vm = new VM(); program = new Program(Hex.decode("65AABBCCDDEEFF602013"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); }
@Test public void testBYTE_3() { VM vm = new VM(); program = new Program(Hex.decode("65AABBCCDDEE3A601F13"), invoke); String expected = "000000000000000000000000000000000000000000000000000000000000003A"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); }
@Test(expected=StackTooSmallException.class) public void testBYTE_4() { VM vm = new VM(); program = new Program(Hex.decode("65AABBCCDDEE3A13"), 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("60000F"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); }
@Test public void testNOT_2() { VM vm = new VM(); program = new Program(Hex.decode("602A0F"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); }
@Test(expected=StackTooSmallException.class) public void testNOT_3() { VM vm = new VM(); program = new Program(Hex.decode("0F"), 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("602A602A0E"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); }
@Test public void testEQ_2() { VM vm = new VM(); program = new Program(Hex.decode("622A3B4C622A3B4C0E"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); }
@Test public void testEQ_3() { VM vm = new VM(); program = new Program(Hex.decode("622A3B5C622A3B4C0E"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); }
@Test(expected=StackTooSmallException.class) public void testEQ_4() { VM vm = new VM(); program = new Program(Hex.decode("622A3B4C0E"), 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("600160020B"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); }
@Test public void testGT_2() { VM vm = new VM(); program = new Program(Hex.decode("6001610F000B"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); }
@Test public void testGT_3() { VM vm = new VM(); program = new Program(Hex.decode("6301020304610F000B"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); }
@Test(expected=StackTooSmallException.class) public void testGT_4() { VM vm = new VM(); program = new Program(Hex.decode("622A3B4C0B"), 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("600160020D"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); }
@Test public void testSGT_2() { VM vm = new VM(); program = new Program(Hex.decode("7F000000000000000000000000000000000000000000000000000000000000001E" + "7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" + "0D"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); }
@Test public void testSGT_3() { VM vm = new VM(); program = new Program(Hex.decode("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" + "7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF57" + "0D"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); }
@Test(expected=StackTooSmallException.class) public void testSGT_4() { VM vm = new VM(); program = new Program(Hex.decode("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" + "0D"), 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("600160020A"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); }
@Test public void testLT_2() { VM vm = new VM(); program = new Program(Hex.decode("6001610F000A"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); }
@Test public void testLT_3() { VM vm = new VM(); program = new Program(Hex.decode("6301020304610F000A"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); }
@Test(expected=StackTooSmallException.class) public void testLT_4() { VM vm = new VM(); program = new Program(Hex.decode("622A3B4C0A"), 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("600160020C"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); }
@Test public void testSLT_2() { VM vm = new VM(); program = new Program(Hex.decode("7F000000000000000000000000000000000000000000000000000000000000001E" + "7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" + "0C"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); }
@Test public void testSLT_3() { VM vm = new VM(); program = new Program(Hex.decode("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" + "7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF57" + "0C"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); }
@Test(expected=StackTooSmallException.class) public void testSLT_4() { VM vm = new VM(); program = new Program(Hex.decode("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" + "0D"), invoke); try { vm.step(program); vm.step(program); vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test public void testNEG_1() { VM vm = new VM(); program = new Program(Hex.decode("600109"), invoke); String expected = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"; vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); }
@Test public void testNEG_2() { VM vm = new VM(); program = new Program(Hex.decode("61A00309"), invoke); String expected = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5FFD"; vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); }
@Test public void testNEG_3() { VM vm = new VM(); program = new Program(Hex.decode("61000009"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); }
@Test(expected=StackTooSmallException.class) public void testNEG_4() { VM vm = new VM(); program = new Program(Hex.decode("09"), 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.stack.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.stack.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("611234600054"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000001234"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.memory.array())); }
@Test public void testMSTORE_2() { VM vm = new VM(); program = new Program(Hex.decode("611234600054615566602054"), 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.memory.array())); }
@Test public void testMSTORE_3() { VM vm = new VM(); program = new Program(Hex.decode("611234600054615566602054618888600054"), 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.memory.array())); }
@Test public void testMSTORE_4() { VM vm = new VM(); program = new Program(Hex.decode("61123460A054"), invoke); String expected = "" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000001234"; vm.step(program); vm.step(program); vm.step(program); assertEquals(expected, Hex.toHexString(program.memory.array())); }
@Test(expected=StackTooSmallException.class) public void testMSTORE_5() { VM vm = new VM(); program = new Program(Hex.decode("61123454"), 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("600053"), invoke); String m_expected = "0000000000000000000000000000000000000000000000000000000000000000"; String s_expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); assertEquals(m_expected, Hex.toHexString(program.memory.array())); assertEquals(s_expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); }
@Test public void testMLOAD_2() { VM vm = new VM(); program = new Program(Hex.decode("602253"), invoke); String m_expected = "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000"; String s_expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); assertEquals(m_expected, Hex.toHexString(program.memory.array()).toUpperCase()); assertEquals(s_expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); }
@Test public void testMLOAD_3() { VM vm = new VM(); program = new Program(Hex.decode("602053"), invoke); String m_expected = "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000"; String s_expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); assertEquals(m_expected, Hex.toHexString(program.memory.array())); assertEquals(s_expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); }
@Test public void testMLOAD_4() { VM vm = new VM(); program = new Program(Hex.decode("611234602054602053"), 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.memory.array())); assertEquals(s_expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); }
@Test public void testMLOAD_5() { VM vm = new VM(); program = new Program(Hex.decode("611234602054601F53"), 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.memory.array())); assertEquals(s_expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); }
@Test(expected=StackTooSmallException.class) public void testMLOAD_6() { VM vm = new VM(); program = new Program(Hex.decode("53"), invoke); try { vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test public void testMSTORE8_1() { VM vm = new VM(); program = new Program(Hex.decode("6011600055"), invoke); String m_expected = "1100000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); assertEquals(m_expected, Hex.toHexString(program.memory.array())); }
@Test public void testMSTORE8_2() { VM vm = new VM(); program = new Program(Hex.decode("6022600155"), invoke); String m_expected = "0022000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); assertEquals(m_expected, Hex.toHexString(program.memory.array())); }
@Test public void testMSTORE8_3() { VM vm = new VM(); program = new Program(Hex.decode("6022602155"), invoke); String m_expected = "0000000000000000000000000000000000000000000000000000000000000000" + "0022000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); assertEquals(m_expected, Hex.toHexString(program.memory.array())); }
@Test(expected=StackTooSmallException.class) public void testMSTORE8_4() { 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 testSSTORE_1() { VM vm = new VM(); program = new Program(Hex.decode("602260AA57"), 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.result.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("602260AA57602260BB57"), 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.result.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("602257"), 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("60AA56"), invoke); String s_expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); assertEquals(s_expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); }
@Test public void testSLOAD_2() { VM vm = new VM(); program = new Program(Hex.decode("602260AA5760AA56"), 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.stack.peek().getData()).toUpperCase()); }
@Test public void testSLOAD_3() { VM vm = new VM(); program = new Program(Hex.decode("602260AA57603360CC5760CC56"), 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.stack.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("5A"), invoke); String s_expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); assertEquals(s_expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); }
@Test public void testPC_2() { VM vm = new VM(); program = new Program(Hex.decode("602260AA5760AA565A"), 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.stack.peek().getData()).toUpperCase()); }
@Test public void testJUMP_1() { VM vm = new VM(); program = new Program(Hex.decode("60AA60BB600E5860CC60DD60EE5D60FF"), 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.stack.peek().getData()).toUpperCase()); }
@Test(expected=BadJumpDestinationException.class) public void testJUMP_2() { VM vm = new VM(); program = new Program(Hex.decode("600C5860CC60DD60EE60FF"), invoke); try { vm.step(program); vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test public void testJUMPI_1() { VM vm = new VM(); program = new Program(Hex.decode("60016006595D60CC"), invoke); String s_expected = "00000000000000000000000000000000000000000000000000000000000000CC"; vm.step(program); vm.step(program); vm.step(program); vm.step(program); assertEquals(s_expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); }
@Test public void testJUMPI_2() { VM vm = new VM(); program = new Program(Hex.decode("630000000060445960CC60DD"), 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("600159"), 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("6001602259"), invoke); try { vm.step(program); vm.step(program); vm.step(program); } finally { assertTrue(program.isStopped()); } }
@Test public void testJUMPDEST_1() { VM vm = new VM(); program = new Program(Hex.decode("602360085860015d600257"), 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.result.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("60236001600a5960015d600257"), 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); DataWord key = new DataWord(Hex.decode(s_expected_key)); DataWord val = program.result.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("60026002600314"), 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("6110006002611002146000"), 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("61100265123456789009600214"), 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("61123414"), 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("60036002600415"), 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("622222226003600415"), 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("62222222623333336244444415"), 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("600115"), 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("5B"), 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("60206030545B"), 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); }
@Test public void testEXP_1() { VM vm = new VM(); program = new Program(Hex.decode("6003600208"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000008"; 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 testEXP_2() { VM vm = new VM(); program = new Program(Hex.decode("60006212345608"), 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 testEXP_3() { VM vm = new VM(); program = new Program(Hex.decode("6212345608"), 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("61123460005460206000F2"), 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().array()).toUpperCase()); assertTrue(program.isStopped()); }
@Test public void testRETURN_2() { VM vm = new VM(); program = new Program(Hex.decode("6112346000546020601FF2"), 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().array()).toUpperCase()); assertTrue(program.isStopped()); }
@Test public void testRETURN_3() { VM vm = new VM(); program = new Program(Hex.decode("7FA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B160005460206000F2"), 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().array()).toUpperCase()); assertTrue(program.isStopped()); }
@Test public void testRETURN_4() { VM vm = new VM(); program = new Program(Hex.decode("7FA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B160005460206010F2"), 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().array()).toUpperCase()); assertTrue(program.isStopped()); }
@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); assertEquals(m_expected_1, Hex.toHexString(program.memory.array()).toUpperCase()); }
@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); assertEquals(m_expected_1, Hex.toHexString(program.memory.array()).toUpperCase()); }
@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); assertTrue(program.isStopped()); }
@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); assertTrue(program.isStopped()); }
@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.memory.array()).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.memory.array()).toUpperCase()); }
@Test public void testEXTCODECOPY_3() { VM vm = new VM(); program = new Program(Hex.decode("605E6007600073471FD3AD3E9EEADEEC4608B92D16CE6B500704CC3C6000605f556014600054601e60205463abcddcba6040545b51602001600a5254516040016014525451606001601e5254516080016028525460a052546016604860003960166000f26000603f556103e75660005460005360200235"), invoke); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); assertTrue(program.isStopped()); }
@Test public void testEXTCODECOPY_4() { VM vm = new VM(); program = new Program(Hex.decode("605E6007600073471FD3AD3E9EEADEEC4608B92D16CE6B500704CC3C6000605f556014600054601e60205463abcddcba6040545b51602001600a5254516040016014525451606001601e5254516080016028525460a052546016604860003960166000f26000603f556103e756600054600053602002351234"), invoke); vm.step(program); vm.step(program); vm.step(program); vm.step(program); vm.step(program); assertTrue(program.isStopped()); }
@Test public void testEXTCODECOPY_5() { 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_6() { 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()); }
@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()); } }
@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.stack.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.stack.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.stack.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.stack.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.stack.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.stack.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.stack.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.stack.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.stack.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.stack.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.stack.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.stack.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.stack.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.stack.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.stack.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.stack.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.stack.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.stack.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.stack.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.stack.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.stack.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.stack.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.stack.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.stack.peek().getData()).toUpperCase() ); }