mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
add some test-cases for unverified library addresses
This commit is contained in:
parent
df03f1412d
commit
e9365e93fc
@ -0,0 +1,33 @@
|
||||
{
|
||||
"language": "Solidity",
|
||||
"sources": {
|
||||
"A": {
|
||||
"content": "
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
pragma solidity >=0.0;
|
||||
|
||||
library L {
|
||||
function f() external {}
|
||||
}
|
||||
|
||||
contract C {
|
||||
function foo() public {
|
||||
L.f();
|
||||
}
|
||||
}
|
||||
"
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"libraries": {
|
||||
"A": {
|
||||
"L": ""
|
||||
}
|
||||
},
|
||||
"outputSelection": {
|
||||
"*": {
|
||||
"C": ["evm.bytecode.object", "evm.bytecode.linkReferences"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
{
|
||||
"errors":
|
||||
[
|
||||
{
|
||||
"component": "general",
|
||||
"formattedMessage": "Library address is not prefixed with \"0x\".",
|
||||
"message": "Library address is not prefixed with \"0x\".",
|
||||
"severity": "error",
|
||||
"type": "JSONError"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
{
|
||||
"language": "Solidity",
|
||||
"sources": {
|
||||
"A": {
|
||||
"content": "
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
pragma solidity >=0.0;
|
||||
|
||||
library L {
|
||||
function f() external {}
|
||||
}
|
||||
|
||||
contract C {
|
||||
function foo() public {
|
||||
L.f();
|
||||
}
|
||||
}
|
||||
"
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"libraries": {
|
||||
"A": {
|
||||
"L": "0x123456789012345678901234567890123456789T"
|
||||
}
|
||||
},
|
||||
"outputSelection": {
|
||||
"*": {
|
||||
"C": ["evm.bytecode.object", "evm.bytecode.linkReferences"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
{
|
||||
"errors":
|
||||
[
|
||||
{
|
||||
"component": "general",
|
||||
"formattedMessage": "Invalid library address (\"0x123456789012345678901234567890123456789T\") supplied.",
|
||||
"message": "Invalid library address (\"0x123456789012345678901234567890123456789T\") supplied.",
|
||||
"severity": "error",
|
||||
"type": "JSONError"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
{
|
||||
"language": "Solidity",
|
||||
"sources": {
|
||||
"A": {
|
||||
"content": "
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
pragma solidity >=0.0;
|
||||
|
||||
library L {
|
||||
function f() external {}
|
||||
}
|
||||
|
||||
contract C {
|
||||
function foo() public {
|
||||
L.f();
|
||||
}
|
||||
}
|
||||
"
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"libraries": {
|
||||
"A": {
|
||||
"L": "0x2323232232323"
|
||||
}
|
||||
},
|
||||
"outputSelection": {
|
||||
"*": {
|
||||
"C": ["evm.bytecode.object", "evm.bytecode.linkReferences"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
{
|
||||
"errors":
|
||||
[
|
||||
{
|
||||
"component": "general",
|
||||
"formattedMessage": "Library address is of invalid length.",
|
||||
"message": "Library address is of invalid length.",
|
||||
"severity": "error",
|
||||
"type": "JSONError"
|
||||
}
|
||||
]
|
||||
}
|
@ -399,6 +399,76 @@ BOOST_AUTO_TEST_CASE(standard_json_mode_options)
|
||||
BOOST_TEST(parsedOptions == expectedOptions);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(invalid_library_address_length)
|
||||
{
|
||||
vector<string> commandLine = {
|
||||
"solc",
|
||||
"contract.sol",
|
||||
"--libraries="
|
||||
"dir1/file1.sol:L=0x"
|
||||
};
|
||||
|
||||
string expectedMessage = "Invalid length for address for library \"dir1/file1.sol:L\": 0 instead of 40 characters.";
|
||||
auto hasCorrectMessage = [&](CommandLineValidationError const& _exception) {
|
||||
return _exception.what() == expectedMessage;
|
||||
};
|
||||
|
||||
BOOST_CHECK_EXCEPTION(parseCommandLine(commandLine), CommandLineValidationError, hasCorrectMessage);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(invalid_library_address_empty)
|
||||
{
|
||||
vector<string> commandLine = {
|
||||
"solc",
|
||||
"contract.sol",
|
||||
"--libraries="
|
||||
"dir1/file1.sol:L="
|
||||
};
|
||||
|
||||
string expectedMessage = "Empty address provided for library \"dir1/file1.sol:L\".\n"
|
||||
"Note that there should not be any whitespace after the equal sign." ;
|
||||
auto hasCorrectMessage = [&](CommandLineValidationError const& _exception) {
|
||||
return _exception.what() == expectedMessage;
|
||||
};
|
||||
|
||||
BOOST_CHECK_EXCEPTION(parseCommandLine(commandLine), CommandLineValidationError, hasCorrectMessage);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(invalid_library_address_prefix)
|
||||
{
|
||||
vector<string> commandLine = {
|
||||
"solc",
|
||||
"contract.sol",
|
||||
"--libraries="
|
||||
"dir1/file1.sol:L=1111122222333334444455555666667777788888"
|
||||
};
|
||||
|
||||
string expectedMessage = "The address 1111122222333334444455555666667777788888 is not prefixed with \"0x\".\n"
|
||||
"Note that the address must be prefixed with \"0x\"." ;
|
||||
auto hasCorrectMessage = [&](CommandLineValidationError const& _exception) {
|
||||
return _exception.what() == expectedMessage;
|
||||
};
|
||||
|
||||
BOOST_CHECK_EXCEPTION(parseCommandLine(commandLine), CommandLineValidationError, hasCorrectMessage);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(invalid_library_address_checksum)
|
||||
{
|
||||
vector<string> commandLine = {
|
||||
"solc",
|
||||
"contract.sol",
|
||||
"--libraries="
|
||||
"dir1/file1.sol:L=0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaaa"
|
||||
};
|
||||
|
||||
string expectedMessage = "Invalid checksum on address for library \"dir1/file1.sol:L\": aAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaaa\n"
|
||||
"The correct checksum is 0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa";
|
||||
auto hasCorrectMessage
|
||||
= [&](CommandLineValidationError const& _exception) { return _exception.what() == expectedMessage; };
|
||||
|
||||
BOOST_CHECK_EXCEPTION(parseCommandLine(commandLine), CommandLineValidationError, hasCorrectMessage);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(invalid_options_input_modes_combinations)
|
||||
{
|
||||
map<string, vector<string>> invalidOptionInputModeCombinations = {
|
||||
|
Loading…
Reference in New Issue
Block a user