diff options
author | chriseth <chris@ethereum.org> | 2017-08-07 21:44:35 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2017-08-12 02:57:57 +0800 |
commit | da3ac8640328c15872630d5d86976f17480f9492 (patch) | |
tree | 8e2134191c50dd31657b3c78b1d4bc7166ae4a11 /test/libsolidity | |
parent | d968912a4ce89a40d7d03bf0748a07c397662f68 (diff) | |
download | dexon-solidity-da3ac8640328c15872630d5d86976f17480f9492.tar.gz dexon-solidity-da3ac8640328c15872630d5d86976f17480f9492.tar.zst dexon-solidity-da3ac8640328c15872630d5d86976f17480f9492.zip |
Warn about large storage structures.
Diffstat (limited to 'test/libsolidity')
-rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index f7648bd7..5c01a245 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -6536,6 +6536,57 @@ BOOST_AUTO_TEST_CASE(constructor_without_implementation) CHECK_ERROR(text, TypeError, "Constructor must be implemented if declared."); } +BOOST_AUTO_TEST_CASE(large_storage_array_fine) +{ + char const* text = R"( + contract C { + uint[2**64 - 1] x; + } + )"; + CHECK_SUCCESS_NO_WARNINGS(text); +} + +BOOST_AUTO_TEST_CASE(large_storage_array_simple) +{ + char const* text = R"( + contract C { + uint[2**64] x; + } + )"; + CHECK_WARNING(text, "covers a large part of storage and thus makes collisions likely"); +} + +BOOST_AUTO_TEST_CASE(large_storage_arrays_combined) +{ + char const* text = R"( + contract C { + uint[200][200][2**30][][2**30] x; + } + )"; + CHECK_WARNING(text, "covers a large part of storage and thus makes collisions likely"); +} + +BOOST_AUTO_TEST_CASE(large_storage_arrays_struct) +{ + char const* text = R"( + contract C { + struct S { uint[2**30] x; uint[2**50] y; } + S[2**20] x; + } + )"; + CHECK_WARNING(text, "covers a large part of storage and thus makes collisions likely"); +} + +BOOST_AUTO_TEST_CASE(large_storage_array_mapping) +{ + char const* text = R"( + contract C { + mapping(uint => uint[2**100]) x; + } + )"; + CHECK_WARNING(text, "covers a large part of storage and thus makes collisions likely"); +} + BOOST_AUTO_TEST_CASE(library_function_without_implementation) { char const* text = R"( |