mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge remote-tracking branch 'origin/develop' into breaking
This commit is contained in:
commit
a3c5d37d02
@ -820,7 +820,7 @@ jobs:
|
|||||||
|
|
||||||
t_ems_compile_ext_gnosis:
|
t_ems_compile_ext_gnosis:
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/node:10
|
- image: circleci/node:14
|
||||||
environment:
|
environment:
|
||||||
TERM: xterm
|
TERM: xterm
|
||||||
steps:
|
steps:
|
||||||
@ -835,7 +835,8 @@ jobs:
|
|||||||
|
|
||||||
t_ems_test_ext_gnosis:
|
t_ems_test_ext_gnosis:
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/node:10
|
# NOTE: Tests do not start on node.js 14 ("ganache-cli exited early with code 1").
|
||||||
|
- image: circleci/node:12
|
||||||
environment:
|
environment:
|
||||||
TERM: xterm
|
TERM: xterm
|
||||||
steps:
|
steps:
|
||||||
@ -845,13 +846,47 @@ jobs:
|
|||||||
- run:
|
- run:
|
||||||
name: External GnosisSafe tests
|
name: External GnosisSafe tests
|
||||||
command: |
|
command: |
|
||||||
test/externalTests/gnosis.sh /tmp/workspace/soljson.js || test/externalTests/gnosis.sh /tmp/workspace/soljson.js
|
test/externalTests/gnosis.sh /tmp/workspace/soljson.js
|
||||||
- run: *gitter_notify_failure
|
# TODO: Re-enable notifications once this is running nightly rather than as a PR check
|
||||||
- run: *gitter_notify_success
|
#- run: *gitter_notify_failure
|
||||||
|
#- run: *gitter_notify_success
|
||||||
|
|
||||||
|
t_ems_compile_ext_gnosis_v2:
|
||||||
|
docker:
|
||||||
|
- image: circleci/node:14
|
||||||
|
environment:
|
||||||
|
TERM: xterm
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- attach_workspace:
|
||||||
|
at: /tmp/workspace
|
||||||
|
- run:
|
||||||
|
name: External GnosisSafe v2 compilation
|
||||||
|
command: |
|
||||||
|
export COMPILE_ONLY=1
|
||||||
|
test/externalTests/gnosis-v2.sh /tmp/workspace/soljson.js
|
||||||
|
|
||||||
|
t_ems_test_ext_gnosis_v2:
|
||||||
|
docker:
|
||||||
|
# NOTE: Tests do not start on node.js 14 ("ganache-cli exited early with code 1").
|
||||||
|
- image: circleci/node:12
|
||||||
|
environment:
|
||||||
|
TERM: xterm
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- attach_workspace:
|
||||||
|
at: /tmp/workspace
|
||||||
|
- run:
|
||||||
|
name: External GnosisSafe v2 tests
|
||||||
|
command: |
|
||||||
|
test/externalTests/gnosis-v2.sh /tmp/workspace/soljson.js
|
||||||
|
# TODO: Re-enable notifications once this is running nightly rather than as a PR check
|
||||||
|
#- run: *gitter_notify_failure
|
||||||
|
#- run: *gitter_notify_success
|
||||||
|
|
||||||
t_ems_compile_ext_zeppelin:
|
t_ems_compile_ext_zeppelin:
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/node:10
|
- image: circleci/node:14
|
||||||
environment:
|
environment:
|
||||||
TERM: xterm
|
TERM: xterm
|
||||||
steps:
|
steps:
|
||||||
@ -866,7 +901,7 @@ jobs:
|
|||||||
|
|
||||||
t_ems_test_ext_zeppelin:
|
t_ems_test_ext_zeppelin:
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/node:10
|
- image: circleci/node:14
|
||||||
environment:
|
environment:
|
||||||
TERM: xterm
|
TERM: xterm
|
||||||
steps:
|
steps:
|
||||||
@ -876,13 +911,14 @@ jobs:
|
|||||||
- run:
|
- run:
|
||||||
name: External Zeppelin tests
|
name: External Zeppelin tests
|
||||||
command: |
|
command: |
|
||||||
test/externalTests/zeppelin.sh /tmp/workspace/soljson.js || test/externalTests/zeppelin.sh /tmp/workspace/soljson.js
|
test/externalTests/zeppelin.sh /tmp/workspace/soljson.js
|
||||||
- run: *gitter_notify_failure
|
# TODO: Re-enable notifications once this is running nightly rather than as a PR check
|
||||||
- run: *gitter_notify_success
|
#- run: *gitter_notify_failure
|
||||||
|
#- run: *gitter_notify_success
|
||||||
|
|
||||||
t_ems_compile_ext_colony:
|
t_ems_compile_ext_colony:
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/node:10
|
- image: circleci/node:14
|
||||||
environment:
|
environment:
|
||||||
TERM: xterm
|
TERM: xterm
|
||||||
steps:
|
steps:
|
||||||
@ -901,7 +937,7 @@ jobs:
|
|||||||
|
|
||||||
t_ems_test_ext_colony:
|
t_ems_test_ext_colony:
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/node:10
|
- image: circleci/node:14
|
||||||
environment:
|
environment:
|
||||||
TERM: xterm
|
TERM: xterm
|
||||||
steps:
|
steps:
|
||||||
@ -915,12 +951,14 @@ jobs:
|
|||||||
- run:
|
- run:
|
||||||
name: External ColonyNetworks tests
|
name: External ColonyNetworks tests
|
||||||
command: |
|
command: |
|
||||||
test/externalTests/colony.sh /tmp/workspace/soljson.js || test/externalTests/colony.sh /tmp/workspace/soljson.js
|
test/externalTests/colony.sh /tmp/workspace/soljson.js
|
||||||
- run: *gitter_notify_failure
|
# TODO: Re-enable notifications once this is running nightly rather than as a PR check
|
||||||
- run: *gitter_notify_success
|
#- run: *gitter_notify_failure
|
||||||
|
#- run: *gitter_notify_success
|
||||||
|
|
||||||
t_ems_compile_ext_ens:
|
t_ems_compile_ext_ens:
|
||||||
docker:
|
docker:
|
||||||
|
# NOTE: One of the dependencies (fsevents) fails to build its native extension on node.js 12+.
|
||||||
- image: circleci/node:10
|
- image: circleci/node:10
|
||||||
environment:
|
environment:
|
||||||
TERM: xterm
|
TERM: xterm
|
||||||
@ -938,6 +976,28 @@ jobs:
|
|||||||
export COMPILE_ONLY=1
|
export COMPILE_ONLY=1
|
||||||
test/externalTests/ens.sh /tmp/workspace/soljson.js
|
test/externalTests/ens.sh /tmp/workspace/soljson.js
|
||||||
|
|
||||||
|
t_ems_test_ext_ens:
|
||||||
|
docker:
|
||||||
|
# NOTE: One of the dependencies (fsevents) fails to build its native extension on node.js 12+.
|
||||||
|
- image: circleci/node:10
|
||||||
|
environment:
|
||||||
|
TERM: xterm
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- attach_workspace:
|
||||||
|
at: /tmp/workspace
|
||||||
|
- run:
|
||||||
|
name: Install test dependencies
|
||||||
|
command: |
|
||||||
|
sudo apt-get -qy install lsof
|
||||||
|
- run:
|
||||||
|
name: External Ens compilation
|
||||||
|
command: |
|
||||||
|
test/externalTests/ens.sh /tmp/workspace/soljson.js
|
||||||
|
# TODO: Re-enable notifications once this is running nightly rather than as a PR check
|
||||||
|
#- run: *gitter_notify_failure
|
||||||
|
#- run: *gitter_notify_success
|
||||||
|
|
||||||
b_win: &b_win
|
b_win: &b_win
|
||||||
executor:
|
executor:
|
||||||
name: win/default
|
name: win/default
|
||||||
@ -1121,8 +1181,16 @@ workflows:
|
|||||||
- t_ems_solcjs: *workflow_emscripten
|
- t_ems_solcjs: *workflow_emscripten
|
||||||
- t_ems_compile_ext_colony: *workflow_emscripten
|
- t_ems_compile_ext_colony: *workflow_emscripten
|
||||||
- t_ems_compile_ext_gnosis: *workflow_emscripten
|
- t_ems_compile_ext_gnosis: *workflow_emscripten
|
||||||
|
- t_ems_compile_ext_gnosis_v2: *workflow_emscripten
|
||||||
- t_ems_compile_ext_zeppelin: *workflow_emscripten
|
- t_ems_compile_ext_zeppelin: *workflow_emscripten
|
||||||
- t_ems_compile_ext_ens: *workflow_emscripten
|
- t_ems_compile_ext_ens: *workflow_emscripten
|
||||||
|
- t_ems_test_ext_colony: *workflow_emscripten
|
||||||
|
# FIXME: Gnosis tests are pretty flaky right now. They often fail on CircleCI due to random ProviderError
|
||||||
|
# and there are also other less frequent problems. See https://github.com/gnosis/safe-contracts/issues/216.
|
||||||
|
#- t_ems_test_ext_gnosis: *workflow_emscripten
|
||||||
|
- t_ems_test_ext_gnosis_v2: *workflow_emscripten
|
||||||
|
- t_ems_test_ext_zeppelin: *workflow_emscripten
|
||||||
|
- t_ems_test_ext_ens: *workflow_emscripten
|
||||||
|
|
||||||
# Windows build and tests
|
# Windows build and tests
|
||||||
- b_win: *workflow_trigger_on_tags
|
- b_win: *workflow_trigger_on_tags
|
||||||
|
@ -53,6 +53,7 @@ Bugfixes:
|
|||||||
* SMTChecker: Fix internal compiler error when doing bitwise compound assignment with string literals.
|
* SMTChecker: Fix internal compiler error when doing bitwise compound assignment with string literals.
|
||||||
* SMTChecker: Fix internal error when trying to generate counterexamples with old z3.
|
* SMTChecker: Fix internal error when trying to generate counterexamples with old z3.
|
||||||
* SMTChecker: Fix segmentation fault that could occur on certain SMT-enabled sources when no SMT solver was available.
|
* SMTChecker: Fix segmentation fault that could occur on certain SMT-enabled sources when no SMT solver was available.
|
||||||
|
* Type Checker: ``super`` is not available in libraries.
|
||||||
* Yul Optimizer: Fix a bug in NameSimplifier where a new name created by NameSimplifier could also be created by NameDispenser.
|
* Yul Optimizer: Fix a bug in NameSimplifier where a new name created by NameSimplifier could also be created by NameDispenser.
|
||||||
* Yul Optimizer: Removed NameSimplifier from optimization steps available to users.
|
* Yul Optimizer: Removed NameSimplifier from optimization steps available to users.
|
||||||
|
|
||||||
|
@ -52,6 +52,13 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA
|
|||||||
add_compile_options(-Wimplicit-fallthrough)
|
add_compile_options(-Wimplicit-fallthrough)
|
||||||
add_compile_options(-Wsign-conversion)
|
add_compile_options(-Wsign-conversion)
|
||||||
|
|
||||||
|
# While this should work on CMake 3.3+, it fails on Ubuntu 18
|
||||||
|
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.16)
|
||||||
|
eth_add_cxx_compiler_flag_if_supported(
|
||||||
|
$<$<COMPILE_LANGUAGE:CXX>:-Wextra-semi>
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Configuration-specific compiler settings.
|
# Configuration-specific compiler settings.
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3 -DETH_DEBUG")
|
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3 -DETH_DEBUG")
|
||||||
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
|
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
|
||||||
|
@ -76,7 +76,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
VariableDeclaration const& declaration() const { return m_declaration; }
|
VariableDeclaration const& declaration() const { return m_declaration; }
|
||||||
Kind kind() const { return m_occurrenceKind; };
|
Kind kind() const { return m_occurrenceKind; }
|
||||||
std::optional<langutil::SourceLocation> const& occurrence() const { return m_occurrence; }
|
std::optional<langutil::SourceLocation> const& occurrence() const { return m_occurrence; }
|
||||||
private:
|
private:
|
||||||
/// Declaration of the occurring variable.
|
/// Declaration of the occurring variable.
|
||||||
|
@ -285,7 +285,8 @@ bool NameAndTypeResolver::resolveNamesAndTypesInternal(ASTNode& _node, bool _res
|
|||||||
solAssert(_resolveInsideCode, "");
|
solAssert(_resolveInsideCode, "");
|
||||||
|
|
||||||
m_globalContext.setCurrentContract(*contract);
|
m_globalContext.setCurrentContract(*contract);
|
||||||
updateDeclaration(*m_globalContext.currentSuper());
|
if (!contract->isLibrary())
|
||||||
|
updateDeclaration(*m_globalContext.currentSuper());
|
||||||
updateDeclaration(*m_globalContext.currentThis());
|
updateDeclaration(*m_globalContext.currentThis());
|
||||||
|
|
||||||
for (ASTPointer<InheritanceSpecifier> const& baseContract: contract->baseContracts())
|
for (ASTPointer<InheritanceSpecifier> const& baseContract: contract->baseContracts())
|
||||||
|
@ -219,23 +219,18 @@ string ABIFunctions::tupleDecoder(TypePointers const& _types, bool _fromMemory)
|
|||||||
valueReturnParams.emplace_back("value" + to_string(stackPos));
|
valueReturnParams.emplace_back("value" + to_string(stackPos));
|
||||||
stackPos++;
|
stackPos++;
|
||||||
}
|
}
|
||||||
bool dynamic = decodingTypes[i]->isDynamicallyEncoded();
|
Whiskers elementTempl(R"(
|
||||||
Whiskers elementTempl(
|
|
||||||
dynamic ?
|
|
||||||
R"(
|
|
||||||
{
|
{
|
||||||
let offset := <load>(add(headStart, <pos>))
|
<?dynamic>
|
||||||
if gt(offset, 0xffffffffffffffff) { <revertString> }
|
let offset := <load>(add(headStart, <pos>))
|
||||||
|
if gt(offset, 0xffffffffffffffff) { <revertString> }
|
||||||
|
<!dynamic>
|
||||||
|
let offset := <pos>
|
||||||
|
</dynamic>
|
||||||
<values> := <abiDecode>(add(headStart, offset), dataEnd)
|
<values> := <abiDecode>(add(headStart, offset), dataEnd)
|
||||||
}
|
}
|
||||||
)" :
|
)");
|
||||||
R"(
|
elementTempl("dynamic", decodingTypes[i]->isDynamicallyEncoded());
|
||||||
{
|
|
||||||
let offset := <pos>
|
|
||||||
<values> := <abiDecode>(add(headStart, offset), dataEnd)
|
|
||||||
}
|
|
||||||
)"
|
|
||||||
);
|
|
||||||
// TODO add test
|
// TODO add test
|
||||||
elementTempl("revertString", revertReasonIfDebug("ABI decoding: invalid tuple offset"));
|
elementTempl("revertString", revertReasonIfDebug("ABI decoding: invalid tuple offset"));
|
||||||
elementTempl("load", _fromMemory ? "mload" : "calldataload");
|
elementTempl("load", _fromMemory ? "mload" : "calldataload");
|
||||||
@ -1356,19 +1351,16 @@ string ABIFunctions::abiDecodingFunctionStruct(StructType const& _type, bool _fr
|
|||||||
solAssert(!member.type->containsNestedMapping(), "");
|
solAssert(!member.type->containsNestedMapping(), "");
|
||||||
auto decodingType = member.type->decodingType();
|
auto decodingType = member.type->decodingType();
|
||||||
solAssert(decodingType, "");
|
solAssert(decodingType, "");
|
||||||
bool dynamic = decodingType->isDynamicallyEncoded();
|
Whiskers memberTempl(R"(
|
||||||
Whiskers memberTempl(
|
<?dynamic>
|
||||||
dynamic ?
|
|
||||||
R"(
|
|
||||||
let offset := <load>(add(headStart, <pos>))
|
let offset := <load>(add(headStart, <pos>))
|
||||||
if gt(offset, 0xffffffffffffffff) { <revertString> }
|
if gt(offset, 0xffffffffffffffff) { <revertString> }
|
||||||
mstore(add(value, <memoryOffset>), <abiDecode>(add(headStart, offset), end))
|
<!dynamic>
|
||||||
)" :
|
|
||||||
R"(
|
|
||||||
let offset := <pos>
|
let offset := <pos>
|
||||||
mstore(add(value, <memoryOffset>), <abiDecode>(add(headStart, offset), end))
|
</dynamic>
|
||||||
)"
|
mstore(add(value, <memoryOffset>), <abiDecode>(add(headStart, offset), end))
|
||||||
);
|
)");
|
||||||
|
memberTempl("dynamic", decodingType->isDynamicallyEncoded());
|
||||||
// TODO add test
|
// TODO add test
|
||||||
memberTempl("revertString", revertReasonIfDebug("ABI decoding: invalid struct offset"));
|
memberTempl("revertString", revertReasonIfDebug("ABI decoding: invalid struct offset"));
|
||||||
memberTempl("load", _fromMemory ? "mload" : "calldataload");
|
memberTempl("load", _fromMemory ? "mload" : "calldataload");
|
||||||
|
@ -135,7 +135,7 @@ public:
|
|||||||
/// @returns a new copy of the utility function generator (but using the same function set).
|
/// @returns a new copy of the utility function generator (but using the same function set).
|
||||||
YulUtilFunctions utils();
|
YulUtilFunctions utils();
|
||||||
|
|
||||||
langutil::EVMVersion evmVersion() const { return m_evmVersion; };
|
langutil::EVMVersion evmVersion() const { return m_evmVersion; }
|
||||||
|
|
||||||
void setArithmetic(Arithmetic _value) { m_arithmetic = _value; }
|
void setArithmetic(Arithmetic _value) { m_arithmetic = _value; }
|
||||||
Arithmetic arithmetic() const { return m_arithmetic; }
|
Arithmetic arithmetic() const { return m_arithmetic; }
|
||||||
|
@ -1462,7 +1462,7 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall)
|
|||||||
solAssert(!functionType->gasSet(), "");
|
solAssert(!functionType->gasSet(), "");
|
||||||
solAssert(!functionType->bound(), "");
|
solAssert(!functionType->bound(), "");
|
||||||
|
|
||||||
static map<FunctionType::Kind, std::tuple<u160, size_t>> precompiles = {
|
static map<FunctionType::Kind, std::tuple<unsigned, size_t>> precompiles = {
|
||||||
{FunctionType::Kind::ECRecover, std::make_tuple(1, 0)},
|
{FunctionType::Kind::ECRecover, std::make_tuple(1, 0)},
|
||||||
{FunctionType::Kind::SHA256, std::make_tuple(2, 0)},
|
{FunctionType::Kind::SHA256, std::make_tuple(2, 0)},
|
||||||
{FunctionType::Kind::RIPEMD160, std::make_tuple(3, 12)},
|
{FunctionType::Kind::RIPEMD160, std::make_tuple(3, 12)},
|
||||||
|
@ -84,7 +84,7 @@ public:
|
|||||||
return Step::invalidInCurrentEnvironment();
|
return Step::invalidInCurrentEnvironment();
|
||||||
else
|
else
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ struct CommonOptions: boost::noncopyable
|
|||||||
static void setSingleton(std::unique_ptr<CommonOptions const>&& _instance);
|
static void setSingleton(std::unique_ptr<CommonOptions const>&& _instance);
|
||||||
|
|
||||||
CommonOptions(std::string caption = "");
|
CommonOptions(std::string caption = "");
|
||||||
virtual ~CommonOptions() {};
|
virtual ~CommonOptions() {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
boost::program_options::options_description options;
|
boost::program_options::options_description options;
|
||||||
|
@ -209,7 +209,7 @@ evmc::result EVMHost::call(evmc_message const& _message) noexcept
|
|||||||
{
|
{
|
||||||
// TODO this is not the right formula
|
// TODO this is not the right formula
|
||||||
// TODO is the nonce incremented on failure, too?
|
// TODO is the nonce incremented on failure, too?
|
||||||
Address createAddress(keccak256(
|
h160 createAddress(keccak256(
|
||||||
bytes(begin(message.sender.bytes), end(message.sender.bytes)) +
|
bytes(begin(message.sender.bytes), end(message.sender.bytes)) +
|
||||||
asBytes(to_string(sender.nonce++))
|
asBytes(to_string(sender.nonce++))
|
||||||
));
|
));
|
||||||
@ -218,7 +218,7 @@ evmc::result EVMHost::call(evmc_message const& _message) noexcept
|
|||||||
}
|
}
|
||||||
else if (message.kind == EVMC_CREATE2)
|
else if (message.kind == EVMC_CREATE2)
|
||||||
{
|
{
|
||||||
Address createAddress(keccak256(
|
h160 createAddress(keccak256(
|
||||||
bytes(1, 0xff) +
|
bytes(1, 0xff) +
|
||||||
bytes(begin(message.sender.bytes), end(message.sender.bytes)) +
|
bytes(begin(message.sender.bytes), end(message.sender.bytes)) +
|
||||||
bytes(begin(message.create2_salt.bytes), end(message.create2_salt.bytes)) +
|
bytes(begin(message.create2_salt.bytes), end(message.create2_salt.bytes)) +
|
||||||
@ -292,12 +292,12 @@ evmc::bytes32 EVMHost::get_block_hash(int64_t _number) const noexcept
|
|||||||
return convertToEVMC(u256("0x3737373737373737373737373737373737373737373737373737373737373737") + _number);
|
return convertToEVMC(u256("0x3737373737373737373737373737373737373737373737373737373737373737") + _number);
|
||||||
}
|
}
|
||||||
|
|
||||||
Address EVMHost::convertFromEVMC(evmc::address const& _addr)
|
h160 EVMHost::convertFromEVMC(evmc::address const& _addr)
|
||||||
{
|
{
|
||||||
return Address(bytes(begin(_addr.bytes), end(_addr.bytes)));
|
return h160(bytes(begin(_addr.bytes), end(_addr.bytes)));
|
||||||
}
|
}
|
||||||
|
|
||||||
evmc::address EVMHost::convertToEVMC(Address const& _addr)
|
evmc::address EVMHost::convertToEVMC(h160 const& _addr)
|
||||||
{
|
{
|
||||||
evmc::address a;
|
evmc::address a;
|
||||||
for (size_t i = 0; i < 20; ++i)
|
for (size_t i = 0; i < 20; ++i)
|
||||||
|
@ -169,7 +169,7 @@ void ExecutionFramework::sendMessage(bytes const& _data, bool _isCreation, u256
|
|||||||
if (_isCreation)
|
if (_isCreation)
|
||||||
{
|
{
|
||||||
message.kind = EVMC_CREATE;
|
message.kind = EVMC_CREATE;
|
||||||
message.destination = EVMHost::convertToEVMC(Address{});
|
message.destination = EVMHost::convertToEVMC(h160{});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -195,7 +195,7 @@ void ExecutionFramework::sendMessage(bytes const& _data, bool _isCreation, u256
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExecutionFramework::sendEther(Address const& _addr, u256 const& _amount)
|
void ExecutionFramework::sendEther(h160 const& _addr, u256 const& _amount)
|
||||||
{
|
{
|
||||||
m_evmcHost->newBlock();
|
m_evmcHost->newBlock();
|
||||||
|
|
||||||
@ -228,12 +228,12 @@ size_t ExecutionFramework::blockTimestamp(u256 _block)
|
|||||||
return static_cast<size_t>((currentTimestamp() / blockNumber()) * _block);
|
return static_cast<size_t>((currentTimestamp() / blockNumber()) * _block);
|
||||||
}
|
}
|
||||||
|
|
||||||
Address ExecutionFramework::account(size_t _idx)
|
h160 ExecutionFramework::account(size_t _idx)
|
||||||
{
|
{
|
||||||
return Address(h256(u256{"0x1212121212121212121212121212120000000012"} + _idx * 0x1000), Address::AlignRight);
|
return h160(h256(u256{"0x1212121212121212121212121212120000000012"} + _idx * 0x1000), h160::AlignRight);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ExecutionFramework::addressHasCode(Address const& _addr)
|
bool ExecutionFramework::addressHasCode(h160 const& _addr)
|
||||||
{
|
{
|
||||||
return m_evmcHost->get_code_size(EVMHost::convertToEVMC(_addr)) != 0;
|
return m_evmcHost->get_code_size(EVMHost::convertToEVMC(_addr)) != 0;
|
||||||
}
|
}
|
||||||
@ -253,7 +253,7 @@ h256 ExecutionFramework::logTopic(size_t _logIdx, size_t _topicIdx) const
|
|||||||
return EVMHost::convertFromEVMC(m_evmcHost->recorded_logs.at(_logIdx).topics.at(_topicIdx));
|
return EVMHost::convertFromEVMC(m_evmcHost->recorded_logs.at(_logIdx).topics.at(_topicIdx));
|
||||||
}
|
}
|
||||||
|
|
||||||
Address ExecutionFramework::logAddress(size_t _logIdx) const
|
h160 ExecutionFramework::logAddress(size_t _logIdx) const
|
||||||
{
|
{
|
||||||
return EVMHost::convertFromEVMC(m_evmcHost->recorded_logs.at(_logIdx).creator);
|
return EVMHost::convertFromEVMC(m_evmcHost->recorded_logs.at(_logIdx).creator);
|
||||||
}
|
}
|
||||||
@ -266,12 +266,12 @@ bytes ExecutionFramework::logData(size_t _logIdx) const
|
|||||||
return {data.begin(), data.end()};
|
return {data.begin(), data.end()};
|
||||||
}
|
}
|
||||||
|
|
||||||
u256 ExecutionFramework::balanceAt(Address const& _addr)
|
u256 ExecutionFramework::balanceAt(h160 const& _addr)
|
||||||
{
|
{
|
||||||
return u256(EVMHost::convertFromEVMC(m_evmcHost->get_balance(EVMHost::convertToEVMC(_addr))));
|
return u256(EVMHost::convertFromEVMC(m_evmcHost->get_balance(EVMHost::convertToEVMC(_addr))));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ExecutionFramework::storageEmpty(Address const& _addr)
|
bool ExecutionFramework::storageEmpty(h160 const& _addr)
|
||||||
{
|
{
|
||||||
const auto it = m_evmcHost->accounts.find(EVMHost::convertToEVMC(_addr));
|
const auto it = m_evmcHost->accounts.find(EVMHost::convertToEVMC(_addr));
|
||||||
if (it != m_evmcHost->accounts.end())
|
if (it != m_evmcHost->accounts.end())
|
||||||
|
@ -42,9 +42,6 @@
|
|||||||
namespace solidity::test
|
namespace solidity::test
|
||||||
{
|
{
|
||||||
using rational = boost::rational<bigint>;
|
using rational = boost::rational<bigint>;
|
||||||
/// An Ethereum address: 20 bytes.
|
|
||||||
/// @NOTE This is not endian-specific; it's just a bunch of bytes.
|
|
||||||
using Address = util::h160;
|
|
||||||
|
|
||||||
// The ether and gwei denominations; here for ease of use where needed within code.
|
// The ether and gwei denominations; here for ease of use where needed within code.
|
||||||
static const u256 gwei = u256(1) << 9;
|
static const u256 gwei = u256(1) << 9;
|
||||||
@ -63,7 +60,7 @@ public:
|
|||||||
u256 const& _value = 0,
|
u256 const& _value = 0,
|
||||||
std::string const& _contractName = "",
|
std::string const& _contractName = "",
|
||||||
bytes const& _arguments = {},
|
bytes const& _arguments = {},
|
||||||
std::map<std::string, Address> const& _libraryAddresses = {}
|
std::map<std::string, util::h160> const& _libraryAddresses = {}
|
||||||
) = 0;
|
) = 0;
|
||||||
|
|
||||||
bytes const& compileAndRun(
|
bytes const& compileAndRun(
|
||||||
@ -71,7 +68,7 @@ public:
|
|||||||
u256 const& _value = 0,
|
u256 const& _value = 0,
|
||||||
std::string const& _contractName = "",
|
std::string const& _contractName = "",
|
||||||
bytes const& _arguments = {},
|
bytes const& _arguments = {},
|
||||||
std::map<std::string, Address> const& _libraryAddresses = {}
|
std::map<std::string, util::h160> const& _libraryAddresses = {}
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
compileAndRunWithoutCheck(
|
compileAndRunWithoutCheck(
|
||||||
@ -177,6 +174,7 @@ public:
|
|||||||
return encode(u256((value.numerator() << fractionalBits) / value.denominator()));
|
return encode(u256((value.numerator() << fractionalBits) / value.denominator()));
|
||||||
}
|
}
|
||||||
static bytes encode(util::h256 const& _value) { return _value.asBytes(); }
|
static bytes encode(util::h256 const& _value) { return _value.asBytes(); }
|
||||||
|
static bytes encode(util::h160 const& _value) { return encode(util::h256(_value, util::h256::AlignRight)); }
|
||||||
static bytes encode(bytes const& _value, bool _padLeft = true)
|
static bytes encode(bytes const& _value, bool _padLeft = true)
|
||||||
{
|
{
|
||||||
bytes padding = bytes((32 - _value.size() % 32) % 32, 0);
|
bytes padding = bytes((32 - _value.size() % 32) % 32, 0);
|
||||||
@ -262,21 +260,21 @@ protected:
|
|||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
void sendMessage(bytes const& _data, bool _isCreation, u256 const& _value = 0);
|
void sendMessage(bytes const& _data, bool _isCreation, u256 const& _value = 0);
|
||||||
void sendEther(Address const& _to, u256 const& _value);
|
void sendEther(util::h160 const& _to, u256 const& _value);
|
||||||
size_t currentTimestamp();
|
size_t currentTimestamp();
|
||||||
size_t blockTimestamp(u256 _number);
|
size_t blockTimestamp(u256 _number);
|
||||||
|
|
||||||
/// @returns the (potentially newly created) _ith address.
|
/// @returns the (potentially newly created) _ith address.
|
||||||
Address account(size_t _i);
|
util::h160 account(size_t _i);
|
||||||
|
|
||||||
u256 balanceAt(Address const& _addr);
|
u256 balanceAt(util::h160 const& _addr);
|
||||||
bool storageEmpty(Address const& _addr);
|
bool storageEmpty(util::h160 const& _addr);
|
||||||
bool addressHasCode(Address const& _addr);
|
bool addressHasCode(util::h160 const& _addr);
|
||||||
|
|
||||||
size_t numLogs() const;
|
size_t numLogs() const;
|
||||||
size_t numLogTopics(size_t _logIdx) const;
|
size_t numLogTopics(size_t _logIdx) const;
|
||||||
util::h256 logTopic(size_t _logIdx, size_t _topicIdx) const;
|
util::h256 logTopic(size_t _logIdx, size_t _topicIdx) const;
|
||||||
Address logAddress(size_t _logIdx) const;
|
util::h160 logAddress(size_t _logIdx) const;
|
||||||
bytes logData(size_t _logIdx) const;
|
bytes logData(size_t _logIdx) const;
|
||||||
|
|
||||||
langutil::EVMVersion m_evmVersion;
|
langutil::EVMVersion m_evmVersion;
|
||||||
@ -289,8 +287,8 @@ protected:
|
|||||||
std::vector<boost::filesystem::path> m_vmPaths;
|
std::vector<boost::filesystem::path> m_vmPaths;
|
||||||
|
|
||||||
bool m_transactionSuccessful = true;
|
bool m_transactionSuccessful = true;
|
||||||
Address m_sender = account(0);
|
util::h160 m_sender = account(0);
|
||||||
Address m_contractAddress;
|
util::h160 m_contractAddress;
|
||||||
u256 const m_gasPrice = 10 * gwei;
|
u256 const m_gasPrice = 10 * gwei;
|
||||||
u256 const m_gas = 100000000;
|
u256 const m_gas = 100000000;
|
||||||
bytes m_output;
|
bytes m_output;
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
"ast":
|
"ast":
|
||||||
{
|
{
|
||||||
"nodeType": "YulBlock",
|
"nodeType": "YulBlock",
|
||||||
"src": "0:823:1",
|
"src": "0:825:1",
|
||||||
"statements":
|
"statements":
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
@ -406,7 +406,7 @@
|
|||||||
"body":
|
"body":
|
||||||
{
|
{
|
||||||
"nodeType": "YulBlock",
|
"nodeType": "YulBlock",
|
||||||
"src": "498:322:1",
|
"src": "498:324:1",
|
||||||
"statements":
|
"statements":
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
@ -499,12 +499,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"nodeType": "YulBlock",
|
"nodeType": "YulBlock",
|
||||||
"src": "570:243:1",
|
"src": "570:245:1",
|
||||||
"statements":
|
"statements":
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"nodeType": "YulVariableDeclaration",
|
"nodeType": "YulVariableDeclaration",
|
||||||
"src": "584:45:1",
|
"src": "585:45:1",
|
||||||
"value":
|
"value":
|
||||||
{
|
{
|
||||||
"arguments":
|
"arguments":
|
||||||
@ -515,12 +515,12 @@
|
|||||||
{
|
{
|
||||||
"name": "headStart",
|
"name": "headStart",
|
||||||
"nodeType": "YulIdentifier",
|
"nodeType": "YulIdentifier",
|
||||||
"src": "615:9:1"
|
"src": "616:9:1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"kind": "number",
|
"kind": "number",
|
||||||
"nodeType": "YulLiteral",
|
"nodeType": "YulLiteral",
|
||||||
"src": "626:1:1",
|
"src": "627:1:1",
|
||||||
"type": "",
|
"type": "",
|
||||||
"value": "0"
|
"value": "0"
|
||||||
}
|
}
|
||||||
@ -529,27 +529,27 @@
|
|||||||
{
|
{
|
||||||
"name": "add",
|
"name": "add",
|
||||||
"nodeType": "YulIdentifier",
|
"nodeType": "YulIdentifier",
|
||||||
"src": "611:3:1"
|
"src": "612:3:1"
|
||||||
},
|
},
|
||||||
"nodeType": "YulFunctionCall",
|
"nodeType": "YulFunctionCall",
|
||||||
"src": "611:17:1"
|
"src": "612:17:1"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"functionName":
|
"functionName":
|
||||||
{
|
{
|
||||||
"name": "calldataload",
|
"name": "calldataload",
|
||||||
"nodeType": "YulIdentifier",
|
"nodeType": "YulIdentifier",
|
||||||
"src": "598:12:1"
|
"src": "599:12:1"
|
||||||
},
|
},
|
||||||
"nodeType": "YulFunctionCall",
|
"nodeType": "YulFunctionCall",
|
||||||
"src": "598:31:1"
|
"src": "599:31:1"
|
||||||
},
|
},
|
||||||
"variables":
|
"variables":
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": "offset",
|
"name": "offset",
|
||||||
"nodeType": "YulTypedName",
|
"nodeType": "YulTypedName",
|
||||||
"src": "588:6:1",
|
"src": "589:6:1",
|
||||||
"type": ""
|
"type": ""
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -558,7 +558,7 @@
|
|||||||
"body":
|
"body":
|
||||||
{
|
{
|
||||||
"nodeType": "YulBlock",
|
"nodeType": "YulBlock",
|
||||||
"src": "676:16:1",
|
"src": "677:16:1",
|
||||||
"statements":
|
"statements":
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
@ -569,14 +569,14 @@
|
|||||||
{
|
{
|
||||||
"kind": "number",
|
"kind": "number",
|
||||||
"nodeType": "YulLiteral",
|
"nodeType": "YulLiteral",
|
||||||
"src": "685:1:1",
|
"src": "686:1:1",
|
||||||
"type": "",
|
"type": "",
|
||||||
"value": "0"
|
"value": "0"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"kind": "number",
|
"kind": "number",
|
||||||
"nodeType": "YulLiteral",
|
"nodeType": "YulLiteral",
|
||||||
"src": "688:1:1",
|
"src": "689:1:1",
|
||||||
"type": "",
|
"type": "",
|
||||||
"value": "0"
|
"value": "0"
|
||||||
}
|
}
|
||||||
@ -585,13 +585,13 @@
|
|||||||
{
|
{
|
||||||
"name": "revert",
|
"name": "revert",
|
||||||
"nodeType": "YulIdentifier",
|
"nodeType": "YulIdentifier",
|
||||||
"src": "678:6:1"
|
"src": "679:6:1"
|
||||||
},
|
},
|
||||||
"nodeType": "YulFunctionCall",
|
"nodeType": "YulFunctionCall",
|
||||||
"src": "678:12:1"
|
"src": "679:12:1"
|
||||||
},
|
},
|
||||||
"nodeType": "YulExpressionStatement",
|
"nodeType": "YulExpressionStatement",
|
||||||
"src": "678:12:1"
|
"src": "679:12:1"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -602,12 +602,12 @@
|
|||||||
{
|
{
|
||||||
"name": "offset",
|
"name": "offset",
|
||||||
"nodeType": "YulIdentifier",
|
"nodeType": "YulIdentifier",
|
||||||
"src": "648:6:1"
|
"src": "649:6:1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"kind": "number",
|
"kind": "number",
|
||||||
"nodeType": "YulLiteral",
|
"nodeType": "YulLiteral",
|
||||||
"src": "656:18:1",
|
"src": "657:18:1",
|
||||||
"type": "",
|
"type": "",
|
||||||
"value": "0xffffffffffffffff"
|
"value": "0xffffffffffffffff"
|
||||||
}
|
}
|
||||||
@ -616,17 +616,17 @@
|
|||||||
{
|
{
|
||||||
"name": "gt",
|
"name": "gt",
|
||||||
"nodeType": "YulIdentifier",
|
"nodeType": "YulIdentifier",
|
||||||
"src": "645:2:1"
|
"src": "646:2:1"
|
||||||
},
|
},
|
||||||
"nodeType": "YulFunctionCall",
|
"nodeType": "YulFunctionCall",
|
||||||
"src": "645:30:1"
|
"src": "646:30:1"
|
||||||
},
|
},
|
||||||
"nodeType": "YulIf",
|
"nodeType": "YulIf",
|
||||||
"src": "642:2:1"
|
"src": "643:2:1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"nodeType": "YulAssignment",
|
"nodeType": "YulAssignment",
|
||||||
"src": "705:98:1",
|
"src": "707:98:1",
|
||||||
"value":
|
"value":
|
||||||
{
|
{
|
||||||
"arguments":
|
"arguments":
|
||||||
@ -637,49 +637,49 @@
|
|||||||
{
|
{
|
||||||
"name": "headStart",
|
"name": "headStart",
|
||||||
"nodeType": "YulIdentifier",
|
"nodeType": "YulIdentifier",
|
||||||
"src": "775:9:1"
|
"src": "777:9:1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "offset",
|
"name": "offset",
|
||||||
"nodeType": "YulIdentifier",
|
"nodeType": "YulIdentifier",
|
||||||
"src": "786:6:1"
|
"src": "788:6:1"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"functionName":
|
"functionName":
|
||||||
{
|
{
|
||||||
"name": "add",
|
"name": "add",
|
||||||
"nodeType": "YulIdentifier",
|
"nodeType": "YulIdentifier",
|
||||||
"src": "771:3:1"
|
"src": "773:3:1"
|
||||||
},
|
},
|
||||||
"nodeType": "YulFunctionCall",
|
"nodeType": "YulFunctionCall",
|
||||||
"src": "771:22:1"
|
"src": "773:22:1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "dataEnd",
|
"name": "dataEnd",
|
||||||
"nodeType": "YulIdentifier",
|
"nodeType": "YulIdentifier",
|
||||||
"src": "795:7:1"
|
"src": "797:7:1"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"functionName":
|
"functionName":
|
||||||
{
|
{
|
||||||
"name": "abi_decode_t_array$_t_uint256_$dyn_calldata_ptr",
|
"name": "abi_decode_t_array$_t_uint256_$dyn_calldata_ptr",
|
||||||
"nodeType": "YulIdentifier",
|
"nodeType": "YulIdentifier",
|
||||||
"src": "723:47:1"
|
"src": "725:47:1"
|
||||||
},
|
},
|
||||||
"nodeType": "YulFunctionCall",
|
"nodeType": "YulFunctionCall",
|
||||||
"src": "723:80:1"
|
"src": "725:80:1"
|
||||||
},
|
},
|
||||||
"variableNames":
|
"variableNames":
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": "value0",
|
"name": "value0",
|
||||||
"nodeType": "YulIdentifier",
|
"nodeType": "YulIdentifier",
|
||||||
"src": "705:6:1"
|
"src": "707:6:1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "value1",
|
"name": "value1",
|
||||||
"nodeType": "YulIdentifier",
|
"nodeType": "YulIdentifier",
|
||||||
"src": "713:6:1"
|
"src": "715:6:1"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -719,11 +719,11 @@
|
|||||||
"type": ""
|
"type": ""
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"src": "397:423:1"
|
"src": "397:425:1"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"contents": "{\n\n // uint256[]\n function abi_decode_t_array$_t_uint256_$dyn_calldata_ptr(offset, end) -> arrayPos, length {\n if iszero(slt(add(offset, 0x1f), end)) { revert(0, 0) }\n length := calldataload(offset)\n if gt(length, 0xffffffffffffffff) { revert(0, 0) }\n arrayPos := add(offset, 0x20)\n if gt(add(arrayPos, mul(length, 0x20)), end) { revert(0, 0) }\n }\n\n function abi_decode_tuple_t_array$_t_uint256_$dyn_calldata_ptr(headStart, dataEnd) -> value0, value1 {\n if slt(sub(dataEnd, headStart), 32) { revert(0, 0) }\n\n {\n let offset := calldataload(add(headStart, 0))\n if gt(offset, 0xffffffffffffffff) { revert(0, 0) }\n value0, value1 := abi_decode_t_array$_t_uint256_$dyn_calldata_ptr(add(headStart, offset), dataEnd)\n }\n\n }\n\n}\n",
|
"contents": "{\n\n // uint256[]\n function abi_decode_t_array$_t_uint256_$dyn_calldata_ptr(offset, end) -> arrayPos, length {\n if iszero(slt(add(offset, 0x1f), end)) { revert(0, 0) }\n length := calldataload(offset)\n if gt(length, 0xffffffffffffffff) { revert(0, 0) }\n arrayPos := add(offset, 0x20)\n if gt(add(arrayPos, mul(length, 0x20)), end) { revert(0, 0) }\n }\n\n function abi_decode_tuple_t_array$_t_uint256_$dyn_calldata_ptr(headStart, dataEnd) -> value0, value1 {\n if slt(sub(dataEnd, headStart), 32) { revert(0, 0) }\n\n {\n\n let offset := calldataload(add(headStart, 0))\n if gt(offset, 0xffffffffffffffff) { revert(0, 0) }\n\n value0, value1 := abi_decode_t_array$_t_uint256_$dyn_calldata_ptr(add(headStart, offset), dataEnd)\n }\n\n }\n\n}\n",
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"language": "Yul",
|
"language": "Yul",
|
||||||
"name": "#utility.yul"
|
"name": "#utility.yul"
|
||||||
|
@ -57,22 +57,30 @@ object "C_80" {
|
|||||||
if slt(sub(dataEnd, headStart), 128) { revert(0, 0) }
|
if slt(sub(dataEnd, headStart), 128) { revert(0, 0) }
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
let offset := 0
|
let offset := 0
|
||||||
|
|
||||||
value0 := abi_decode_t_uint256(add(headStart, offset), dataEnd)
|
value0 := abi_decode_t_uint256(add(headStart, offset), dataEnd)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
let offset := 32
|
let offset := 32
|
||||||
|
|
||||||
value1 := abi_decode_t_uint256(add(headStart, offset), dataEnd)
|
value1 := abi_decode_t_uint256(add(headStart, offset), dataEnd)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
let offset := 64
|
let offset := 64
|
||||||
|
|
||||||
value2 := abi_decode_t_uint256(add(headStart, offset), dataEnd)
|
value2 := abi_decode_t_uint256(add(headStart, offset), dataEnd)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
let offset := 96
|
let offset := 96
|
||||||
|
|
||||||
value3 := abi_decode_t_uint256(add(headStart, offset), dataEnd)
|
value3 := abi_decode_t_uint256(add(headStart, offset), dataEnd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
@ -239,27 +239,27 @@ protected:
|
|||||||
{
|
{
|
||||||
callString("reserve", _name);
|
callString("reserve", _name);
|
||||||
}
|
}
|
||||||
u160 owner(string const& _name)
|
h160 owner(string const& _name)
|
||||||
{
|
{
|
||||||
return callStringReturnsAddress("owner", _name);
|
return callStringReturnsAddress("owner", _name);
|
||||||
}
|
}
|
||||||
void setAddress(string const& _name, u160 const& _address, bool _primary)
|
void setAddress(string const& _name, h160 const& _address, bool _primary)
|
||||||
{
|
{
|
||||||
callStringAddressBool("setAddress", _name, _address, _primary);
|
callStringAddressBool("setAddress", _name, _address, _primary);
|
||||||
}
|
}
|
||||||
u160 addr(string const& _name)
|
h160 addr(string const& _name)
|
||||||
{
|
{
|
||||||
return callStringReturnsAddress("addr", _name);
|
return callStringReturnsAddress("addr", _name);
|
||||||
}
|
}
|
||||||
string name(u160 const& _addr)
|
string name(h160 const& _addr)
|
||||||
{
|
{
|
||||||
return callAddressReturnsString("name", _addr);
|
return callAddressReturnsString("name", _addr);
|
||||||
}
|
}
|
||||||
void setSubRegistrar(string const& _name, u160 const& _address)
|
void setSubRegistrar(string const& _name, h160 const& _address)
|
||||||
{
|
{
|
||||||
callStringAddress("setSubRegistrar", _name, _address);
|
callStringAddress("setSubRegistrar", _name, _address);
|
||||||
}
|
}
|
||||||
u160 subRegistrar(string const& _name)
|
h160 subRegistrar(string const& _name)
|
||||||
{
|
{
|
||||||
return callStringReturnsAddress("subRegistrar", _name);
|
return callStringReturnsAddress("subRegistrar", _name);
|
||||||
}
|
}
|
||||||
@ -271,7 +271,7 @@ protected:
|
|||||||
{
|
{
|
||||||
return callStringReturnsBytes32("content", _name);
|
return callStringReturnsBytes32("content", _name);
|
||||||
}
|
}
|
||||||
void transfer(string const& _name, u160 const& _target)
|
void transfer(string const& _name, h160 const& _target)
|
||||||
{
|
{
|
||||||
return callStringAddress("transfer", _name, _target);
|
return callStringAddress("transfer", _name, _target);
|
||||||
}
|
}
|
||||||
@ -304,12 +304,12 @@ BOOST_AUTO_TEST_CASE(reserve)
|
|||||||
|
|
||||||
// should not work
|
// should not work
|
||||||
registrar.reserve("");
|
registrar.reserve("");
|
||||||
BOOST_CHECK_EQUAL(registrar.owner(""), u160(0));
|
BOOST_CHECK_EQUAL(registrar.owner(""), h160{});
|
||||||
|
|
||||||
for (auto const& name: names)
|
for (auto const& name: names)
|
||||||
{
|
{
|
||||||
registrar.reserve(name);
|
registrar.reserve(name);
|
||||||
BOOST_CHECK_EQUAL(registrar.owner(name), u160(m_sender));
|
BOOST_CHECK_EQUAL(registrar.owner(name), m_sender);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,20 +346,20 @@ BOOST_AUTO_TEST_CASE(properties)
|
|||||||
// setting by sender works
|
// setting by sender works
|
||||||
registrar.reserve(name);
|
registrar.reserve(name);
|
||||||
BOOST_CHECK_EQUAL(registrar.owner(name), sender);
|
BOOST_CHECK_EQUAL(registrar.owner(name), sender);
|
||||||
registrar.setAddress(name, addr, true);
|
registrar.setAddress(name, h160(addr), true);
|
||||||
BOOST_CHECK_EQUAL(registrar.addr(name), u160(addr));
|
BOOST_CHECK_EQUAL(registrar.addr(name), h160(addr));
|
||||||
registrar.setSubRegistrar(name, addr + 20);
|
registrar.setSubRegistrar(name, h160(addr + 20));
|
||||||
BOOST_CHECK_EQUAL(registrar.subRegistrar(name), u160(addr + 20));
|
BOOST_CHECK_EQUAL(registrar.subRegistrar(name), h160(addr + 20));
|
||||||
registrar.setContent(name, h256(u256(addr + 90)));
|
registrar.setContent(name, h256(u256(addr + 90)));
|
||||||
BOOST_CHECK_EQUAL(registrar.content(name), h256(u256(addr + 90)));
|
BOOST_CHECK_EQUAL(registrar.content(name), h256(u256(addr + 90)));
|
||||||
|
|
||||||
// but not by someone else
|
// but not by someone else
|
||||||
m_sender = account(count - 1);
|
m_sender = account(count - 1);
|
||||||
BOOST_CHECK_EQUAL(registrar.owner(name), sender);
|
BOOST_CHECK_EQUAL(registrar.owner(name), sender);
|
||||||
registrar.setAddress(name, addr + 1, true);
|
registrar.setAddress(name, h160(addr + 1), true);
|
||||||
BOOST_CHECK_EQUAL(registrar.addr(name), u160(addr));
|
BOOST_CHECK_EQUAL(registrar.addr(name), h160(addr));
|
||||||
registrar.setSubRegistrar(name, addr + 20 + 1);
|
registrar.setSubRegistrar(name, h160(addr + 20 + 1));
|
||||||
BOOST_CHECK_EQUAL(registrar.subRegistrar(name), u160(addr + 20));
|
BOOST_CHECK_EQUAL(registrar.subRegistrar(name), h160(addr + 20));
|
||||||
registrar.setContent(name, h256(u256(addr + 90 + 1)));
|
registrar.setContent(name, h256(u256(addr + 90 + 1)));
|
||||||
BOOST_CHECK_EQUAL(registrar.content(name), h256(u256(addr + 90)));
|
BOOST_CHECK_EQUAL(registrar.content(name), h256(u256(addr + 90)));
|
||||||
count++;
|
count++;
|
||||||
@ -373,8 +373,8 @@ BOOST_AUTO_TEST_CASE(transfer)
|
|||||||
RegistrarInterface registrar(*this);
|
RegistrarInterface registrar(*this);
|
||||||
registrar.reserve(name);
|
registrar.reserve(name);
|
||||||
registrar.setContent(name, h256(u256(123)));
|
registrar.setContent(name, h256(u256(123)));
|
||||||
registrar.transfer(name, u160(555));
|
registrar.transfer(name, h160(555));
|
||||||
BOOST_CHECK_EQUAL(registrar.owner(name), u160(555));
|
BOOST_CHECK_EQUAL(registrar.owner(name), h160(555));
|
||||||
BOOST_CHECK_EQUAL(registrar.content(name), h256(u256(123)));
|
BOOST_CHECK_EQUAL(registrar.content(name), h256(u256(123)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,9 +386,9 @@ BOOST_AUTO_TEST_CASE(disown)
|
|||||||
RegistrarInterface registrar(*this);
|
RegistrarInterface registrar(*this);
|
||||||
registrar.reserve(name);
|
registrar.reserve(name);
|
||||||
registrar.setContent(name, h256(u256(123)));
|
registrar.setContent(name, h256(u256(123)));
|
||||||
registrar.setAddress(name, u160(124), true);
|
registrar.setAddress(name, h160(124), true);
|
||||||
registrar.setSubRegistrar(name, u160(125));
|
registrar.setSubRegistrar(name, h160(125));
|
||||||
BOOST_CHECK_EQUAL(registrar.name(u160(124)), name);
|
BOOST_CHECK_EQUAL(registrar.name(h160(124)), name);
|
||||||
|
|
||||||
// someone else tries disowning
|
// someone else tries disowning
|
||||||
sendEther(account(1), u256(10) * ether);
|
sendEther(account(1), u256(10) * ether);
|
||||||
@ -398,11 +398,11 @@ BOOST_AUTO_TEST_CASE(disown)
|
|||||||
|
|
||||||
m_sender = account(0);
|
m_sender = account(0);
|
||||||
registrar.disown(name);
|
registrar.disown(name);
|
||||||
BOOST_CHECK_EQUAL(registrar.owner(name), 0);
|
BOOST_CHECK_EQUAL(registrar.owner(name), h160());
|
||||||
BOOST_CHECK_EQUAL(registrar.addr(name), 0);
|
BOOST_CHECK_EQUAL(registrar.addr(name), h160());
|
||||||
BOOST_CHECK_EQUAL(registrar.subRegistrar(name), 0);
|
BOOST_CHECK_EQUAL(registrar.subRegistrar(name), h160());
|
||||||
BOOST_CHECK_EQUAL(registrar.content(name), h256());
|
BOOST_CHECK_EQUAL(registrar.content(name), h256());
|
||||||
BOOST_CHECK_EQUAL(registrar.name(u160(124)), "");
|
BOOST_CHECK_EQUAL(registrar.name(h160(124)), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(auction_simple)
|
BOOST_AUTO_TEST_CASE(auction_simple)
|
||||||
@ -414,7 +414,7 @@ BOOST_AUTO_TEST_CASE(auction_simple)
|
|||||||
// initiate auction
|
// initiate auction
|
||||||
registrar.setNextValue(8);
|
registrar.setNextValue(8);
|
||||||
registrar.reserve(name);
|
registrar.reserve(name);
|
||||||
BOOST_CHECK_EQUAL(registrar.owner(name), 0);
|
BOOST_CHECK_EQUAL(registrar.owner(name), h160());
|
||||||
// "wait" until auction end
|
// "wait" until auction end
|
||||||
|
|
||||||
m_evmcHost->tx_context.block_timestamp += m_biddingTime + 10;
|
m_evmcHost->tx_context.block_timestamp += m_biddingTime + 10;
|
||||||
@ -435,7 +435,7 @@ BOOST_AUTO_TEST_CASE(auction_bidding)
|
|||||||
// initiate auction
|
// initiate auction
|
||||||
registrar.setNextValue(8);
|
registrar.setNextValue(8);
|
||||||
registrar.reserve(name);
|
registrar.reserve(name);
|
||||||
BOOST_CHECK_EQUAL(registrar.owner(name), 0);
|
BOOST_CHECK_EQUAL(registrar.owner(name), h160());
|
||||||
// overbid self
|
// overbid self
|
||||||
m_evmcHost->tx_context.block_timestamp = startTime + m_biddingTime - 10;
|
m_evmcHost->tx_context.block_timestamp = startTime + m_biddingTime - 10;
|
||||||
registrar.setNextValue(12);
|
registrar.setNextValue(12);
|
||||||
@ -446,7 +446,7 @@ BOOST_AUTO_TEST_CASE(auction_bidding)
|
|||||||
m_evmcHost->tx_context.block_timestamp = startTime + 2 * m_biddingTime - 50;
|
m_evmcHost->tx_context.block_timestamp = startTime + 2 * m_biddingTime - 50;
|
||||||
registrar.setNextValue(13);
|
registrar.setNextValue(13);
|
||||||
registrar.reserve(name);
|
registrar.reserve(name);
|
||||||
BOOST_CHECK_EQUAL(registrar.owner(name), 0);
|
BOOST_CHECK_EQUAL(registrar.owner(name), h160());
|
||||||
// end auction by first bidder (which is not highest) trying to overbid again (too late)
|
// end auction by first bidder (which is not highest) trying to overbid again (too late)
|
||||||
m_sender = account(0);
|
m_sender = account(0);
|
||||||
m_evmcHost->tx_context.block_timestamp = startTime + 4 * m_biddingTime;
|
m_evmcHost->tx_context.block_timestamp = startTime + 4 * m_biddingTime;
|
||||||
|
@ -47,12 +47,12 @@ protected:
|
|||||||
BOOST_CHECK(call(_name + "(string)", u256(0x20), _arg.length(), _arg).empty());
|
BOOST_CHECK(call(_name + "(string)", u256(0x20), _arg.length(), _arg).empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
void callStringAddress(std::string const& _name, std::string const& _arg1, u160 const& _arg2)
|
void callStringAddress(std::string const& _name, std::string const& _arg1, util::h160 const& _arg2)
|
||||||
{
|
{
|
||||||
BOOST_CHECK(call(_name + "(string,address)", u256(0x40), _arg2, _arg1.length(), _arg1).empty());
|
BOOST_CHECK(call(_name + "(string,address)", u256(0x40), _arg2, _arg1.length(), _arg1).empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
void callStringAddressBool(std::string const& _name, std::string const& _arg1, u160 const& _arg2, bool _arg3)
|
void callStringAddressBool(std::string const& _name, std::string const& _arg1, util::h160 const& _arg2, bool _arg3)
|
||||||
{
|
{
|
||||||
BOOST_CHECK(call(_name + "(string,address,bool)", u256(0x60), _arg2, _arg3, _arg1.length(), _arg1).empty());
|
BOOST_CHECK(call(_name + "(string,address,bool)", u256(0x60), _arg2, _arg3, _arg1.length(), _arg1).empty());
|
||||||
}
|
}
|
||||||
@ -62,15 +62,16 @@ protected:
|
|||||||
BOOST_CHECK(call(_name + "(string,bytes32)", u256(0x40), _arg2, _arg1.length(), _arg1).empty());
|
BOOST_CHECK(call(_name + "(string,bytes32)", u256(0x40), _arg2, _arg1.length(), _arg1).empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
u160 callStringReturnsAddress(std::string const& _name, std::string const& _arg)
|
util::h160 callStringReturnsAddress(std::string const& _name, std::string const& _arg)
|
||||||
{
|
{
|
||||||
bytes const& ret = call(_name + "(string)", u256(0x20), _arg.length(), _arg);
|
bytes const& ret = call(_name + "(string)", u256(0x20), _arg.length(), _arg);
|
||||||
BOOST_REQUIRE(ret.size() == 0x20);
|
BOOST_REQUIRE(ret.size() == 0x20);
|
||||||
BOOST_CHECK(std::count(ret.begin(), ret.begin() + 12, 0) == 12);
|
BOOST_CHECK(std::count(ret.begin(), ret.begin() + 12, 0) == 12);
|
||||||
return u160(u256(util::h256(ret)));
|
bytes const addr{ret.begin() + 12, ret.end()};
|
||||||
|
return util::h160(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string callAddressReturnsString(std::string const& _name, u160 const& _arg)
|
std::string callAddressReturnsString(std::string const& _name, util::h160 const& _arg)
|
||||||
{
|
{
|
||||||
bytesConstRef const ret(&call(_name + "(address)", _arg));
|
bytesConstRef const ret(&call(_name + "(address)", _arg));
|
||||||
BOOST_REQUIRE(ret.size() >= 0x40);
|
BOOST_REQUIRE(ret.size() >= 0x40);
|
||||||
|
@ -160,11 +160,11 @@ BOOST_AUTO_TEST_CASE(reserve)
|
|||||||
deployRegistrar();
|
deployRegistrar();
|
||||||
string name[] = {"abc", "def", "ghi"};
|
string name[] = {"abc", "def", "ghi"};
|
||||||
BOOST_REQUIRE(callContractFunctionWithValue("reserve(string)", m_fee, encodeDyn(name[0])) == encodeArgs());
|
BOOST_REQUIRE(callContractFunctionWithValue("reserve(string)", m_fee, encodeDyn(name[0])) == encodeArgs());
|
||||||
BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name[0])) == encodeArgs(h256(account(0), h256::AlignRight)));
|
BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name[0])) == encodeArgs(account(0)));
|
||||||
BOOST_REQUIRE(callContractFunctionWithValue("reserve(string)", m_fee + 1, encodeDyn(name[1])) == encodeArgs());
|
BOOST_REQUIRE(callContractFunctionWithValue("reserve(string)", m_fee + 1, encodeDyn(name[1])) == encodeArgs());
|
||||||
BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name[1])) == encodeArgs(h256(account(0), h256::AlignRight)));
|
BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name[1])) == encodeArgs(account(0)));
|
||||||
BOOST_REQUIRE(callContractFunctionWithValue("reserve(string)", m_fee - 1, encodeDyn(name[2])) == encodeArgs());
|
BOOST_REQUIRE(callContractFunctionWithValue("reserve(string)", m_fee - 1, encodeDyn(name[2])) == encodeArgs());
|
||||||
BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name[2])) == encodeArgs(h256{}));
|
BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name[2])) == encodeArgs(h160{}));
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(double_reserve)
|
BOOST_AUTO_TEST_CASE(double_reserve)
|
||||||
@ -173,12 +173,12 @@ BOOST_AUTO_TEST_CASE(double_reserve)
|
|||||||
deployRegistrar();
|
deployRegistrar();
|
||||||
string name = "abc";
|
string name = "abc";
|
||||||
BOOST_REQUIRE(callContractFunctionWithValue("reserve(string)", m_fee, encodeDyn(name)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunctionWithValue("reserve(string)", m_fee, encodeDyn(name)) == encodeArgs());
|
||||||
BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name)) == encodeArgs(h256(account(0), h256::AlignRight)));
|
BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name)) == encodeArgs(account(0)));
|
||||||
|
|
||||||
sendEther(account(1), 100 * ether);
|
sendEther(account(1), 100 * ether);
|
||||||
m_sender = account(1);
|
m_sender = account(1);
|
||||||
BOOST_REQUIRE(callContractFunctionWithValue("reserve(string)", m_fee, encodeDyn(name)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunctionWithValue("reserve(string)", m_fee, encodeDyn(name)) == encodeArgs());
|
||||||
BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name)) == encodeArgs(h256(account(0), h256::AlignRight)));
|
BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name)) == encodeArgs(account(0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(properties)
|
BOOST_AUTO_TEST_CASE(properties)
|
||||||
@ -194,10 +194,10 @@ BOOST_AUTO_TEST_CASE(properties)
|
|||||||
m_sender = account(0);
|
m_sender = account(0);
|
||||||
sendEther(account(count), 100 * ether);
|
sendEther(account(count), 100 * ether);
|
||||||
m_sender = account(count);
|
m_sender = account(count);
|
||||||
Address owner = m_sender;
|
h160 owner = m_sender;
|
||||||
// setting by sender works
|
// setting by sender works
|
||||||
BOOST_REQUIRE(callContractFunctionWithValue("reserve(string)", m_fee, encodeDyn(name)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunctionWithValue("reserve(string)", m_fee, encodeDyn(name)) == encodeArgs());
|
||||||
BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name)) == encodeArgs(h256(owner, h256::AlignRight)));
|
BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name)) == encodeArgs(owner));
|
||||||
BOOST_CHECK(callContractFunction("setAddr(string,address)", u256(0x40), u256(addr), u256(name.length()), name) == encodeArgs());
|
BOOST_CHECK(callContractFunction("setAddr(string,address)", u256(0x40), u256(addr), u256(name.length()), name) == encodeArgs());
|
||||||
BOOST_CHECK(callContractFunction("addr(string)", encodeDyn(name)) == encodeArgs(addr));
|
BOOST_CHECK(callContractFunction("addr(string)", encodeDyn(name)) == encodeArgs(addr));
|
||||||
BOOST_CHECK(callContractFunction("setSubRegistrar(string,address)", u256(0x40), addr + 20, u256(name.length()), name) == encodeArgs());
|
BOOST_CHECK(callContractFunction("setSubRegistrar(string,address)", u256(0x40), addr + 20, u256(name.length()), name) == encodeArgs());
|
||||||
@ -209,7 +209,7 @@ BOOST_AUTO_TEST_CASE(properties)
|
|||||||
m_sender = account(0);
|
m_sender = account(0);
|
||||||
sendEther(account(count), 100 * ether);
|
sendEther(account(count), 100 * ether);
|
||||||
m_sender = account(count);
|
m_sender = account(count);
|
||||||
BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name)) == encodeArgs(h256(owner, h256::AlignRight)));
|
BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name)) == encodeArgs(owner));
|
||||||
BOOST_CHECK(callContractFunction("setAddr(string,address)", u256(0x40), addr + 1, u256(name.length()), name) == encodeArgs());
|
BOOST_CHECK(callContractFunction("setAddr(string,address)", u256(0x40), addr + 1, u256(name.length()), name) == encodeArgs());
|
||||||
BOOST_CHECK(callContractFunction("addr(string)", encodeDyn(name)) == encodeArgs(addr));
|
BOOST_CHECK(callContractFunction("addr(string)", encodeDyn(name)) == encodeArgs(addr));
|
||||||
BOOST_CHECK(callContractFunction("setSubRegistrar(string,address)", u256(0x40), addr + 20 + 1, u256(name.length()), name) == encodeArgs());
|
BOOST_CHECK(callContractFunction("setSubRegistrar(string,address)", u256(0x40), addr + 20 + 1, u256(name.length()), name) == encodeArgs());
|
||||||
@ -225,10 +225,10 @@ BOOST_AUTO_TEST_CASE(transfer)
|
|||||||
deployRegistrar();
|
deployRegistrar();
|
||||||
string name = "abc";
|
string name = "abc";
|
||||||
BOOST_REQUIRE(callContractFunctionWithValue("reserve(string)", m_fee, encodeDyn(name)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunctionWithValue("reserve(string)", m_fee, encodeDyn(name)) == encodeArgs());
|
||||||
BOOST_CHECK(callContractFunction("setContent(string,bytes32)", u256(0x40), h256(account(0), h256::AlignRight), u256(name.length()), name) == encodeArgs());
|
BOOST_CHECK(callContractFunction("setContent(string,bytes32)", u256(0x40), account(0), u256(name.length()), name) == encodeArgs());
|
||||||
BOOST_CHECK(callContractFunction("transfer(string,address)", u256(0x40), u256(555), u256(name.length()), name) == encodeArgs());
|
BOOST_CHECK(callContractFunction("transfer(string,address)", u256(0x40), u256(555), u256(name.length()), name) == encodeArgs());
|
||||||
BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name)) == encodeArgs(u256(555)));
|
BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name)) == encodeArgs(u256(555)));
|
||||||
BOOST_CHECK(callContractFunction("content(string)", encodeDyn(name)) == encodeArgs(h256(account(0), h256::AlignRight)));
|
BOOST_CHECK(callContractFunction("content(string)", encodeDyn(name)) == encodeArgs(account(0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(disown)
|
BOOST_AUTO_TEST_CASE(disown)
|
||||||
@ -236,13 +236,13 @@ BOOST_AUTO_TEST_CASE(disown)
|
|||||||
deployRegistrar();
|
deployRegistrar();
|
||||||
string name = "abc";
|
string name = "abc";
|
||||||
BOOST_REQUIRE(callContractFunctionWithValue("reserve(string)", m_fee, encodeDyn(name)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunctionWithValue("reserve(string)", m_fee, encodeDyn(name)) == encodeArgs());
|
||||||
BOOST_CHECK(callContractFunction("setContent(string,bytes32)", u256(0x40), h256(account(0), h256::AlignRight), u256(name.length()), name) == encodeArgs());
|
BOOST_CHECK(callContractFunction("setContent(string,bytes32)", u256(0x40), account(0), u256(name.length()), name) == encodeArgs());
|
||||||
BOOST_CHECK(callContractFunction("setAddr(string,address)", u256(0x40), u256(124), u256(name.length()), name) == encodeArgs());
|
BOOST_CHECK(callContractFunction("setAddr(string,address)", u256(0x40), u256(124), u256(name.length()), name) == encodeArgs());
|
||||||
BOOST_CHECK(callContractFunction("setSubRegistrar(string,address)", u256(0x40), u256(125), u256(name.length()), name) == encodeArgs());
|
BOOST_CHECK(callContractFunction("setSubRegistrar(string,address)", u256(0x40), u256(125), u256(name.length()), name) == encodeArgs());
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL(balanceAt(Address(0x124)), 0);
|
BOOST_CHECK_EQUAL(balanceAt(h160(0x124)), 0);
|
||||||
BOOST_CHECK(callContractFunction("disown(string,address)", u256(0x40), u256(0x124), name.size(), name) == encodeArgs());
|
BOOST_CHECK(callContractFunction("disown(string,address)", u256(0x40), u256(0x124), name.size(), name) == encodeArgs());
|
||||||
BOOST_CHECK_EQUAL(balanceAt(Address(0x124)), m_fee);
|
BOOST_CHECK_EQUAL(balanceAt(h160(0x124)), m_fee);
|
||||||
|
|
||||||
BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name)) == encodeArgs(u256(0)));
|
BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name)) == encodeArgs(u256(0)));
|
||||||
BOOST_CHECK(callContractFunction("content(string)", encodeDyn(name)) == encodeArgs(u256(0)));
|
BOOST_CHECK(callContractFunction("content(string)", encodeDyn(name)) == encodeArgs(u256(0)));
|
||||||
|
@ -445,7 +445,7 @@ class WalletTestFramework: public SolidityExecutionFramework
|
|||||||
protected:
|
protected:
|
||||||
void deployWallet(
|
void deployWallet(
|
||||||
u256 const& _value = 0,
|
u256 const& _value = 0,
|
||||||
vector<u256> const& _owners = vector<u256>{},
|
vector<h160> const& _owners = vector<h160>{},
|
||||||
u256 _required = 1,
|
u256 _required = 1,
|
||||||
u256 _dailyLimit = 0
|
u256 _dailyLimit = 0
|
||||||
)
|
)
|
||||||
@ -467,7 +467,7 @@ BOOST_FIXTURE_TEST_SUITE(SolidityWallet, WalletTestFramework)
|
|||||||
BOOST_AUTO_TEST_CASE(creation)
|
BOOST_AUTO_TEST_CASE(creation)
|
||||||
{
|
{
|
||||||
deployWallet(200);
|
deployWallet(200);
|
||||||
BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(m_sender, h256::AlignRight)) == encodeArgs(true));
|
BOOST_REQUIRE(callContractFunction("isOwner(address)", m_sender) == encodeArgs(true));
|
||||||
bool v2 = solidity::test::CommonOptions::get().useABIEncoderV2;
|
bool v2 = solidity::test::CommonOptions::get().useABIEncoderV2;
|
||||||
BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(~0)) == (v2 ? encodeArgs() : encodeArgs(false)));
|
BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(~0)) == (v2 ? encodeArgs() : encodeArgs(false)));
|
||||||
}
|
}
|
||||||
@ -475,34 +475,34 @@ BOOST_AUTO_TEST_CASE(creation)
|
|||||||
BOOST_AUTO_TEST_CASE(add_owners)
|
BOOST_AUTO_TEST_CASE(add_owners)
|
||||||
{
|
{
|
||||||
deployWallet(200);
|
deployWallet(200);
|
||||||
Address originalOwner = m_sender;
|
h160 originalOwner = m_sender;
|
||||||
BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(account(1), h256::AlignRight)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunction("addOwner(address)", account(1)) == encodeArgs());
|
||||||
BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(account(1), h256::AlignRight)) == encodeArgs(true));
|
BOOST_REQUIRE(callContractFunction("isOwner(address)", account(1)) == encodeArgs(true));
|
||||||
// now let the new owner add someone
|
// now let the new owner add someone
|
||||||
sendEther(account(1), 10 * ether);
|
sendEther(account(1), 10 * ether);
|
||||||
m_sender = account(1);
|
m_sender = account(1);
|
||||||
BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(0x13)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunction("addOwner(address)", h160(0x13)) == encodeArgs());
|
||||||
BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(0x13)) == encodeArgs(true));
|
BOOST_REQUIRE(callContractFunction("isOwner(address)", h160(0x13)) == encodeArgs(true));
|
||||||
// and check that a non-owner cannot add a new owner
|
// and check that a non-owner cannot add a new owner
|
||||||
m_sender = account(0);
|
m_sender = account(0);
|
||||||
sendEther(account(2), 10 * ether);
|
sendEther(account(2), 10 * ether);
|
||||||
m_sender = account(2);
|
m_sender = account(2);
|
||||||
BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(0x20)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunction("addOwner(address)", h160(0x20)) == encodeArgs());
|
||||||
BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(0x20)) == encodeArgs(false));
|
BOOST_REQUIRE(callContractFunction("isOwner(address)", h160(0x20)) == encodeArgs(false));
|
||||||
// finally check that all the owners are there
|
// finally check that all the owners are there
|
||||||
BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(originalOwner, h256::AlignRight)) == encodeArgs(true));
|
BOOST_REQUIRE(callContractFunction("isOwner(address)", originalOwner) == encodeArgs(true));
|
||||||
BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(account(1), h256::AlignRight)) == encodeArgs(true));
|
BOOST_REQUIRE(callContractFunction("isOwner(address)", account(1)) == encodeArgs(true));
|
||||||
BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(0x13)) == encodeArgs(true));
|
BOOST_REQUIRE(callContractFunction("isOwner(address)", h160(0x13)) == encodeArgs(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(change_owners)
|
BOOST_AUTO_TEST_CASE(change_owners)
|
||||||
{
|
{
|
||||||
deployWallet(200);
|
deployWallet(200);
|
||||||
BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(0x12)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunction("addOwner(address)", h160(0x12)) == encodeArgs());
|
||||||
BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(0x12)) == encodeArgs(true));
|
BOOST_REQUIRE(callContractFunction("isOwner(address)", h160(0x12)) == encodeArgs(true));
|
||||||
BOOST_REQUIRE(callContractFunction("changeOwner(address,address)", h256(0x12), h256(0x13)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunction("changeOwner(address,address)", h160(0x12), h160(0x13)) == encodeArgs());
|
||||||
BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(0x12)) == encodeArgs(false));
|
BOOST_REQUIRE(callContractFunction("isOwner(address)", h160(0x12)) == encodeArgs(false));
|
||||||
BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(0x13)) == encodeArgs(true));
|
BOOST_REQUIRE(callContractFunction("isOwner(address)", h160(0x13)) == encodeArgs(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(remove_owner)
|
BOOST_AUTO_TEST_CASE(remove_owner)
|
||||||
@ -511,43 +511,43 @@ BOOST_AUTO_TEST_CASE(remove_owner)
|
|||||||
// add 10 owners
|
// add 10 owners
|
||||||
for (unsigned i = 0; i < 10; ++i)
|
for (unsigned i = 0; i < 10; ++i)
|
||||||
{
|
{
|
||||||
BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(0x12 + i)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunction("addOwner(address)", h160(0x12 + i)) == encodeArgs());
|
||||||
BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(0x12 + i)) == encodeArgs(true));
|
BOOST_REQUIRE(callContractFunction("isOwner(address)", h160(0x12 + i)) == encodeArgs(true));
|
||||||
}
|
}
|
||||||
// check they are there again
|
// check they are there again
|
||||||
for (unsigned i = 0; i < 10; ++i)
|
for (unsigned i = 0; i < 10; ++i)
|
||||||
BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(0x12 + i)) == encodeArgs(true));
|
BOOST_REQUIRE(callContractFunction("isOwner(address)", h160(0x12 + i)) == encodeArgs(true));
|
||||||
// remove the odd owners
|
// remove the odd owners
|
||||||
for (unsigned i = 0; i < 10; ++i)
|
for (unsigned i = 0; i < 10; ++i)
|
||||||
if (i % 2 == 1)
|
if (i % 2 == 1)
|
||||||
BOOST_REQUIRE(callContractFunction("removeOwner(address)", h256(0x12 + i)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunction("removeOwner(address)", h160(0x12 + i)) == encodeArgs());
|
||||||
// check the result
|
// check the result
|
||||||
for (unsigned i = 0; i < 10; ++i)
|
for (unsigned i = 0; i < 10; ++i)
|
||||||
BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(0x12 + i)) == encodeArgs(i % 2 == 0));
|
BOOST_REQUIRE(callContractFunction("isOwner(address)", h160(0x12 + i)) == encodeArgs(i % 2 == 0));
|
||||||
// add them again
|
// add them again
|
||||||
for (unsigned i = 0; i < 10; ++i)
|
for (unsigned i = 0; i < 10; ++i)
|
||||||
if (i % 2 == 1)
|
if (i % 2 == 1)
|
||||||
BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(0x12 + i)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunction("addOwner(address)", h160(0x12 + i)) == encodeArgs());
|
||||||
// check everyone is there
|
// check everyone is there
|
||||||
for (unsigned i = 0; i < 10; ++i)
|
for (unsigned i = 0; i < 10; ++i)
|
||||||
BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(0x12 + i)) == encodeArgs(true));
|
BOOST_REQUIRE(callContractFunction("isOwner(address)", h160(0x12 + i)) == encodeArgs(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(initial_owners)
|
BOOST_AUTO_TEST_CASE(initial_owners)
|
||||||
{
|
{
|
||||||
vector<u256> owners{
|
vector<h160> owners{
|
||||||
u256("0x00000000000000000000000042c56279432962a17176998a4747d1b4d6ed4367"),
|
h160("0x42c56279432962a17176998a4747d1b4d6ed4367"),
|
||||||
u256("0x000000000000000000000000d4d4669f5ba9f4c27d38ef02a358c339b5560c47"),
|
h160("0xd4d4669f5ba9f4c27d38ef02a358c339b5560c47"),
|
||||||
u256("0x000000000000000000000000e6716f9544a56c530d868e4bfbacb172315bdead"),
|
h160("0xe6716f9544a56c530d868e4bfbacb172315bdead"),
|
||||||
u256("0x000000000000000000000000775e18be7a50a0abb8a4e82b1bd697d79f31fe04"),
|
h160("0x775e18be7a50a0abb8a4e82b1bd697d79f31fe04"),
|
||||||
u256("0x000000000000000000000000f4dd5c3794f1fd0cdc0327a83aa472609c806e99"),
|
h160("0xf4dd5c3794f1fd0cdc0327a83aa472609c806e99"),
|
||||||
u256("0x0000000000000000000000004c9113886af165b2de069d6e99430647e94a9fff"),
|
h160("0x4c9113886af165b2de069d6e99430647e94a9fff"),
|
||||||
u256("0x0000000000000000000000003fb1cd2cd96c6d5c0b5eb3322d807b34482481d4")
|
h160("0x3fb1cd2cd96c6d5c0b5eb3322d807b34482481d4")
|
||||||
};
|
};
|
||||||
deployWallet(0, owners, 4, 2);
|
deployWallet(0, owners, 4, 2);
|
||||||
BOOST_CHECK(callContractFunction("m_numOwners()") == encodeArgs(u256(8)));
|
BOOST_CHECK(callContractFunction("m_numOwners()") == encodeArgs(u256(8)));
|
||||||
BOOST_CHECK(callContractFunction("isOwner(address)", h256(m_sender, h256::AlignRight)) == encodeArgs(true));
|
BOOST_CHECK(callContractFunction("isOwner(address)", m_sender) == encodeArgs(true));
|
||||||
for (u256 const& owner: owners)
|
for (h160 const& owner: owners)
|
||||||
{
|
{
|
||||||
BOOST_CHECK(callContractFunction("isOwner(address)", owner) == encodeArgs(true));
|
BOOST_CHECK(callContractFunction("isOwner(address)", owner) == encodeArgs(true));
|
||||||
}
|
}
|
||||||
@ -556,17 +556,17 @@ BOOST_AUTO_TEST_CASE(initial_owners)
|
|||||||
BOOST_AUTO_TEST_CASE(multisig_value_transfer)
|
BOOST_AUTO_TEST_CASE(multisig_value_transfer)
|
||||||
{
|
{
|
||||||
deployWallet(200);
|
deployWallet(200);
|
||||||
BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(account(1), h256::AlignRight)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunction("addOwner(address)", account(1)) == encodeArgs());
|
||||||
BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(account(2), h256::AlignRight)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunction("addOwner(address)", account(2)) == encodeArgs());
|
||||||
BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(account(3), h256::AlignRight)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunction("addOwner(address)", account(3)) == encodeArgs());
|
||||||
// 4 owners, set required to 3
|
// 4 owners, set required to 3
|
||||||
BOOST_REQUIRE(callContractFunction("changeRequirement(uint256)", u256(3)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunction("changeRequirement(uint256)", u256(3)) == encodeArgs());
|
||||||
Address destination = Address("0x5c6d6026d3fb35cd7175fd0054ae8df50d8f8b41");
|
h160 destination = h160("0x5c6d6026d3fb35cd7175fd0054ae8df50d8f8b41");
|
||||||
BOOST_CHECK_EQUAL(balanceAt(destination), 0);
|
BOOST_CHECK_EQUAL(balanceAt(destination), 0);
|
||||||
m_sender = account(0);
|
m_sender = account(0);
|
||||||
sendEther(account(1), 10 * ether);
|
sendEther(account(1), 10 * ether);
|
||||||
m_sender = account(1);
|
m_sender = account(1);
|
||||||
auto ophash = callContractFunction("execute(address,uint256,bytes)", h256(destination, h256::AlignRight), 100, 0x60, 0x00);
|
auto ophash = callContractFunction("execute(address,uint256,bytes)", destination, 100, 0x60, 0x00);
|
||||||
BOOST_CHECK_EQUAL(balanceAt(destination), 0);
|
BOOST_CHECK_EQUAL(balanceAt(destination), 0);
|
||||||
m_sender = account(0);
|
m_sender = account(0);
|
||||||
sendEther(account(2), 10 * ether);
|
sendEther(account(2), 10 * ether);
|
||||||
@ -584,52 +584,52 @@ BOOST_AUTO_TEST_CASE(multisig_value_transfer)
|
|||||||
BOOST_AUTO_TEST_CASE(revoke_addOwner)
|
BOOST_AUTO_TEST_CASE(revoke_addOwner)
|
||||||
{
|
{
|
||||||
deployWallet();
|
deployWallet();
|
||||||
BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(account(1), h256::AlignRight)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunction("addOwner(address)", account(1)) == encodeArgs());
|
||||||
BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(account(2), h256::AlignRight)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunction("addOwner(address)", account(2)) == encodeArgs());
|
||||||
BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(account(3), h256::AlignRight)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunction("addOwner(address)", account(3)) == encodeArgs());
|
||||||
// 4 owners, set required to 3
|
// 4 owners, set required to 3
|
||||||
BOOST_REQUIRE(callContractFunction("changeRequirement(uint256)", u256(3)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunction("changeRequirement(uint256)", u256(3)) == encodeArgs());
|
||||||
// add a new owner
|
// add a new owner
|
||||||
Address deployer = m_sender;
|
h160 deployer = m_sender;
|
||||||
h256 opHash = util::keccak256(FixedHash<4>(util::keccak256("addOwner(address)")).asBytes() + h256(0x33).asBytes());
|
h256 opHash = util::keccak256(FixedHash<4>(util::keccak256("addOwner(address)")).asBytes() + h256(0x33).asBytes());
|
||||||
BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(0x33)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunction("addOwner(address)", h160(0x33)) == encodeArgs());
|
||||||
BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(0x33)) == encodeArgs(false));
|
BOOST_REQUIRE(callContractFunction("isOwner(address)", h160(0x33)) == encodeArgs(false));
|
||||||
m_sender = account(0);
|
m_sender = account(0);
|
||||||
sendEther(account(1), 10 * ether);
|
sendEther(account(1), 10 * ether);
|
||||||
m_sender = account(1);
|
m_sender = account(1);
|
||||||
BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(0x33)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunction("addOwner(address)", h160(0x33)) == encodeArgs());
|
||||||
BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(0x33)) == encodeArgs(false));
|
BOOST_REQUIRE(callContractFunction("isOwner(address)", h160(0x33)) == encodeArgs(false));
|
||||||
// revoke one confirmation
|
// revoke one confirmation
|
||||||
m_sender = deployer;
|
m_sender = deployer;
|
||||||
BOOST_REQUIRE(callContractFunction("revoke(bytes32)", opHash) == encodeArgs());
|
BOOST_REQUIRE(callContractFunction("revoke(bytes32)", opHash) == encodeArgs());
|
||||||
m_sender = account(0);
|
m_sender = account(0);
|
||||||
sendEther(account(2), 10 * ether);
|
sendEther(account(2), 10 * ether);
|
||||||
m_sender = account(2);
|
m_sender = account(2);
|
||||||
BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(0x33)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunction("addOwner(address)", h160(0x33)) == encodeArgs());
|
||||||
BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(0x33)) == encodeArgs(false));
|
BOOST_REQUIRE(callContractFunction("isOwner(address)", h160(0x33)) == encodeArgs(false));
|
||||||
m_sender = account(0);
|
m_sender = account(0);
|
||||||
sendEther(account(3), 10 * ether);
|
sendEther(account(3), 10 * ether);
|
||||||
m_sender = account(3);
|
m_sender = account(3);
|
||||||
BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(0x33)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunction("addOwner(address)", h160(0x33)) == encodeArgs());
|
||||||
BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(0x33)) == encodeArgs(true));
|
BOOST_REQUIRE(callContractFunction("isOwner(address)", h160(0x33)) == encodeArgs(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(revoke_transaction)
|
BOOST_AUTO_TEST_CASE(revoke_transaction)
|
||||||
{
|
{
|
||||||
deployWallet(200);
|
deployWallet(200);
|
||||||
BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(account(1), h256::AlignRight)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunction("addOwner(address)", account(1)) == encodeArgs());
|
||||||
BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(account(2), h256::AlignRight)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunction("addOwner(address)", account(2)) == encodeArgs());
|
||||||
BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(account(3), h256::AlignRight)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunction("addOwner(address)", account(3)) == encodeArgs());
|
||||||
// 4 owners, set required to 3
|
// 4 owners, set required to 3
|
||||||
BOOST_REQUIRE(callContractFunction("changeRequirement(uint256)", u256(3)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunction("changeRequirement(uint256)", u256(3)) == encodeArgs());
|
||||||
// create a transaction
|
// create a transaction
|
||||||
Address deployer = m_sender;
|
h160 deployer = m_sender;
|
||||||
Address destination = Address("0x5c6d6026d3fb35cd7175fd0054ae8df50d8f8b41");
|
h160 destination = h160("0x5c6d6026d3fb35cd7175fd0054ae8df50d8f8b41");
|
||||||
BOOST_CHECK_EQUAL(balanceAt(destination), 0);
|
BOOST_CHECK_EQUAL(balanceAt(destination), 0);
|
||||||
m_sender = account(0);
|
m_sender = account(0);
|
||||||
sendEther(account(1), 10 * ether);
|
sendEther(account(1), 10 * ether);
|
||||||
m_sender = account(1);
|
m_sender = account(1);
|
||||||
auto opHash = callContractFunction("execute(address,uint256,bytes)", h256(destination, h256::AlignRight), 100, 0x60, 0x00);
|
auto opHash = callContractFunction("execute(address,uint256,bytes)", destination, 100, 0x60, 0x00);
|
||||||
BOOST_CHECK_EQUAL(balanceAt(destination), 0);
|
BOOST_CHECK_EQUAL(balanceAt(destination), 0);
|
||||||
m_sender = account(0);
|
m_sender = account(0);
|
||||||
sendEther(account(2), 10 * ether);
|
sendEther(account(2), 10 * ether);
|
||||||
@ -655,21 +655,21 @@ BOOST_AUTO_TEST_CASE(daylimit)
|
|||||||
{
|
{
|
||||||
deployWallet(200);
|
deployWallet(200);
|
||||||
BOOST_REQUIRE(callContractFunction("m_dailyLimit()") == encodeArgs(u256(0)));
|
BOOST_REQUIRE(callContractFunction("m_dailyLimit()") == encodeArgs(u256(0)));
|
||||||
BOOST_REQUIRE(callContractFunction("setDailyLimit(uint256)", h256(100)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunction("setDailyLimit(uint256)", u256(100)) == encodeArgs());
|
||||||
BOOST_REQUIRE(callContractFunction("m_dailyLimit()") == encodeArgs(u256(100)));
|
BOOST_REQUIRE(callContractFunction("m_dailyLimit()") == encodeArgs(u256(100)));
|
||||||
BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(account(1), h256::AlignRight)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunction("addOwner(address)", account(1)) == encodeArgs());
|
||||||
BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(account(2), h256::AlignRight)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunction("addOwner(address)", account(2)) == encodeArgs());
|
||||||
BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(account(3), h256::AlignRight)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunction("addOwner(address)", account(3)) == encodeArgs());
|
||||||
// 4 owners, set required to 3
|
// 4 owners, set required to 3
|
||||||
BOOST_REQUIRE(callContractFunction("changeRequirement(uint256)", u256(3)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunction("changeRequirement(uint256)", u256(3)) == encodeArgs());
|
||||||
|
|
||||||
// try to send tx over daylimit
|
// try to send tx over daylimit
|
||||||
Address destination = Address("0x5c6d6026d3fb35cd7175fd0054ae8df50d8f8b41");
|
h160 destination = h160("0x5c6d6026d3fb35cd7175fd0054ae8df50d8f8b41");
|
||||||
BOOST_CHECK_EQUAL(balanceAt(destination), 0);
|
BOOST_CHECK_EQUAL(balanceAt(destination), 0);
|
||||||
sendEther(account(1), 10 * ether);
|
sendEther(account(1), 10 * ether);
|
||||||
m_sender = account(1);
|
m_sender = account(1);
|
||||||
BOOST_REQUIRE(
|
BOOST_REQUIRE(
|
||||||
callContractFunction("execute(address,uint256,bytes)", h256(destination, h256::AlignRight), 150, 0x60, 0x00) !=
|
callContractFunction("execute(address,uint256,bytes)", destination, 150, 0x60, 0x00) !=
|
||||||
encodeArgs(u256(0))
|
encodeArgs(u256(0))
|
||||||
);
|
);
|
||||||
BOOST_CHECK_EQUAL(balanceAt(destination), 0);
|
BOOST_CHECK_EQUAL(balanceAt(destination), 0);
|
||||||
@ -678,7 +678,7 @@ BOOST_AUTO_TEST_CASE(daylimit)
|
|||||||
sendEther(account(4), 10 * ether);
|
sendEther(account(4), 10 * ether);
|
||||||
m_sender = account(4);
|
m_sender = account(4);
|
||||||
BOOST_REQUIRE(
|
BOOST_REQUIRE(
|
||||||
callContractFunction("execute(address,uint256,bytes)", h256(destination, h256::AlignRight), 90, 0x60, 0x00) ==
|
callContractFunction("execute(address,uint256,bytes)", destination, 90, 0x60, 0x00) ==
|
||||||
encodeArgs(u256(0))
|
encodeArgs(u256(0))
|
||||||
);
|
);
|
||||||
BOOST_CHECK_EQUAL(balanceAt(destination), 0);
|
BOOST_CHECK_EQUAL(balanceAt(destination), 0);
|
||||||
@ -686,7 +686,7 @@ BOOST_AUTO_TEST_CASE(daylimit)
|
|||||||
m_sender = account(0);
|
m_sender = account(0);
|
||||||
sendEther(account(1), 10 * ether);
|
sendEther(account(1), 10 * ether);
|
||||||
BOOST_REQUIRE(
|
BOOST_REQUIRE(
|
||||||
callContractFunction("execute(address,uint256,bytes)", h256(destination, h256::AlignRight), 90, 0x60, 0x00) ==
|
callContractFunction("execute(address,uint256,bytes)", destination, 90, 0x60, 0x00) ==
|
||||||
encodeArgs(u256(0))
|
encodeArgs(u256(0))
|
||||||
);
|
);
|
||||||
BOOST_CHECK_EQUAL(balanceAt(destination), 90);
|
BOOST_CHECK_EQUAL(balanceAt(destination), 90);
|
||||||
@ -696,7 +696,7 @@ BOOST_AUTO_TEST_CASE(daylimit_constructor)
|
|||||||
{
|
{
|
||||||
deployWallet(200, {}, 1, 20);
|
deployWallet(200, {}, 1, 20);
|
||||||
BOOST_REQUIRE(callContractFunction("m_dailyLimit()") == encodeArgs(u256(20)));
|
BOOST_REQUIRE(callContractFunction("m_dailyLimit()") == encodeArgs(u256(20)));
|
||||||
BOOST_REQUIRE(callContractFunction("setDailyLimit(uint256)", h256(30)) == encodeArgs());
|
BOOST_REQUIRE(callContractFunction("setDailyLimit(uint256)", u256(30)) == encodeArgs());
|
||||||
BOOST_REQUIRE(callContractFunction("m_dailyLimit()") == encodeArgs(u256(30)));
|
BOOST_REQUIRE(callContractFunction("m_dailyLimit()") == encodeArgs(u256(30)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@ printTask "Running external tests..."
|
|||||||
|
|
||||||
"$REPO_ROOT/externalTests/zeppelin.sh" "$SOLJSON"
|
"$REPO_ROOT/externalTests/zeppelin.sh" "$SOLJSON"
|
||||||
"$REPO_ROOT/externalTests/gnosis.sh" "$SOLJSON"
|
"$REPO_ROOT/externalTests/gnosis.sh" "$SOLJSON"
|
||||||
|
"$REPO_ROOT/externalTests/gnosis-v2.sh" "$SOLJSON"
|
||||||
"$REPO_ROOT/externalTests/colony.sh" "$SOLJSON"
|
"$REPO_ROOT/externalTests/colony.sh" "$SOLJSON"
|
||||||
"$REPO_ROOT/externalTests/ens.sh" "$SOLJSON"
|
"$REPO_ROOT/externalTests/ens.sh" "$SOLJSON"
|
||||||
|
|
||||||
|
@ -33,15 +33,15 @@ function colony_test
|
|||||||
OPTIMIZER_LEVEL=3
|
OPTIMIZER_LEVEL=3
|
||||||
CONFIG="truffle.js"
|
CONFIG="truffle.js"
|
||||||
|
|
||||||
truffle_setup "$SOLJSON" https://github.com/solidity-external-tests/colonyNetwork.git develop_080
|
truffle_setup "$SOLJSON" https://github.com/solidity-external-tests/colonyNetwork.git develop_070_new
|
||||||
run_install "$SOLJSON" install_fn
|
run_install "$SOLJSON" install_fn
|
||||||
|
|
||||||
cd lib
|
cd lib
|
||||||
rm -Rf dappsys
|
rm -Rf dappsys
|
||||||
git clone https://github.com/solidity-external-tests/dappsys-monolithic.git -b master_080 dappsys
|
git clone https://github.com/solidity-external-tests/dappsys-monolithic.git -b master_070 dappsys
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
truffle_run_test "$SOLJSON" compile_fn test_fn "NO-FORCE-ABI-V2"
|
truffle_run_test "$SOLJSON" compile_fn test_fn
|
||||||
}
|
}
|
||||||
|
|
||||||
external_test ColonyNetworks colony_test
|
external_test ColonyNetworks colony_test
|
||||||
|
@ -109,13 +109,6 @@ function replace_version_pragmas
|
|||||||
find . test -name '*.sol' -type f -print0 | xargs -0 sed -i -E -e 's/pragma solidity [^;]+;/pragma solidity >=0.0;/'
|
find . test -name '*.sol' -type f -print0 | xargs -0 sed -i -E -e 's/pragma solidity [^;]+;/pragma solidity >=0.0;/'
|
||||||
}
|
}
|
||||||
|
|
||||||
function replace_libsolc_call
|
|
||||||
{
|
|
||||||
# Change "compileStandard" to "compile" (needed for pre-5.x Truffle)
|
|
||||||
printLog "Replacing libsolc compile call in Truffle..."
|
|
||||||
sed -i s/solc.compileStandard/solc.compile/ "node_modules/truffle/build/cli.bundled.js"
|
|
||||||
}
|
|
||||||
|
|
||||||
function find_truffle_config
|
function find_truffle_config
|
||||||
{
|
{
|
||||||
local config_file="truffle.js"
|
local config_file="truffle.js"
|
||||||
@ -142,6 +135,9 @@ function force_solc_truffle_modules
|
|||||||
rm -rf solc
|
rm -rf solc
|
||||||
git clone --depth 1 -b master https://github.com/ethereum/solc-js.git solc
|
git clone --depth 1 -b master https://github.com/ethereum/solc-js.git solc
|
||||||
cp "$1" solc/soljson.js
|
cp "$1" solc/soljson.js
|
||||||
|
|
||||||
|
cd solc
|
||||||
|
npm install
|
||||||
fi
|
fi
|
||||||
)
|
)
|
||||||
done
|
done
|
||||||
@ -180,20 +176,6 @@ function force_solc_settings
|
|||||||
echo "module.exports['compilers']['solc']['settings'] = { optimizer: $settings, evmVersion: \"$evmVersion\" };" >> "$config_file"
|
echo "module.exports['compilers']['solc']['settings'] = { optimizer: $settings, evmVersion: \"$evmVersion\" };" >> "$config_file"
|
||||||
}
|
}
|
||||||
|
|
||||||
function force_abi_v2
|
|
||||||
{
|
|
||||||
# Add "pragma abi coder v2" to all files.
|
|
||||||
printLog "Forcibly enabling abi coder v2..."
|
|
||||||
find contracts test -name '*.sol' -type f -print0 | \
|
|
||||||
while IFS= read -r -d '' file
|
|
||||||
do
|
|
||||||
# Only add the pragma if it is not already there.
|
|
||||||
if grep -q -v 'pragma abicoder v2' "$file"; then
|
|
||||||
sed -i -e '1 i pragma abicoder v2;' "$file"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
function verify_compiler_version
|
function verify_compiler_version
|
||||||
{
|
{
|
||||||
local solc_version="$1"
|
local solc_version="$1"
|
||||||
@ -238,9 +220,6 @@ function truffle_run_test
|
|||||||
local soljson="$1"
|
local soljson="$1"
|
||||||
local compile_fn="$2"
|
local compile_fn="$2"
|
||||||
local test_fn="$3"
|
local test_fn="$3"
|
||||||
local force_abi_v2_flag="$4"
|
|
||||||
|
|
||||||
test "$force_abi_v2_flag" = "FORCE-ABI-V2" || test "$force_abi_v2_flag" = "NO-FORCE-ABI-V2"
|
|
||||||
|
|
||||||
replace_version_pragmas
|
replace_version_pragmas
|
||||||
force_solc "$CONFIG" "$DIR" "$soljson"
|
force_solc "$CONFIG" "$DIR" "$soljson"
|
||||||
@ -264,10 +243,6 @@ function truffle_run_test
|
|||||||
do
|
do
|
||||||
clean
|
clean
|
||||||
force_solc_settings "$CONFIG" "$optimize" "istanbul"
|
force_solc_settings "$CONFIG" "$optimize" "istanbul"
|
||||||
# Force abi coder v2 in the last step. Has to be the last because code is modified.
|
|
||||||
if [ "$force_abi_v2_flag" = "FORCE-ABI-V2" ]; then
|
|
||||||
[[ "$optimize" =~ yul ]] && force_abi_v2
|
|
||||||
fi
|
|
||||||
|
|
||||||
printLog "Running compile function..."
|
printLog "Running compile function..."
|
||||||
$compile_fn
|
$compile_fn
|
||||||
|
@ -38,9 +38,12 @@ function ens_test
|
|||||||
# Use latest Truffle. Older versions crash on the output from 0.8.0.
|
# Use latest Truffle. Older versions crash on the output from 0.8.0.
|
||||||
force_truffle_version ^5.1.55
|
force_truffle_version ^5.1.55
|
||||||
|
|
||||||
|
# Remove the lock file (if it exists) to prevent it from overriding our changes in package.json
|
||||||
|
rm -f package-lock.json
|
||||||
|
|
||||||
run_install "$SOLJSON" install_fn
|
run_install "$SOLJSON" install_fn
|
||||||
|
|
||||||
truffle_run_test "$SOLJSON" compile_fn test_fn "NO-FORCE-ABI-V2"
|
truffle_run_test "$SOLJSON" compile_fn test_fn
|
||||||
}
|
}
|
||||||
|
|
||||||
external_test Ens ens_test
|
external_test Ens ens_test
|
||||||
|
49
test/externalTests/gnosis-v2.sh
Executable file
49
test/externalTests/gnosis-v2.sh
Executable file
@ -0,0 +1,49 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# This file is part of solidity.
|
||||||
|
#
|
||||||
|
# solidity is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# solidity is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with solidity. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
#
|
||||||
|
# (c) 2020 solidity contributors.
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
source scripts/common.sh
|
||||||
|
source test/externalTests/common.sh
|
||||||
|
|
||||||
|
verify_input "$1"
|
||||||
|
SOLJSON="$1"
|
||||||
|
|
||||||
|
function install_fn { npm install --package-lock; }
|
||||||
|
function compile_fn { npx truffle compile; }
|
||||||
|
function test_fn { npm test; }
|
||||||
|
|
||||||
|
function gnosis_safe_test
|
||||||
|
{
|
||||||
|
OPTIMIZER_LEVEL=1
|
||||||
|
CONFIG="truffle-config.js"
|
||||||
|
|
||||||
|
truffle_setup "$SOLJSON" https://github.com/solidity-external-tests/safe-contracts.git v2_070
|
||||||
|
|
||||||
|
sed -i 's|github:gnosis/mock-contract#sol_0_5_0|github:solidity-external-tests/mock-contract#master_070_new|g' package.json
|
||||||
|
sed -i -E 's|"@gnosis.pm/util-contracts": "[^"]+"|"@gnosis.pm/util-contracts": "github:solidity-external-tests/util-contracts#solc-7"|g' package.json
|
||||||
|
|
||||||
|
# Remove the lock file (if it exists) to prevent it from overriding our changes in package.json
|
||||||
|
rm -f package-lock.json
|
||||||
|
|
||||||
|
run_install "$SOLJSON" install_fn
|
||||||
|
|
||||||
|
truffle_run_test "$SOLJSON" compile_fn test_fn
|
||||||
|
}
|
||||||
|
|
||||||
|
external_test Gnosis-Safe gnosis_safe_test
|
@ -31,19 +31,18 @@ function test_fn { npm test; }
|
|||||||
function gnosis_safe_test
|
function gnosis_safe_test
|
||||||
{
|
{
|
||||||
OPTIMIZER_LEVEL=1
|
OPTIMIZER_LEVEL=1
|
||||||
CONFIG="truffle.js"
|
CONFIG="truffle-config.js"
|
||||||
|
|
||||||
truffle_setup "$SOLJSON" https://github.com/solidity-external-tests/safe-contracts.git development_080
|
truffle_setup "$SOLJSON" https://github.com/solidity-external-tests/safe-contracts.git development_070_new
|
||||||
|
|
||||||
force_truffle_version ^5.0.42
|
sed -i 's|github:gnosis/mock-contract#sol_0_5_0|github:solidity-external-tests/mock-contract#master_070_new|g' package.json
|
||||||
sed -i 's|github:gnosis/mock-contract#sol_0_5_0|github:solidity-external-tests/mock-contract#master_080|g' package.json
|
|
||||||
|
# Remove the lock file (if it exists) to prevent it from overriding our changes in package.json
|
||||||
rm -f package-lock.json
|
rm -f package-lock.json
|
||||||
rm -rf node_modules/
|
|
||||||
|
|
||||||
run_install "$SOLJSON" install_fn
|
run_install "$SOLJSON" install_fn
|
||||||
replace_libsolc_call
|
|
||||||
|
|
||||||
truffle_run_test "$SOLJSON" compile_fn test_fn "NO-FORCE-ABI-V2"
|
truffle_run_test "$SOLJSON" compile_fn test_fn
|
||||||
}
|
}
|
||||||
|
|
||||||
external_test Gnosis-Safe gnosis_safe_test
|
external_test Gnosis-Safe gnosis_safe_test
|
||||||
|
@ -33,10 +33,10 @@ function zeppelin_test
|
|||||||
OPTIMIZER_LEVEL=1
|
OPTIMIZER_LEVEL=1
|
||||||
CONFIG="truffle-config.js"
|
CONFIG="truffle-config.js"
|
||||||
|
|
||||||
truffle_setup "$SOLJSON" https://github.com/solidity-external-tests/openzeppelin-contracts.git upgrade-0.8.0
|
truffle_setup "$SOLJSON" https://github.com/solidity-external-tests/openzeppelin-contracts.git master_070
|
||||||
run_install "$SOLJSON" install_fn
|
run_install "$SOLJSON" install_fn
|
||||||
|
|
||||||
truffle_run_test "$SOLJSON" compile_fn test_fn "NO-FORCE-ABI-V2"
|
truffle_run_test "$SOLJSON" compile_fn test_fn
|
||||||
}
|
}
|
||||||
|
|
||||||
external_test Zeppelin zeppelin_test
|
external_test Zeppelin zeppelin_test
|
||||||
|
@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE(value_types)
|
|||||||
compileAndRun(sourceCode);
|
compileAndRun(sourceCode);
|
||||||
ABI_CHECK(callContractFunction(
|
ABI_CHECK(callContractFunction(
|
||||||
"f(uint256,uint16,uint24,int24,bytes3,bool,address)",
|
"f(uint256,uint16,uint24,int24,bytes3,bool,address)",
|
||||||
1, 2, 3, 4, string("abc"), true, u160(m_contractAddress)
|
1, 2, 3, 4, string("abc"), true, m_contractAddress
|
||||||
), encodeArgs(u256(20)));
|
), encodeArgs(u256(20)));
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -408,7 +408,7 @@ BOOST_AUTO_TEST_CASE(complex_struct)
|
|||||||
0x40,
|
0x40,
|
||||||
0x100,
|
0x100,
|
||||||
// S s1[0]
|
// S s1[0]
|
||||||
u256(u160(m_contractAddress)),
|
m_contractAddress,
|
||||||
0x40,
|
0x40,
|
||||||
// T s1[0].t
|
// T s1[0].t
|
||||||
1, // length
|
1, // length
|
||||||
@ -431,7 +431,7 @@ BOOST_AUTO_TEST_CASE(complex_struct)
|
|||||||
0x21, 2, 0x22,
|
0x21, 2, 0x22,
|
||||||
0, 0, 0
|
0, 0, 0
|
||||||
);
|
);
|
||||||
ABI_CHECK(callContractFunction(sig, args), encodeArgs(7, u256(u160(m_contractAddress)), 8, 2, 0x1234, 3, 2, 0x22));
|
ABI_CHECK(callContractFunction(sig, args), encodeArgs(7, m_contractAddress, 8, 2, 0x1234, 3, 2, 0x22));
|
||||||
// invalid enum value
|
// invalid enum value
|
||||||
args.data()[0x20 * 28] = 3;
|
args.data()[0x20 * 28] = 3;
|
||||||
ABI_CHECK(callContractFunction(sig, args), encodeArgs());
|
ABI_CHECK(callContractFunction(sig, args), encodeArgs());
|
||||||
|
@ -78,7 +78,7 @@ BOOST_AUTO_TEST_CASE(value_types)
|
|||||||
compileAndRun(sourceCode);
|
compileAndRun(sourceCode);
|
||||||
callContractFunction("f()");
|
callContractFunction("f()");
|
||||||
REQUIRE_LOG_DATA(encodeArgs(
|
REQUIRE_LOG_DATA(encodeArgs(
|
||||||
10, u256(65534), u256(0x121212), u256(-1), string("\x1b\xab\xab"), true, u160(u256(-5))
|
10, u256(65534), u256(0x121212), u256(-1), string("\x1b\xab\xab"), true, h160("fffffffffffffffffffffffffffffffffffffffb")
|
||||||
));
|
));
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -273,7 +273,11 @@ BOOST_AUTO_TEST_CASE(storage_array)
|
|||||||
BOTH_ENCODERS(
|
BOTH_ENCODERS(
|
||||||
compileAndRun(sourceCode);
|
compileAndRun(sourceCode);
|
||||||
callContractFunction("f()");
|
callContractFunction("f()");
|
||||||
REQUIRE_LOG_DATA(encodeArgs(u160(-1), u160(-2), u160(-3)));
|
REQUIRE_LOG_DATA(encodeArgs(
|
||||||
|
h160("ffffffffffffffffffffffffffffffffffffffff"),
|
||||||
|
h160("fffffffffffffffffffffffffffffffffffffffe"),
|
||||||
|
h160("fffffffffffffffffffffffffffffffffffffffd")
|
||||||
|
));
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,7 +298,13 @@ BOOST_AUTO_TEST_CASE(storage_array_dyn)
|
|||||||
BOTH_ENCODERS(
|
BOTH_ENCODERS(
|
||||||
compileAndRun(sourceCode);
|
compileAndRun(sourceCode);
|
||||||
callContractFunction("f()");
|
callContractFunction("f()");
|
||||||
REQUIRE_LOG_DATA(encodeArgs(0x20, 3, u160(1), u160(2), u160(3)));
|
REQUIRE_LOG_DATA(encodeArgs(
|
||||||
|
0x20,
|
||||||
|
3,
|
||||||
|
h160("0000000000000000000000000000000000000001"),
|
||||||
|
h160("0000000000000000000000000000000000000002"),
|
||||||
|
h160("0000000000000000000000000000000000000003")
|
||||||
|
));
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -488,7 +498,7 @@ BOOST_AUTO_TEST_CASE(structs2)
|
|||||||
0x40,
|
0x40,
|
||||||
0x100,
|
0x100,
|
||||||
// S s1[0]
|
// S s1[0]
|
||||||
u256(u160(m_contractAddress)),
|
m_contractAddress,
|
||||||
0x40,
|
0x40,
|
||||||
// T s1[0].t
|
// T s1[0].t
|
||||||
1, // length
|
1, // length
|
||||||
|
@ -832,7 +832,7 @@ BOOST_AUTO_TEST_CASE(blockchain)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
m_evmcHost->tx_context.block_coinbase = EVMHost::convertToEVMC(Address("0x1212121212121212121212121212121212121212"));
|
m_evmcHost->tx_context.block_coinbase = EVMHost::convertToEVMC(h160("0x1212121212121212121212121212121212121212"));
|
||||||
m_evmcHost->newBlock();
|
m_evmcHost->newBlock();
|
||||||
m_evmcHost->newBlock();
|
m_evmcHost->newBlock();
|
||||||
m_evmcHost->newBlock();
|
m_evmcHost->newBlock();
|
||||||
@ -858,7 +858,7 @@ BOOST_AUTO_TEST_CASE(send_ether)
|
|||||||
|
|
||||||
u256 amount(250);
|
u256 amount(250);
|
||||||
compileAndRun(sourceCode, amount + 1);
|
compileAndRun(sourceCode, amount + 1);
|
||||||
u160 address(23);
|
h160 address(23);
|
||||||
ABI_CHECK(callContractFunction("a(address,uint256)", address, amount), encodeArgs(1));
|
ABI_CHECK(callContractFunction("a(address,uint256)", address, amount), encodeArgs(1));
|
||||||
BOOST_CHECK_EQUAL(balanceAt(address), amount);
|
BOOST_CHECK_EQUAL(balanceAt(address), amount);
|
||||||
)
|
)
|
||||||
@ -891,11 +891,11 @@ BOOST_AUTO_TEST_CASE(transfer_ether)
|
|||||||
DISABLE_EWASM_TESTRUN()
|
DISABLE_EWASM_TESTRUN()
|
||||||
|
|
||||||
compileAndRun(sourceCode, 0, "B");
|
compileAndRun(sourceCode, 0, "B");
|
||||||
u160 const nonPayableRecipient = m_contractAddress;
|
h160 const nonPayableRecipient = m_contractAddress;
|
||||||
compileAndRun(sourceCode, 0, "C");
|
compileAndRun(sourceCode, 0, "C");
|
||||||
u160 const oogRecipient = m_contractAddress;
|
h160 const oogRecipient = m_contractAddress;
|
||||||
compileAndRun(sourceCode, 20, "A");
|
compileAndRun(sourceCode, 20, "A");
|
||||||
u160 payableRecipient(23);
|
h160 payableRecipient(23);
|
||||||
ABI_CHECK(callContractFunction("a(address,uint256)", payableRecipient, 10), encodeArgs(10));
|
ABI_CHECK(callContractFunction("a(address,uint256)", payableRecipient, 10), encodeArgs(10));
|
||||||
BOOST_CHECK_EQUAL(balanceAt(payableRecipient), 10);
|
BOOST_CHECK_EQUAL(balanceAt(payableRecipient), 10);
|
||||||
BOOST_CHECK_EQUAL(balanceAt(m_contractAddress), 10);
|
BOOST_CHECK_EQUAL(balanceAt(m_contractAddress), 10);
|
||||||
@ -935,7 +935,7 @@ BOOST_AUTO_TEST_CASE(selfdestruct)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
u256 amount(130);
|
u256 amount(130);
|
||||||
u160 address(23);
|
h160 address(23);
|
||||||
ALSO_VIA_YUL(
|
ALSO_VIA_YUL(
|
||||||
DISABLE_EWASM_TESTRUN()
|
DISABLE_EWASM_TESTRUN()
|
||||||
|
|
||||||
@ -1164,7 +1164,7 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode, 0, "Helper");
|
compileAndRun(sourceCode, 0, "Helper");
|
||||||
u160 const c_helperAddress = m_contractAddress;
|
h160 const c_helperAddress = m_contractAddress;
|
||||||
compileAndRun(sourceCode, 0, "Main");
|
compileAndRun(sourceCode, 0, "Main");
|
||||||
BOOST_REQUIRE(callContractFunction("setHelper(address)", c_helperAddress) == bytes());
|
BOOST_REQUIRE(callContractFunction("setHelper(address)", c_helperAddress) == bytes());
|
||||||
BOOST_REQUIRE(callContractFunction("getHelper()", c_helperAddress) == encodeArgs(c_helperAddress));
|
BOOST_REQUIRE(callContractFunction("getHelper()", c_helperAddress) == encodeArgs(c_helperAddress));
|
||||||
@ -1195,7 +1195,7 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls_with_complex_parameters)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode, 0, "Helper");
|
compileAndRun(sourceCode, 0, "Helper");
|
||||||
u160 const c_helperAddress = m_contractAddress;
|
h160 const c_helperAddress = m_contractAddress;
|
||||||
compileAndRun(sourceCode, 0, "Main");
|
compileAndRun(sourceCode, 0, "Main");
|
||||||
BOOST_REQUIRE(callContractFunction("setHelper(address)", c_helperAddress) == bytes());
|
BOOST_REQUIRE(callContractFunction("setHelper(address)", c_helperAddress) == bytes());
|
||||||
BOOST_REQUIRE(callContractFunction("getHelper()", c_helperAddress) == encodeArgs(c_helperAddress));
|
BOOST_REQUIRE(callContractFunction("getHelper()", c_helperAddress) == encodeArgs(c_helperAddress));
|
||||||
@ -1227,7 +1227,7 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls_accessing_this)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode, 0, "Helper");
|
compileAndRun(sourceCode, 0, "Helper");
|
||||||
u160 const c_helperAddress = m_contractAddress;
|
h160 const c_helperAddress = m_contractAddress;
|
||||||
compileAndRun(sourceCode, 0, "Main");
|
compileAndRun(sourceCode, 0, "Main");
|
||||||
BOOST_REQUIRE(callContractFunction("setHelper(address)", c_helperAddress) == bytes());
|
BOOST_REQUIRE(callContractFunction("setHelper(address)", c_helperAddress) == bytes());
|
||||||
BOOST_REQUIRE(callContractFunction("getHelper()", c_helperAddress) == encodeArgs(c_helperAddress));
|
BOOST_REQUIRE(callContractFunction("getHelper()", c_helperAddress) == encodeArgs(c_helperAddress));
|
||||||
@ -1259,7 +1259,7 @@ BOOST_AUTO_TEST_CASE(calls_to_this)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode, 0, "Helper");
|
compileAndRun(sourceCode, 0, "Helper");
|
||||||
u160 const c_helperAddress = m_contractAddress;
|
h160 const c_helperAddress = m_contractAddress;
|
||||||
compileAndRun(sourceCode, 0, "Main");
|
compileAndRun(sourceCode, 0, "Main");
|
||||||
BOOST_REQUIRE(callContractFunction("setHelper(address)", c_helperAddress) == bytes());
|
BOOST_REQUIRE(callContractFunction("setHelper(address)", c_helperAddress) == bytes());
|
||||||
BOOST_REQUIRE(callContractFunction("getHelper()", c_helperAddress) == encodeArgs(c_helperAddress));
|
BOOST_REQUIRE(callContractFunction("getHelper()", c_helperAddress) == encodeArgs(c_helperAddress));
|
||||||
@ -1294,7 +1294,7 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls_with_local_vars)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode, 0, "Helper");
|
compileAndRun(sourceCode, 0, "Helper");
|
||||||
u160 const c_helperAddress = m_contractAddress;
|
h160 const c_helperAddress = m_contractAddress;
|
||||||
compileAndRun(sourceCode, 0, "Main");
|
compileAndRun(sourceCode, 0, "Main");
|
||||||
BOOST_REQUIRE(callContractFunction("setHelper(address)", c_helperAddress) == bytes());
|
BOOST_REQUIRE(callContractFunction("setHelper(address)", c_helperAddress) == bytes());
|
||||||
BOOST_REQUIRE(callContractFunction("getHelper()", c_helperAddress) == encodeArgs(c_helperAddress));
|
BOOST_REQUIRE(callContractFunction("getHelper()", c_helperAddress) == encodeArgs(c_helperAddress));
|
||||||
@ -1325,7 +1325,7 @@ BOOST_AUTO_TEST_CASE(fixed_bytes_in_calls)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode, 0, "Helper");
|
compileAndRun(sourceCode, 0, "Helper");
|
||||||
u160 const c_helperAddress = m_contractAddress;
|
h160 const c_helperAddress = m_contractAddress;
|
||||||
compileAndRun(sourceCode, 0, "Main");
|
compileAndRun(sourceCode, 0, "Main");
|
||||||
BOOST_REQUIRE(callContractFunction("setHelper(address)", c_helperAddress) == bytes());
|
BOOST_REQUIRE(callContractFunction("setHelper(address)", c_helperAddress) == bytes());
|
||||||
BOOST_REQUIRE(callContractFunction("getHelper()", c_helperAddress) == encodeArgs(c_helperAddress));
|
BOOST_REQUIRE(callContractFunction("getHelper()", c_helperAddress) == encodeArgs(c_helperAddress));
|
||||||
@ -1656,7 +1656,7 @@ BOOST_AUTO_TEST_CASE(events_with_same_name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
u160 const c_loggedAddress = m_contractAddress;
|
h160 const c_loggedAddress = m_contractAddress;
|
||||||
|
|
||||||
ALSO_VIA_YUL(
|
ALSO_VIA_YUL(
|
||||||
DISABLE_EWASM_TESTRUN()
|
DISABLE_EWASM_TESTRUN()
|
||||||
@ -1719,7 +1719,7 @@ BOOST_AUTO_TEST_CASE(events_with_same_name_inherited_emit)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
u160 const c_loggedAddress = m_contractAddress;
|
h160 const c_loggedAddress = m_contractAddress;
|
||||||
|
|
||||||
ALSO_VIA_YUL(
|
ALSO_VIA_YUL(
|
||||||
DISABLE_EWASM_TESTRUN()
|
DISABLE_EWASM_TESTRUN()
|
||||||
@ -1814,7 +1814,7 @@ BOOST_AUTO_TEST_CASE(event_lots_of_data)
|
|||||||
callContractFunctionWithValue("deposit(bytes32)", value, id);
|
callContractFunctionWithValue("deposit(bytes32)", value, id);
|
||||||
BOOST_REQUIRE_EQUAL(numLogs(), 1);
|
BOOST_REQUIRE_EQUAL(numLogs(), 1);
|
||||||
BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress);
|
BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress);
|
||||||
BOOST_CHECK(logData(0) == encodeArgs((u160)m_sender, id, value, true));
|
BOOST_CHECK(logData(0) == encodeArgs(m_sender, id, value, true));
|
||||||
BOOST_REQUIRE_EQUAL(numLogTopics(0), 1);
|
BOOST_REQUIRE_EQUAL(numLogTopics(0), 1);
|
||||||
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Deposit(address,bytes32,uint256,bool)")));
|
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Deposit(address,bytes32,uint256,bool)")));
|
||||||
)
|
)
|
||||||
@ -2207,7 +2207,7 @@ BOOST_AUTO_TEST_CASE(generic_call)
|
|||||||
}
|
}
|
||||||
)**";
|
)**";
|
||||||
compileAndRun(sourceCode, 0, "receiver");
|
compileAndRun(sourceCode, 0, "receiver");
|
||||||
u160 const c_receiverAddress = m_contractAddress;
|
h160 const c_receiverAddress = m_contractAddress;
|
||||||
compileAndRun(sourceCode, 50, "sender");
|
compileAndRun(sourceCode, 50, "sender");
|
||||||
BOOST_REQUIRE(callContractFunction("doSend(address)", c_receiverAddress) == encodeArgs(23));
|
BOOST_REQUIRE(callContractFunction("doSend(address)", c_receiverAddress) == encodeArgs(23));
|
||||||
BOOST_CHECK_EQUAL(balanceAt(m_contractAddress), 50 - 2);
|
BOOST_CHECK_EQUAL(balanceAt(m_contractAddress), 50 - 2);
|
||||||
@ -2242,13 +2242,13 @@ BOOST_AUTO_TEST_CASE(generic_delegatecall)
|
|||||||
string source = "pragma abicoder " + string(v2 ? "v2" : "v1") + ";\n" + string(sourceCode);
|
string source = "pragma abicoder " + string(v2 ? "v2" : "v1") + ";\n" + string(sourceCode);
|
||||||
|
|
||||||
compileAndRun(source, 0, "Receiver");
|
compileAndRun(source, 0, "Receiver");
|
||||||
u160 const c_receiverAddress = m_contractAddress;
|
h160 const c_receiverAddress = m_contractAddress;
|
||||||
compileAndRun(source, 50, "Sender");
|
compileAndRun(source, 50, "Sender");
|
||||||
u160 const c_senderAddress = m_contractAddress;
|
h160 const c_senderAddress = m_contractAddress;
|
||||||
BOOST_CHECK(m_sender != c_senderAddress); // just for sanity
|
BOOST_CHECK(m_sender != c_senderAddress); // just for sanity
|
||||||
ABI_CHECK(callContractFunctionWithValue("doSend(address)", 11, c_receiverAddress), encodeArgs());
|
ABI_CHECK(callContractFunctionWithValue("doSend(address)", 11, c_receiverAddress), encodeArgs());
|
||||||
ABI_CHECK(callContractFunction("received()"), encodeArgs(u256(23)));
|
ABI_CHECK(callContractFunction("received()"), encodeArgs(u256(23)));
|
||||||
ABI_CHECK(callContractFunction("sender()"), encodeArgs(u160(m_sender)));
|
ABI_CHECK(callContractFunction("sender()"), encodeArgs(m_sender));
|
||||||
ABI_CHECK(callContractFunction("value()"), encodeArgs(u256(11)));
|
ABI_CHECK(callContractFunction("value()"), encodeArgs(u256(11)));
|
||||||
m_contractAddress = c_receiverAddress;
|
m_contractAddress = c_receiverAddress;
|
||||||
ABI_CHECK(callContractFunction("received()"), encodeArgs(u256(0)));
|
ABI_CHECK(callContractFunction("received()"), encodeArgs(u256(0)));
|
||||||
@ -2294,7 +2294,7 @@ BOOST_AUTO_TEST_CASE(generic_staticcall)
|
|||||||
}
|
}
|
||||||
)**";
|
)**";
|
||||||
compileAndRun(sourceCode, 0, "A");
|
compileAndRun(sourceCode, 0, "A");
|
||||||
u160 const c_addressA = m_contractAddress;
|
h160 const c_addressA = m_contractAddress;
|
||||||
compileAndRun(sourceCode, 0, "C");
|
compileAndRun(sourceCode, 0, "C");
|
||||||
ABI_CHECK(callContractFunction("f(address)", c_addressA), encodeArgs(true, 0x40, 0x20, 23));
|
ABI_CHECK(callContractFunction("f(address)", c_addressA), encodeArgs(true, 0x40, 0x20, 23));
|
||||||
ABI_CHECK(callContractFunction("g(address)", c_addressA), encodeArgs(true, 0x40, 0x20, 23 + 42));
|
ABI_CHECK(callContractFunction("g(address)", c_addressA), encodeArgs(true, 0x40, 0x20, 23 + 42));
|
||||||
@ -2316,9 +2316,9 @@ BOOST_AUTO_TEST_CASE(library_call_in_homestead)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode, 0, "Lib");
|
compileAndRun(sourceCode, 0, "Lib");
|
||||||
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, Address>{{"Lib", m_contractAddress}});
|
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, h160>{{"Lib", m_contractAddress}});
|
||||||
ABI_CHECK(callContractFunction("f()"), encodeArgs());
|
ABI_CHECK(callContractFunction("f()"), encodeArgs());
|
||||||
ABI_CHECK(callContractFunction("sender()"), encodeArgs(u160(m_sender)));
|
ABI_CHECK(callContractFunction("sender()"), encodeArgs(m_sender));
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(library_call_protection)
|
BOOST_AUTO_TEST_CASE(library_call_protection)
|
||||||
@ -2344,13 +2344,13 @@ BOOST_AUTO_TEST_CASE(library_call_protection)
|
|||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode, 0, "Lib");
|
compileAndRun(sourceCode, 0, "Lib");
|
||||||
ABI_CHECK(callContractFunction("np(Lib.S storage)", 0), encodeArgs());
|
ABI_CHECK(callContractFunction("np(Lib.S storage)", 0), encodeArgs());
|
||||||
ABI_CHECK(callContractFunction("v(Lib.S storage)", 0), encodeArgs(u160(m_sender)));
|
ABI_CHECK(callContractFunction("v(Lib.S storage)", 0), encodeArgs(m_sender));
|
||||||
ABI_CHECK(callContractFunction("pu()"), encodeArgs(2));
|
ABI_CHECK(callContractFunction("pu()"), encodeArgs(2));
|
||||||
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, Address>{{"Lib", m_contractAddress}});
|
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, h160>{{"Lib", m_contractAddress}});
|
||||||
ABI_CHECK(callContractFunction("s()"), encodeArgs(0));
|
ABI_CHECK(callContractFunction("s()"), encodeArgs(0));
|
||||||
ABI_CHECK(callContractFunction("np()"), encodeArgs(u160(m_sender)));
|
ABI_CHECK(callContractFunction("np()"), encodeArgs(m_sender));
|
||||||
ABI_CHECK(callContractFunction("s()"), encodeArgs(3));
|
ABI_CHECK(callContractFunction("s()"), encodeArgs(3));
|
||||||
ABI_CHECK(callContractFunction("v()"), encodeArgs(u160(m_sender)));
|
ABI_CHECK(callContractFunction("v()"), encodeArgs(m_sender));
|
||||||
ABI_CHECK(callContractFunction("pu()"), encodeArgs(2));
|
ABI_CHECK(callContractFunction("pu()"), encodeArgs(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2374,7 +2374,7 @@ BOOST_AUTO_TEST_CASE(library_staticcall_delegatecall)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode, 0, "Lib");
|
compileAndRun(sourceCode, 0, "Lib");
|
||||||
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, Address>{{"Lib", m_contractAddress}});
|
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, h160>{{"Lib", m_contractAddress}});
|
||||||
ABI_CHECK(callContractFunction("f()"), encodeArgs(1));
|
ABI_CHECK(callContractFunction("f()"), encodeArgs(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2616,7 +2616,7 @@ BOOST_AUTO_TEST_CASE(struct_referencing)
|
|||||||
compileAndRun(sourceCode, 0, "L");
|
compileAndRun(sourceCode, 0, "L");
|
||||||
ABI_CHECK(callContractFunction("f()"), encodeArgs(0, 3));
|
ABI_CHECK(callContractFunction("f()"), encodeArgs(0, 3));
|
||||||
ABI_CHECK(callContractFunction("g()"), encodeArgs(4));
|
ABI_CHECK(callContractFunction("g()"), encodeArgs(4));
|
||||||
compileAndRun(sourceCode, 0, "C", bytes(), map<string, Address>{ {"L", m_contractAddress}});
|
compileAndRun(sourceCode, 0, "C", bytes(), map<string, h160>{ {"L", m_contractAddress}});
|
||||||
ABI_CHECK(callContractFunction("f()"), encodeArgs(1));
|
ABI_CHECK(callContractFunction("f()"), encodeArgs(1));
|
||||||
ABI_CHECK(callContractFunction("g()"), encodeArgs(2));
|
ABI_CHECK(callContractFunction("g()"), encodeArgs(2));
|
||||||
ABI_CHECK(callContractFunction("h()"), encodeArgs(0, 5));
|
ABI_CHECK(callContractFunction("h()"), encodeArgs(0, 5));
|
||||||
@ -2662,7 +2662,7 @@ BOOST_AUTO_TEST_CASE(enum_referencing)
|
|||||||
compileAndRun(sourceCode, 0, "L");
|
compileAndRun(sourceCode, 0, "L");
|
||||||
ABI_CHECK(callContractFunction("f()"), encodeArgs(1));
|
ABI_CHECK(callContractFunction("f()"), encodeArgs(1));
|
||||||
ABI_CHECK(callContractFunction("g()"), encodeArgs(3));
|
ABI_CHECK(callContractFunction("g()"), encodeArgs(3));
|
||||||
compileAndRun(sourceCode, 0, "C", bytes(), map<string, Address>{{"L", m_contractAddress}});
|
compileAndRun(sourceCode, 0, "C", bytes(), map<string, h160>{{"L", m_contractAddress}});
|
||||||
ABI_CHECK(callContractFunction("f()"), encodeArgs(3));
|
ABI_CHECK(callContractFunction("f()"), encodeArgs(3));
|
||||||
ABI_CHECK(callContractFunction("g()"), encodeArgs(3));
|
ABI_CHECK(callContractFunction("g()"), encodeArgs(3));
|
||||||
ABI_CHECK(callContractFunction("h()"), encodeArgs(1));
|
ABI_CHECK(callContractFunction("h()"), encodeArgs(1));
|
||||||
@ -2888,7 +2888,7 @@ BOOST_AUTO_TEST_CASE(failing_send)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode, 0, "Helper");
|
compileAndRun(sourceCode, 0, "Helper");
|
||||||
u160 const c_helperAddress = m_contractAddress;
|
h160 const c_helperAddress = m_contractAddress;
|
||||||
compileAndRun(sourceCode, 20, "Main");
|
compileAndRun(sourceCode, 20, "Main");
|
||||||
BOOST_REQUIRE(callContractFunction("callHelper(address)", c_helperAddress) == encodeArgs(true, 20));
|
BOOST_REQUIRE(callContractFunction("callHelper(address)", c_helperAddress) == encodeArgs(true, 20));
|
||||||
}
|
}
|
||||||
@ -3490,7 +3490,7 @@ BOOST_AUTO_TEST_CASE(library_call)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode, 0, "Lib");
|
compileAndRun(sourceCode, 0, "Lib");
|
||||||
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, Address>{{"Lib", m_contractAddress}});
|
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, h160>{{"Lib", m_contractAddress}});
|
||||||
ABI_CHECK(callContractFunction("f(uint256)", u256(33)), encodeArgs(u256(33) * 9));
|
ABI_CHECK(callContractFunction("f(uint256)", u256(33)), encodeArgs(u256(33) * 9));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3505,7 +3505,7 @@ BOOST_AUTO_TEST_CASE(library_function_external)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode, 0, "Lib");
|
compileAndRun(sourceCode, 0, "Lib");
|
||||||
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, Address>{{"Lib", m_contractAddress}});
|
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, h160>{{"Lib", m_contractAddress}});
|
||||||
ABI_CHECK(callContractFunction("f(bytes)", u256(0x20), u256(5), "abcde"), encodeArgs("c"));
|
ABI_CHECK(callContractFunction("f(bytes)", u256(0x20), u256(5), "abcde"), encodeArgs("c"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3522,7 +3522,7 @@ BOOST_AUTO_TEST_CASE(library_stray_values)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode, 0, "Lib");
|
compileAndRun(sourceCode, 0, "Lib");
|
||||||
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, Address>{{"Lib", m_contractAddress}});
|
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, h160>{{"Lib", m_contractAddress}});
|
||||||
ABI_CHECK(callContractFunction("f(uint256)", u256(33)), encodeArgs(u256(42)));
|
ABI_CHECK(callContractFunction("f(uint256)", u256(33)), encodeArgs(u256(42)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3552,7 +3552,7 @@ BOOST_AUTO_TEST_CASE(internal_types_in_library)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode, 0, "Lib");
|
compileAndRun(sourceCode, 0, "Lib");
|
||||||
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, Address>{{"Lib", m_contractAddress}});
|
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, h160>{{"Lib", m_contractAddress}});
|
||||||
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(4), u256(17)));
|
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(4), u256(17)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3583,7 +3583,7 @@ BOOST_AUTO_TEST_CASE(mapping_arguments_in_library)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode, 0, "Lib");
|
compileAndRun(sourceCode, 0, "Lib");
|
||||||
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, Address>{{"Lib", m_contractAddress}});
|
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, h160>{{"Lib", m_contractAddress}});
|
||||||
ABI_CHECK(callContractFunction("set(uint256,uint256)", u256(1), u256(42)), encodeArgs(u256(0)));
|
ABI_CHECK(callContractFunction("set(uint256,uint256)", u256(1), u256(42)), encodeArgs(u256(0)));
|
||||||
ABI_CHECK(callContractFunction("set(uint256,uint256)", u256(2), u256(84)), encodeArgs(u256(0)));
|
ABI_CHECK(callContractFunction("set(uint256,uint256)", u256(2), u256(84)), encodeArgs(u256(0)));
|
||||||
ABI_CHECK(callContractFunction("set(uint256,uint256)", u256(21), u256(7)), encodeArgs(u256(0)));
|
ABI_CHECK(callContractFunction("set(uint256,uint256)", u256(21), u256(7)), encodeArgs(u256(0)));
|
||||||
@ -3631,7 +3631,7 @@ BOOST_AUTO_TEST_CASE(mapping_returns_in_library)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode, 0, "Lib");
|
compileAndRun(sourceCode, 0, "Lib");
|
||||||
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, Address>{{"Lib", m_contractAddress}});
|
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, h160>{{"Lib", m_contractAddress}});
|
||||||
ABI_CHECK(callContractFunction("set(bool,uint256,uint256)", true, u256(1), u256(42)), encodeArgs(u256(0)));
|
ABI_CHECK(callContractFunction("set(bool,uint256,uint256)", true, u256(1), u256(42)), encodeArgs(u256(0)));
|
||||||
ABI_CHECK(callContractFunction("set(bool,uint256,uint256)", true, u256(2), u256(84)), encodeArgs(u256(0)));
|
ABI_CHECK(callContractFunction("set(bool,uint256,uint256)", true, u256(2), u256(84)), encodeArgs(u256(0)));
|
||||||
ABI_CHECK(callContractFunction("set(bool,uint256,uint256)", true, u256(21), u256(7)), encodeArgs(u256(0)));
|
ABI_CHECK(callContractFunction("set(bool,uint256,uint256)", true, u256(21), u256(7)), encodeArgs(u256(0)));
|
||||||
@ -3707,7 +3707,7 @@ BOOST_AUTO_TEST_CASE(mapping_returns_in_library_named)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode, 0, "Lib");
|
compileAndRun(sourceCode, 0, "Lib");
|
||||||
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, Address>{{"Lib", m_contractAddress}});
|
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, h160>{{"Lib", m_contractAddress}});
|
||||||
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(0), u256(42), u256(0), u256(0), u256(21), u256(84)));
|
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(0), u256(42), u256(0), u256(0), u256(21), u256(84)));
|
||||||
ABI_CHECK(callContractFunction("g()"), encodeArgs(u256(0), u256(42), u256(0), u256(0), u256(21), u256(17)));
|
ABI_CHECK(callContractFunction("g()"), encodeArgs(u256(0), u256(42), u256(0), u256(0), u256(21), u256(17)));
|
||||||
}
|
}
|
||||||
@ -3735,7 +3735,7 @@ BOOST_AUTO_TEST_CASE(using_library_mappings_public)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode, 0, "Lib");
|
compileAndRun(sourceCode, 0, "Lib");
|
||||||
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, Address>{{"Lib", m_contractAddress}});
|
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, h160>{{"Lib", m_contractAddress}});
|
||||||
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(1), u256(0), u256(42), u256(23), u256(0), u256(99)));
|
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(1), u256(0), u256(42), u256(23), u256(0), u256(99)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3770,7 +3770,7 @@ BOOST_AUTO_TEST_CASE(using_library_mappings_external)
|
|||||||
{
|
{
|
||||||
string prefix = "pragma abicoder " + string(v2 ? "v2" : "v1") + ";\n";
|
string prefix = "pragma abicoder " + string(v2 ? "v2" : "v1") + ";\n";
|
||||||
compileAndRun(prefix + libSourceCode, 0, "Lib");
|
compileAndRun(prefix + libSourceCode, 0, "Lib");
|
||||||
compileAndRun(prefix + sourceCode, 0, "Test", bytes(), map<string, Address>{{"Lib", m_contractAddress}});
|
compileAndRun(prefix + sourceCode, 0, "Test", bytes(), map<string, h160>{{"Lib", m_contractAddress}});
|
||||||
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(2), u256(0), u256(84), u256(46), u256(0), u256(198)));
|
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(2), u256(0), u256(84), u256(46), u256(0), u256(198)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3796,7 +3796,7 @@ BOOST_AUTO_TEST_CASE(using_library_mappings_return)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode, 0, "Lib");
|
compileAndRun(sourceCode, 0, "Lib");
|
||||||
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, Address>{{"Lib", m_contractAddress}});
|
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, h160>{{"Lib", m_contractAddress}});
|
||||||
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(1), u256(0), u256(42), u256(23), u256(0), u256(99)));
|
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(1), u256(0), u256(42), u256(23), u256(0), u256(99)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3824,7 +3824,7 @@ BOOST_AUTO_TEST_CASE(using_library_structs)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode, 0, "Lib");
|
compileAndRun(sourceCode, 0, "Lib");
|
||||||
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, Address>{{"Lib", m_contractAddress}});
|
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, h160>{{"Lib", m_contractAddress}});
|
||||||
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(7), u256(8)));
|
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(7), u256(8)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3982,10 +3982,10 @@ BOOST_AUTO_TEST_CASE(reject_ether_sent_to_library)
|
|||||||
compileAndRun(sourceCode, 10, "c");
|
compileAndRun(sourceCode, 10, "c");
|
||||||
BOOST_CHECK_EQUAL(balanceAt(m_contractAddress), 10);
|
BOOST_CHECK_EQUAL(balanceAt(m_contractAddress), 10);
|
||||||
BOOST_CHECK_EQUAL(balanceAt(libraryAddress), 0);
|
BOOST_CHECK_EQUAL(balanceAt(libraryAddress), 0);
|
||||||
ABI_CHECK(callContractFunction("f(address)", encodeArgs(u160(libraryAddress))), encodeArgs(false));
|
ABI_CHECK(callContractFunction("f(address)", encodeArgs(libraryAddress)), encodeArgs(false));
|
||||||
BOOST_CHECK_EQUAL(balanceAt(m_contractAddress), 10);
|
BOOST_CHECK_EQUAL(balanceAt(m_contractAddress), 10);
|
||||||
BOOST_CHECK_EQUAL(balanceAt(libraryAddress), 0);
|
BOOST_CHECK_EQUAL(balanceAt(libraryAddress), 0);
|
||||||
ABI_CHECK(callContractFunction("f(address)", encodeArgs(u160(m_contractAddress))), encodeArgs(true));
|
ABI_CHECK(callContractFunction("f(address)", encodeArgs(m_contractAddress)), encodeArgs(true));
|
||||||
BOOST_CHECK_EQUAL(balanceAt(m_contractAddress), 10);
|
BOOST_CHECK_EQUAL(balanceAt(m_contractAddress), 10);
|
||||||
BOOST_CHECK_EQUAL(balanceAt(libraryAddress), 0);
|
BOOST_CHECK_EQUAL(balanceAt(libraryAddress), 0);
|
||||||
}
|
}
|
||||||
@ -4029,7 +4029,7 @@ BOOST_AUTO_TEST_CASE(using_for_function_on_int)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode, 0, "D");
|
compileAndRun(sourceCode, 0, "D");
|
||||||
compileAndRun(sourceCode, 0, "C", bytes(), map<string, Address>{{"D", m_contractAddress}});
|
compileAndRun(sourceCode, 0, "C", bytes(), map<string, h160>{{"D", m_contractAddress}});
|
||||||
ABI_CHECK(callContractFunction("f(uint256)", u256(9)), encodeArgs(u256(2 * 9)));
|
ABI_CHECK(callContractFunction("f(uint256)", u256(9)), encodeArgs(u256(2 * 9)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4047,7 +4047,7 @@ BOOST_AUTO_TEST_CASE(using_for_function_on_struct)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode, 0, "D");
|
compileAndRun(sourceCode, 0, "D");
|
||||||
compileAndRun(sourceCode, 0, "C", bytes(), map<string, Address>{{"D", m_contractAddress}});
|
compileAndRun(sourceCode, 0, "C", bytes(), map<string, h160>{{"D", m_contractAddress}});
|
||||||
ABI_CHECK(callContractFunction("f(uint256)", u256(7)), encodeArgs(u256(3 * 7)));
|
ABI_CHECK(callContractFunction("f(uint256)", u256(7)), encodeArgs(u256(3 * 7)));
|
||||||
ABI_CHECK(callContractFunction("x()"), encodeArgs(u256(3 * 7)));
|
ABI_CHECK(callContractFunction("x()"), encodeArgs(u256(3 * 7)));
|
||||||
}
|
}
|
||||||
@ -4070,7 +4070,7 @@ BOOST_AUTO_TEST_CASE(using_for_overload)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode, 0, "D");
|
compileAndRun(sourceCode, 0, "D");
|
||||||
compileAndRun(sourceCode, 0, "C", bytes(), map<string, Address>{{"D", m_contractAddress}});
|
compileAndRun(sourceCode, 0, "C", bytes(), map<string, h160>{{"D", m_contractAddress}});
|
||||||
ABI_CHECK(callContractFunction("f(uint256)", u256(7)), encodeArgs(u256(6 * 7)));
|
ABI_CHECK(callContractFunction("f(uint256)", u256(7)), encodeArgs(u256(6 * 7)));
|
||||||
ABI_CHECK(callContractFunction("x()"), encodeArgs(u256(6 * 7)));
|
ABI_CHECK(callContractFunction("x()"), encodeArgs(u256(6 * 7)));
|
||||||
}
|
}
|
||||||
@ -4089,7 +4089,7 @@ BOOST_AUTO_TEST_CASE(using_for_by_name)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode, 0, "D");
|
compileAndRun(sourceCode, 0, "D");
|
||||||
compileAndRun(sourceCode, 0, "C", bytes(), map<string, Address>{{"D", m_contractAddress}});
|
compileAndRun(sourceCode, 0, "C", bytes(), map<string, h160>{{"D", m_contractAddress}});
|
||||||
ABI_CHECK(callContractFunction("f(uint256)", u256(7)), encodeArgs(u256(6 * 7)));
|
ABI_CHECK(callContractFunction("f(uint256)", u256(7)), encodeArgs(u256(6 * 7)));
|
||||||
ABI_CHECK(callContractFunction("x()"), encodeArgs(u256(6 * 7)));
|
ABI_CHECK(callContractFunction("x()"), encodeArgs(u256(6 * 7)));
|
||||||
}
|
}
|
||||||
@ -4109,7 +4109,7 @@ BOOST_AUTO_TEST_CASE(bound_function_in_function)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode, 0, "L");
|
compileAndRun(sourceCode, 0, "L");
|
||||||
compileAndRun(sourceCode, 0, "C", bytes(), map<string, Address>{{"L", m_contractAddress}});
|
compileAndRun(sourceCode, 0, "C", bytes(), map<string, h160>{{"L", m_contractAddress}});
|
||||||
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(7)));
|
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(7)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4127,7 +4127,7 @@ BOOST_AUTO_TEST_CASE(bound_function_in_var)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode, 0, "D");
|
compileAndRun(sourceCode, 0, "D");
|
||||||
compileAndRun(sourceCode, 0, "C", bytes(), map<string, Address>{{"D", m_contractAddress}});
|
compileAndRun(sourceCode, 0, "C", bytes(), map<string, h160>{{"D", m_contractAddress}});
|
||||||
ABI_CHECK(callContractFunction("f(uint256)", u256(7)), encodeArgs(u256(6 * 7)));
|
ABI_CHECK(callContractFunction("f(uint256)", u256(7)), encodeArgs(u256(6 * 7)));
|
||||||
ABI_CHECK(callContractFunction("x()"), encodeArgs(u256(6 * 7)));
|
ABI_CHECK(callContractFunction("x()"), encodeArgs(u256(6 * 7)));
|
||||||
}
|
}
|
||||||
@ -4150,7 +4150,7 @@ BOOST_AUTO_TEST_CASE(bound_function_to_string)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode, 0, "D");
|
compileAndRun(sourceCode, 0, "D");
|
||||||
compileAndRun(sourceCode, 0, "C", bytes(), map<string, Address>{{"D", m_contractAddress}});
|
compileAndRun(sourceCode, 0, "C", bytes(), map<string, h160>{{"D", m_contractAddress}});
|
||||||
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(3)));
|
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(3)));
|
||||||
ABI_CHECK(callContractFunction("g()"), encodeArgs(u256(3)));
|
ABI_CHECK(callContractFunction("g()"), encodeArgs(u256(3)));
|
||||||
}
|
}
|
||||||
@ -4302,9 +4302,9 @@ BOOST_AUTO_TEST_CASE(mutex)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode, 500, "Fund");
|
compileAndRun(sourceCode, 500, "Fund");
|
||||||
auto fund = m_contractAddress;
|
h160 const fund = m_contractAddress;
|
||||||
BOOST_CHECK_EQUAL(balanceAt(fund), 500);
|
BOOST_CHECK_EQUAL(balanceAt(fund), 500);
|
||||||
compileAndRun(sourceCode, 0, "Attacker", encodeArgs(u160(fund)));
|
compileAndRun(sourceCode, 0, "Attacker", encodeArgs(fund));
|
||||||
ABI_CHECK(callContractFunction("setProtected(bool)", true), encodeArgs());
|
ABI_CHECK(callContractFunction("setProtected(bool)", true), encodeArgs());
|
||||||
ABI_CHECK(callContractFunction("attack()"), encodeArgs());
|
ABI_CHECK(callContractFunction("attack()"), encodeArgs());
|
||||||
BOOST_CHECK_EQUAL(balanceAt(fund), 500);
|
BOOST_CHECK_EQUAL(balanceAt(fund), 500);
|
||||||
@ -4348,7 +4348,7 @@ BOOST_AUTO_TEST_CASE(payable_function_calls_library)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode, 0, "L");
|
compileAndRun(sourceCode, 0, "L");
|
||||||
compileAndRun(sourceCode, 0, "C", bytes(), map<string, Address>{{"L", m_contractAddress}});
|
compileAndRun(sourceCode, 0, "C", bytes(), map<string, h160>{{"L", m_contractAddress}});
|
||||||
ABI_CHECK(callContractFunctionWithValue("f()", 27), encodeArgs(u256(7)));
|
ABI_CHECK(callContractFunctionWithValue("f()", 27), encodeArgs(u256(7)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4400,7 +4400,7 @@ BOOST_AUTO_TEST_CASE(mem_resize_is_not_paid_at_call)
|
|||||||
)";
|
)";
|
||||||
|
|
||||||
compileAndRun(sourceCode, 0, "C");
|
compileAndRun(sourceCode, 0, "C");
|
||||||
u160 cAddr = m_contractAddress;
|
h160 const cAddr = m_contractAddress;
|
||||||
compileAndRun(sourceCode, 0, "D");
|
compileAndRun(sourceCode, 0, "D");
|
||||||
ABI_CHECK(callContractFunction("f(address)", cAddr), encodeArgs(u256(7)));
|
ABI_CHECK(callContractFunction("f(address)", cAddr), encodeArgs(u256(7)));
|
||||||
}
|
}
|
||||||
@ -4814,7 +4814,7 @@ BOOST_AUTO_TEST_CASE(interface_contract)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode, 0, "A");
|
compileAndRun(sourceCode, 0, "A");
|
||||||
u160 const recipient = m_contractAddress;
|
h160 const recipient = m_contractAddress;
|
||||||
compileAndRun(sourceCode, 0, "C");
|
compileAndRun(sourceCode, 0, "C");
|
||||||
ABI_CHECK(callContractFunction("f(address)", recipient), encodeArgs(true));
|
ABI_CHECK(callContractFunction("f(address)", recipient), encodeArgs(true));
|
||||||
}
|
}
|
||||||
@ -5633,7 +5633,7 @@ BOOST_AUTO_TEST_CASE(event_wrong_abi_name)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode, 0, "ClientReceipt", bytes());
|
compileAndRun(sourceCode, 0, "ClientReceipt", bytes());
|
||||||
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, Address>{{"ClientReceipt", m_contractAddress}});
|
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, h160>{{"ClientReceipt", m_contractAddress}});
|
||||||
|
|
||||||
callContractFunction("f()");
|
callContractFunction("f()");
|
||||||
BOOST_REQUIRE_EQUAL(numLogs(), 1);
|
BOOST_REQUIRE_EQUAL(numLogs(), 1);
|
||||||
|
@ -119,8 +119,8 @@ protected:
|
|||||||
u256 m_gasUsedNonOptimized;
|
u256 m_gasUsedNonOptimized;
|
||||||
bytes m_nonOptimizedBytecode;
|
bytes m_nonOptimizedBytecode;
|
||||||
bytes m_optimizedBytecode;
|
bytes m_optimizedBytecode;
|
||||||
Address m_optimizedContract;
|
h160 m_optimizedContract;
|
||||||
Address m_nonOptimizedContract;
|
h160 m_nonOptimizedContract;
|
||||||
};
|
};
|
||||||
|
|
||||||
BOOST_FIXTURE_TEST_SUITE(SolidityOptimizer, OptimizerTestFramework)
|
BOOST_FIXTURE_TEST_SUITE(SolidityOptimizer, OptimizerTestFramework)
|
||||||
|
7
test/libsolidity/syntaxTests/super/super_in_function.sol
Normal file
7
test/libsolidity/syntaxTests/super/super_in_function.sol
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
contract C {
|
||||||
|
}
|
||||||
|
function f() pure {
|
||||||
|
super;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// DeclarationError 7576: (39-44): Undeclared identifier. "super" is not (or not yet) visible at this point.
|
7
test/libsolidity/syntaxTests/super/super_in_library.sol
Normal file
7
test/libsolidity/syntaxTests/super/super_in_library.sol
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
library L {
|
||||||
|
function f() public {
|
||||||
|
(super);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// DeclarationError 7576: (41-46): Undeclared identifier. "super" is not (or not yet) visible at this point.
|
@ -121,7 +121,7 @@ public:
|
|||||||
|
|
||||||
CacheStats gatherStats() const;
|
CacheStats gatherStats() const;
|
||||||
|
|
||||||
std::map<std::string, CacheEntry> const& entries() const { return m_entries; };
|
std::map<std::string, CacheEntry> const& entries() const { return m_entries; }
|
||||||
Program const& program() const { return m_program; }
|
Program const& program() const { return m_program; }
|
||||||
size_t currentRound() const { return m_currentRound; }
|
size_t currentRound() const { return m_currentRound; }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user