mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add test.
This commit is contained in:
parent
91ecc4533d
commit
aa1fd6a879
@ -22,8 +22,11 @@
|
|||||||
|
|
||||||
#include "../TestHelper.h"
|
#include "../TestHelper.h"
|
||||||
#include <libsolidity/interface/CompilerStack.h>
|
#include <libsolidity/interface/CompilerStack.h>
|
||||||
#include <json/json.h>
|
|
||||||
#include <libdevcore/Exceptions.h>
|
#include <libdevcore/Exceptions.h>
|
||||||
|
#include <libdevcore/SwarmHash.h>
|
||||||
|
|
||||||
|
#include <json/json.h>
|
||||||
|
|
||||||
namespace dev
|
namespace dev
|
||||||
{
|
{
|
||||||
@ -51,7 +54,7 @@ public:
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
CompilerStack m_compilerStack;
|
CompilerStack m_compilerStack;
|
||||||
Json::Reader m_reader;
|
Json::Reader m_reader;
|
||||||
};
|
};
|
||||||
@ -731,6 +734,23 @@ BOOST_AUTO_TEST_CASE(function_type)
|
|||||||
checkInterface(sourceCode, interface);
|
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()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user