From c26bca7d4449a1b63841992258dc7731e2f7178d Mon Sep 17 00:00:00 2001 From: nicksavers Date: Wed, 15 Oct 2014 11:12:55 +0200 Subject: [PATCH] Fix assert description and move exception --- .../src/main/java/org/ethereum/jsontestsuite/TestRunner.java | 2 +- ethereumj-core/src/main/java/org/ethereum/vm/Program.java | 3 +++ ethereumj-core/src/main/java/org/ethereum/vm/VM.java | 5 +---- ethereumj-core/src/test/java/org/ethereum/vm/VMTest.java | 3 +-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/ethereumj-core/src/main/java/org/ethereum/jsontestsuite/TestRunner.java b/ethereumj-core/src/main/java/org/ethereum/jsontestsuite/TestRunner.java index ac538d96..11f0066f 100644 --- a/ethereumj-core/src/main/java/org/ethereum/jsontestsuite/TestRunner.java +++ b/ethereumj-core/src/main/java/org/ethereum/jsontestsuite/TestRunner.java @@ -298,7 +298,7 @@ public class TestRunner { if (!expectedGas.equals(actualGas)) { String output = - String.format("Gas usage is different. Expected gas usage: [ %s ], actual gas usage: [ %s ]", + String.format("Gas remaining is different. Expected gas remaining: [ %s ], actual gas remaining: [ %s ]", expectedGas.toString() , actualGas.toString()); logger.info(output); diff --git a/ethereumj-core/src/main/java/org/ethereum/vm/Program.java b/ethereumj-core/src/main/java/org/ethereum/vm/Program.java index 0d689815..d48a0cbf 100644 --- a/ethereumj-core/src/main/java/org/ethereum/vm/Program.java +++ b/ethereumj-core/src/main/java/org/ethereum/vm/Program.java @@ -751,6 +751,9 @@ public class Program { public class OutOfGasException extends RuntimeException { } + @SuppressWarnings("serial") + public class IllegalOperationException extends RuntimeException {} + @SuppressWarnings("serial") public class StackTooSmallException extends RuntimeException { public StackTooSmallException(String message) { diff --git a/ethereumj-core/src/main/java/org/ethereum/vm/VM.java b/ethereumj-core/src/main/java/org/ethereum/vm/VM.java index 5935121e..769b30c7 100644 --- a/ethereumj-core/src/main/java/org/ethereum/vm/VM.java +++ b/ethereumj-core/src/main/java/org/ethereum/vm/VM.java @@ -80,7 +80,7 @@ public class VM { OpCode op = OpCode.code(program.getCurrentOp()); if (op == null) - throw new IllegalOperationException(); + throw program.new IllegalOperationException(); program.setLastOp(op.val()); @@ -1080,7 +1080,4 @@ public class VM { gasBefore, gasCost, memWords); } } - - @SuppressWarnings("serial") - public class IllegalOperationException extends RuntimeException {} } \ No newline at end of file diff --git a/ethereumj-core/src/test/java/org/ethereum/vm/VMTest.java b/ethereumj-core/src/test/java/org/ethereum/vm/VMTest.java index 4ffbb404..556a8635 100644 --- a/ethereumj-core/src/test/java/org/ethereum/vm/VMTest.java +++ b/ethereumj-core/src/test/java/org/ethereum/vm/VMTest.java @@ -5,7 +5,6 @@ import org.ethereum.util.ByteUtil; import org.ethereum.vm.Program.OutOfGasException; import org.ethereum.vm.Program.PcOverflowException; import org.ethereum.vm.Program.StackTooSmallException; -import org.ethereum.vm.VM.IllegalOperationException; import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runners.MethodSorters; @@ -3336,7 +3335,7 @@ public class VMTest { assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } - @Test(expected=IllegalOperationException.class) // INVALID OP + @Test(expected=Program.IllegalOperationException.class) // INVALID OP public void testINVALID_1() { VM vm = new VM();