aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/StandardCompiler.cpp
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2018-08-09 03:43:44 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2018-08-09 03:52:18 +0800
commit0eeb06b6ead4c6446c7584f7dd5e6c21ec5d26c4 (patch)
treeb6028c839ea5efeecfb96c5d5ac2a8a14eae8a3b /test/libsolidity/StandardCompiler.cpp
parenta16461249feb564b3ea581e8056fead8152999d0 (diff)
downloaddexon-solidity-0eeb06b6ead4c6446c7584f7dd5e6c21ec5d26c4.tar.gz
dexon-solidity-0eeb06b6ead4c6446c7584f7dd5e6c21ec5d26c4.tar.zst
dexon-solidity-0eeb06b6ead4c6446c7584f7dd5e6c21ec5d26c4.zip
Test for legacyAssembly in StandardCompiler
Diffstat (limited to 'test/libsolidity/StandardCompiler.cpp')
-rw-r--r--test/libsolidity/StandardCompiler.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/test/libsolidity/StandardCompiler.cpp b/test/libsolidity/StandardCompiler.cpp
index 16921a24..4b0a2d13 100644
--- a/test/libsolidity/StandardCompiler.cpp
+++ b/test/libsolidity/StandardCompiler.cpp
@@ -238,7 +238,7 @@ BOOST_AUTO_TEST_CASE(basic_compilation)
"settings": {
"outputSelection": {
"fileA": {
- "A": [ "abi", "devdoc", "userdoc", "evm.bytecode", "evm.assembly", "evm.gasEstimates", "metadata" ],
+ "A": [ "abi", "devdoc", "userdoc", "evm.bytecode", "evm.assembly", "evm.gasEstimates", "evm.legacyAssembly", "metadata" ],
"": [ "legacyAST" ]
}
}
@@ -280,6 +280,34 @@ BOOST_AUTO_TEST_CASE(basic_compilation)
dev::jsonCompactPrint(contract["evm"]["gasEstimates"]),
"{\"creation\":{\"codeDepositCost\":\"10600\",\"executionCost\":\"66\",\"totalCost\":\"10666\"}}"
);
+ // Lets take the top level `.code` section (the "deployer code"), that should expose most of the features of
+ // the assembly JSON. What we want to check here is Operation, Push, PushTag, PushSub, PushSubSize and Tag.
+ BOOST_CHECK(contract["evm"]["legacyAssembly"].isObject());
+ BOOST_CHECK(contract["evm"]["legacyAssembly"][".code"].isArray());
+ BOOST_CHECK_EQUAL(
+ dev::jsonCompactPrint(contract["evm"]["legacyAssembly"][".code"]),
+ "[{\"begin\":0,\"end\":14,\"name\":\"PUSH\",\"value\":\"80\"},"
+ "{\"begin\":0,\"end\":14,\"name\":\"PUSH\",\"value\":\"40\"},"
+ "{\"begin\":0,\"end\":14,\"name\":\"MSTORE\"},"
+ "{\"begin\":0,\"end\":14,\"name\":\"CALLVALUE\"},"
+ "{\"begin\":8,\"end\":17,\"name\":\"DUP1\"},"
+ "{\"begin\":5,\"end\":7,\"name\":\"ISZERO\"},"
+ "{\"begin\":5,\"end\":7,\"name\":\"PUSH [tag]\",\"value\":\"1\"},"
+ "{\"begin\":5,\"end\":7,\"name\":\"JUMPI\"},"
+ "{\"begin\":30,\"end\":31,\"name\":\"PUSH\",\"value\":\"0\"},"
+ "{\"begin\":27,\"end\":28,\"name\":\"DUP1\"},"
+ "{\"begin\":20,\"end\":32,\"name\":\"REVERT\"},"
+ "{\"begin\":5,\"end\":7,\"name\":\"tag\",\"value\":\"1\"},"
+ "{\"begin\":5,\"end\":7,\"name\":\"JUMPDEST\"},"
+ "{\"begin\":0,\"end\":14,\"name\":\"POP\"},"
+ "{\"begin\":0,\"end\":14,\"name\":\"PUSH #[$]\",\"value\":\"0000000000000000000000000000000000000000000000000000000000000000\"},"
+ "{\"begin\":0,\"end\":14,\"name\":\"DUP1\"},"
+ "{\"begin\":0,\"end\":14,\"name\":\"PUSH [$]\",\"value\":\"0000000000000000000000000000000000000000000000000000000000000000\"},"
+ "{\"begin\":0,\"end\":14,\"name\":\"PUSH\",\"value\":\"0\"},"
+ "{\"begin\":0,\"end\":14,\"name\":\"CODECOPY\"},"
+ "{\"begin\":0,\"end\":14,\"name\":\"PUSH\",\"value\":\"0\"},"
+ "{\"begin\":0,\"end\":14,\"name\":\"RETURN\"}]"
+ );
BOOST_CHECK(contract["metadata"].isString());
BOOST_CHECK(dev::test::isValidMetadata(contract["metadata"].asString()));
BOOST_CHECK(result["sources"].isObject());