mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Remove duplicated code in test/Metadata
This commit is contained in:
parent
26de5684a2
commit
43ccc75293
@ -44,19 +44,7 @@ bytes bytecodeSansMetadata(bytes const& _bytecode)
|
|||||||
|
|
||||||
string bytecodeSansMetadata(string const& _bytecode)
|
string bytecodeSansMetadata(string const& _bytecode)
|
||||||
{
|
{
|
||||||
/// The metadata hash takes up 43 bytes (or 86 characters in hex)
|
return toHex(bytecodeSansMetadata(fromHex(_bytecode, WhenError::Throw)));
|
||||||
/// /a165627a7a72305820([0-9a-f]{64})0029$/
|
|
||||||
|
|
||||||
if (_bytecode.size() < 88)
|
|
||||||
return _bytecode;
|
|
||||||
|
|
||||||
if (_bytecode.substr(_bytecode.size() - 4, 4) != "0029")
|
|
||||||
return _bytecode;
|
|
||||||
|
|
||||||
if (_bytecode.substr(_bytecode.size() - 86, 18) != "a165627a7a72305820")
|
|
||||||
return _bytecode;
|
|
||||||
|
|
||||||
return _bytecode.substr(0, _bytecode.size() - 86);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isValidMetadata(string const& _metadata)
|
bool isValidMetadata(string const& _metadata)
|
||||||
|
@ -31,6 +31,7 @@ namespace test
|
|||||||
bytes bytecodeSansMetadata(bytes const& _bytecode);
|
bytes bytecodeSansMetadata(bytes const& _bytecode);
|
||||||
|
|
||||||
/// Returns the bytecode with the metadata hash stripped out.
|
/// Returns the bytecode with the metadata hash stripped out.
|
||||||
|
/// Throws exception on invalid hex string.
|
||||||
std::string bytecodeSansMetadata(std::string const& _bytecode);
|
std::string bytecodeSansMetadata(std::string const& _bytecode);
|
||||||
|
|
||||||
/// Expects a serialised metadata JSON and returns true if the
|
/// Expects a serialised metadata JSON and returns true if the
|
||||||
|
Loading…
Reference in New Issue
Block a user