mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Make external library functions accessible.
This commit is contained in:
@@ -6955,6 +6955,21 @@ BOOST_AUTO_TEST_CASE(library_call)
|
||||
ABI_CHECK(callContractFunction("f(uint256)", u256(33)), encodeArgs(u256(33) * 9));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(library_function_external)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
library Lib { function m(bytes b) external pure returns (byte) { return b[2]; } }
|
||||
contract Test {
|
||||
function f(bytes b) public pure returns (byte) {
|
||||
return Lib.m(b);
|
||||
}
|
||||
}
|
||||
)";
|
||||
compileAndRun(sourceCode, 0, "Lib");
|
||||
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, Address>{{"Lib", m_contractAddress}});
|
||||
ABI_CHECK(callContractFunction("f(bytes)", u256(0x20), u256(5), "abcde"), encodeArgs("c"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(library_stray_values)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
library L {
|
||||
function f(uint) pure external {}
|
||||
}
|
||||
|
||||
contract C {
|
||||
using L for *;
|
||||
|
||||
function f() public pure {
|
||||
L.f(2);
|
||||
uint x;
|
||||
x.f();
|
||||
}
|
||||
}
|
||||
// ----
|
||||
Reference in New Issue
Block a user