Validate metadata JSON too

This commit is contained in:
Alex Beregszaszi 2017-05-24 09:54:25 +01:00
parent 804e99c633
commit 4612c7681c

View File

@ -19,6 +19,7 @@
* Unit tests for the metadata output.
*/
#include "../Metadata.h"
#include "../TestHelper.h"
#include <libsolidity/interface/CompilerStack.h>
#include <libdevcore/SwarmHash.h>
@ -44,7 +45,9 @@ BOOST_AUTO_TEST_CASE(metadata_stamp)
CompilerStack compilerStack;
BOOST_REQUIRE(compilerStack.compile(std::string(sourceCode)));
bytes const& bytecode = compilerStack.runtimeObject("test").bytecode;
bytes hash = dev::swarmHash(compilerStack.onChainMetadata("test")).asBytes();
std::string const& metadata = compilerStack.onChainMetadata("test");
BOOST_CHECK(dev::test::isValidMetadata(metadata));
bytes hash = dev::swarmHash(metadata).asBytes();
BOOST_REQUIRE(hash.size() == 32);
BOOST_REQUIRE(bytecode.size() >= 2);
size_t metadataCBORSize = (size_t(bytecode.end()[-2]) << 8) + size_t(bytecode.end()[-1]);