aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2018-02-28 23:57:35 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2018-03-01 19:03:56 +0800
commitb6dfd9ef5422d80177b622fc2c486de00fcc0f73 (patch)
treea1b20ed0c80eae0bf01597070fb62a22cf17ba33 /test
parent9e3da89a7a0753e869b4668f9587385c9b37ba8d (diff)
downloaddexon-solidity-b6dfd9ef5422d80177b622fc2c486de00fcc0f73.tar
dexon-solidity-b6dfd9ef5422d80177b622fc2c486de00fcc0f73.tar.gz
dexon-solidity-b6dfd9ef5422d80177b622fc2c486de00fcc0f73.tar.bz2
dexon-solidity-b6dfd9ef5422d80177b622fc2c486de00fcc0f73.tar.lz
dexon-solidity-b6dfd9ef5422d80177b622fc2c486de00fcc0f73.tar.xz
dexon-solidity-b6dfd9ef5422d80177b622fc2c486de00fcc0f73.tar.zst
dexon-solidity-b6dfd9ef5422d80177b622fc2c486de00fcc0f73.zip
Ensure that library addresses supplied are of correct length and hex prefixed in JSONIO
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/StandardCompiler.cpp34
1 files changed, 27 insertions, 7 deletions
diff --git a/test/libsolidity/StandardCompiler.cpp b/test/libsolidity/StandardCompiler.cpp
index 0bb94172..eb2773ba 100644
--- a/test/libsolidity/StandardCompiler.cpp
+++ b/test/libsolidity/StandardCompiler.cpp
@@ -633,7 +633,7 @@ BOOST_AUTO_TEST_CASE(libraries_invalid_hex)
BOOST_CHECK(containsError(result, "JSONError", "Invalid library address (\"0x4200000000000000000000000000000000000xx1\") supplied."));
}
-BOOST_AUTO_TEST_CASE(libraries_various_addresses)
+BOOST_AUTO_TEST_CASE(libraries_invalid_length)
{
char const* input = R"(
{
@@ -641,11 +641,8 @@ BOOST_AUTO_TEST_CASE(libraries_various_addresses)
"settings": {
"libraries": {
"library.sol": {
- "L": 42,
- "L3": "42",
- "L4": "0x42",
- "L5": "0x4200000000000000000000000000000000000001",
- "L6": "4200000000000000000000000000000000000001"
+ "L1": "0x42",
+ "L2": "0x4200000000000000000000000000000000000001ff"
}
}
},
@@ -657,7 +654,30 @@ BOOST_AUTO_TEST_CASE(libraries_various_addresses)
}
)";
Json::Value result = compile(input);
- BOOST_CHECK(containsAtMostWarnings(result));
+ BOOST_CHECK(containsError(result, "JSONError", "Library address is of invalid length."));
+}
+
+BOOST_AUTO_TEST_CASE(libraries_missing_hex_prefix)
+{
+ char const* input = R"(
+ {
+ "language": "Solidity",
+ "settings": {
+ "libraries": {
+ "library.sol": {
+ "L": "4200000000000000000000000000000000000001"
+ }
+ }
+ },
+ "sources": {
+ "empty": {
+ "content": ""
+ }
+ }
+ }
+ )";
+ Json::Value result = compile(input);
+ BOOST_CHECK(containsError(result, "JSONError", "Library address is not prefixed with \"0x\"."));
}
BOOST_AUTO_TEST_CASE(library_linking)