aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-08-14 17:37:02 +0800
committerGitHub <noreply@github.com>2017-08-14 17:37:01 +0800
commit4d9790b6d5a490d30ed55b69fa117bc568fa4c64 (patch)
treebce6ff9a128203ff38ed7517d43fa212fb5e88c6 /test
parent52ccc264940c00ae8ffe015433bc1d094c1a4f1f (diff)
parentda3ac8640328c15872630d5d86976f17480f9492 (diff)
downloaddexon-solidity-4d9790b6d5a490d30ed55b69fa117bc568fa4c64.tar
dexon-solidity-4d9790b6d5a490d30ed55b69fa117bc568fa4c64.tar.gz
dexon-solidity-4d9790b6d5a490d30ed55b69fa117bc568fa4c64.tar.bz2
dexon-solidity-4d9790b6d5a490d30ed55b69fa117bc568fa4c64.tar.lz
dexon-solidity-4d9790b6d5a490d30ed55b69fa117bc568fa4c64.tar.xz
dexon-solidity-4d9790b6d5a490d30ed55b69fa117bc568fa4c64.tar.zst
dexon-solidity-4d9790b6d5a490d30ed55b69fa117bc568fa4c64.zip
Merge pull request #2703 from ethereum/warnAboutLargeStorageArrays
Warn about large storage structures.
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index 49a23e13..13843afa 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -6545,6 +6545,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"(