mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #1325 from LefterisJP/sol_MsgSig
Adding msg.sig Solidity Magic type
This commit is contained in:
commit
e26f2dcaae
@ -1031,6 +1031,35 @@ BOOST_AUTO_TEST_CASE(blockchain)
|
|||||||
BOOST_CHECK(callContractFunctionWithValue("someInfo()", 28) == encodeArgs(28, 0, 1));
|
BOOST_CHECK(callContractFunctionWithValue("someInfo()", 28) == encodeArgs(28, 0, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(msg_sig)
|
||||||
|
{
|
||||||
|
char const* sourceCode = R"(
|
||||||
|
contract test {
|
||||||
|
function foo(uint256 a) returns (bytes4 value) {
|
||||||
|
return msg.sig;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
compileAndRun(sourceCode);
|
||||||
|
BOOST_CHECK(callContractFunctionWithValue("foo(uint256)", 13) == encodeArgs(asString(FixedHash<4>(dev::sha3("foo(uint256)")).asBytes())));
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(msg_sig_after_internal_call_is_same)
|
||||||
|
{
|
||||||
|
char const* sourceCode = R"(
|
||||||
|
contract test {
|
||||||
|
function boo() returns (bytes4 value) {
|
||||||
|
return msg.sig;
|
||||||
|
}
|
||||||
|
function foo(uint256 a) returns (bytes4 value) {
|
||||||
|
return boo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
compileAndRun(sourceCode);
|
||||||
|
BOOST_CHECK(callContractFunctionWithValue("foo(uint256)", 13) == encodeArgs(asString(FixedHash<4>(dev::sha3("foo(uint256)")).asBytes())));
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(now)
|
BOOST_AUTO_TEST_CASE(now)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = "contract test {\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user