diff options
author | chriseth <c@ethdev.com> | 2015-09-15 22:23:06 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-09-15 22:23:06 +0800 |
commit | 9d43f2c186d1ad4027d42f6b155bea5500efa0e5 (patch) | |
tree | 55116e80169b079fa80f41acd75707a252be880f /test/libsolidity | |
parent | 9de174ce2e8ec0952c6ea1113238299d82f14165 (diff) | |
parent | 152bc642a6e8025d7957898e25848c9c836eb462 (diff) | |
download | dexon-solidity-9d43f2c186d1ad4027d42f6b155bea5500efa0e5.tar.gz dexon-solidity-9d43f2c186d1ad4027d42f6b155bea5500efa0e5.tar.zst dexon-solidity-9d43f2c186d1ad4027d42f6b155bea5500efa0e5.zip |
Merge pull request #32 from LianaHus/sol_compiletime_check_for_out_of_bound_access_for_arrays
Sol compiletime check for out of bound index(integer constant) access for Ordinary arrays
Diffstat (limited to 'test/libsolidity')
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 5 | ||||
-rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 15 |
2 files changed, 18 insertions, 2 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index c56845aa..2ba6ab85 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -1248,6 +1248,7 @@ BOOST_AUTO_TEST_CASE(convert_fixed_bytes_to_fixed_bytes_same_size) compileAndRun(sourceCode); BOOST_CHECK(callContractFunction("bytesToBytes(bytes4)", "abcd") == encodeArgs("abcd")); } + // fixed bytes to uint conversion tests BOOST_AUTO_TEST_CASE(convert_fixed_bytes_to_uint_same_size) { @@ -1300,6 +1301,7 @@ BOOST_AUTO_TEST_CASE(convert_fixed_bytes_to_uint_greater_size) BOOST_CHECK(callContractFunction("bytesToUint(bytes4)", string("abcd")) == encodeArgs(u256("0x61626364"))); } + // uint fixed bytes conversion tests BOOST_AUTO_TEST_CASE(convert_uint_to_fixed_bytes_same_size) { @@ -4188,7 +4190,8 @@ BOOST_AUTO_TEST_CASE(evm_exceptions_in_constructor_out_of_baund) uint[3] arr; function A() { - test = arr[5]; + uint index = 5; + test = arr[index]; ++test; } } diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 5d174367..2a720494 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -2250,10 +2250,23 @@ BOOST_AUTO_TEST_CASE(creating_contract_within_the_contract) function f() { var x = new Test(); } } )"; - BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); } +BOOST_AUTO_TEST_CASE(array_out_of_bound_access) +{ + char const* text = R"( + contract c { + uint[2] dataArray; + function set5th() returns (bool) { + dataArray[5] = 2; + return true; + } + } + )"; + BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError); +} + BOOST_AUTO_TEST_SUITE_END() } |