diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2018-08-09 04:59:07 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-09 04:59:07 +0800 |
commit | 478012a00058767ab82b17a8cb21bfa5f6e7ee44 (patch) | |
tree | 5538a5522d23cf886f1f038f734aa34ad94a29c1 /test/libsolidity | |
parent | d634d20b5b0dac3e5caf1741073fa123fdd56ab9 (diff) | |
parent | d3c3fd20796dd18b7213938bd0ce89e8aeb9d6f3 (diff) | |
download | dexon-solidity-478012a00058767ab82b17a8cb21bfa5f6e7ee44.tar.gz dexon-solidity-478012a00058767ab82b17a8cb21bfa5f6e7ee44.tar.zst dexon-solidity-478012a00058767ab82b17a8cb21bfa5f6e7ee44.zip |
Merge pull request #4772 from ethereum/asm-json
Add tests for the assembler object (and avoid misusing string{} for u256)
Diffstat (limited to 'test/libsolidity')
-rw-r--r-- | test/libsolidity/StandardCompiler.cpp | 30 |
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()); |