aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2016-11-24 17:55:32 +0800
committerchriseth <c@ethdev.com>2016-12-01 23:03:59 +0800
commitaa1fd6a879eaedc5c4df2951c06e9dc3eb6eaeb4 (patch)
treeb81e1dcea319c100d160db3da687c9361ff4be31
parent91ecc4533dffbe67fa27adfaff27780ddf69c21a (diff)
downloaddexon-solidity-aa1fd6a879eaedc5c4df2951c06e9dc3eb6eaeb4.tar.gz
dexon-solidity-aa1fd6a879eaedc5c4df2951c06e9dc3eb6eaeb4.tar.zst
dexon-solidity-aa1fd6a879eaedc5c4df2951c06e9dc3eb6eaeb4.zip
Add test.
-rw-r--r--test/libsolidity/SolidityABIJSON.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/test/libsolidity/SolidityABIJSON.cpp b/test/libsolidity/SolidityABIJSON.cpp
index 6fc2bcee..f5f8b342 100644
--- a/test/libsolidity/SolidityABIJSON.cpp
+++ b/test/libsolidity/SolidityABIJSON.cpp
@@ -22,8 +22,11 @@
#include "../TestHelper.h"
#include <libsolidity/interface/CompilerStack.h>
-#include <json/json.h>
+
#include <libdevcore/Exceptions.h>
+#include <libdevcore/SwarmHash.h>
+
+#include <json/json.h>
namespace dev
{
@@ -51,7 +54,7 @@ public:
);
}
-private:
+protected:
CompilerStack m_compilerStack;
Json::Reader m_reader;
};
@@ -731,6 +734,23 @@ BOOST_AUTO_TEST_CASE(function_type)
checkInterface(sourceCode, interface);
}
+BOOST_AUTO_TEST_CASE(metadata_stamp)
+{
+ // Check that the metadata stamp is at the end of the runtime bytecode.
+ char const* sourceCode = R"(
+ pragma solidity >=0.0;
+ contract test {
+ function g(function(uint) external returns (uint) x) {}
+ }
+ )";
+ BOOST_REQUIRE(m_compilerStack.compile(std::string(sourceCode)));
+ bytes const& bytecode = m_compilerStack.runtimeObject("test").bytecode;
+ bytes hash = dev::swarmHash(m_compilerStack.onChainMetadata("test")).asBytes();
+ BOOST_REQUIRE(hash.size() == 32);
+ BOOST_REQUIRE(bytecode.size() >= hash.size());
+ BOOST_CHECK(std::equal(hash.begin(), hash.end(), bytecode.end() - 32));
+}
+
BOOST_AUTO_TEST_SUITE_END()
}