aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/SolidityEndToEndTest.cpp
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-05-30 17:29:15 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-05-30 20:57:44 +0800
commitdcb7c51920a947e57371b7dc92417f47ee5cc65c (patch)
tree40fbd6460fca748fff725278851145c1010e23d7 /test/libsolidity/SolidityEndToEndTest.cpp
parent524a52660d01025954374e7902ab6df68e466c26 (diff)
downloaddexon-solidity-dcb7c51920a947e57371b7dc92417f47ee5cc65c.tar.gz
dexon-solidity-dcb7c51920a947e57371b7dc92417f47ee5cc65c.tar.zst
dexon-solidity-dcb7c51920a947e57371b7dc92417f47ee5cc65c.zip
Add inline assembly test for sha3/keccak256
Diffstat (limited to 'test/libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 3707a65c..aae8b146 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -9338,6 +9338,45 @@ BOOST_AUTO_TEST_CASE(interface)
BOOST_CHECK(callContractFunction("f(address)", recipient) == encodeArgs(true));
}
+BOOST_AUTO_TEST_CASE(keccak256_assembly)
+{
+ char const* sourceCode = R"(
+ contract C {
+ function f() returns (bytes32 ret) {
+ assembly {
+ ret := keccak256(0, 0)
+ }
+ }
+ function g() returns (bytes32 ret) {
+ assembly {
+ 0
+ 0
+ keccak256
+ =: ret
+ }
+ }
+ function h() returns (bytes32 ret) {
+ assembly {
+ ret := sha3(0, 0)
+ }
+ }
+ function i() returns (bytes32 ret) {
+ assembly {
+ 0
+ 0
+ sha3
+ =: ret
+ }
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "C");
+ BOOST_CHECK(callContractFunction("f()") == fromHex("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"));
+ BOOST_CHECK(callContractFunction("g()") == fromHex("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"));
+ BOOST_CHECK(callContractFunction("h()") == fromHex("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"));
+ BOOST_CHECK(callContractFunction("i()") == fromHex("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"));
+}
+
BOOST_AUTO_TEST_SUITE_END()
}