mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge branch 'develop' of https://github.com/ethereum/cpp-ethereum into bc-test-fix
This commit is contained in:
commit
0e258248e9
@ -116,7 +116,7 @@ contract multiowned {
|
||||
}
|
||||
|
||||
// Replaces an owner `_from` with another `_to`.
|
||||
function changeOwner(address _from, address _to) onlymanyowners(sha3(msg.data, block.number)) external {
|
||||
function changeOwner(address _from, address _to) onlymanyowners(sha3(msg.data)) external {
|
||||
if (isOwner(_to)) return;
|
||||
uint ownerIndex = m_ownerIndex[uint(_from)];
|
||||
if (ownerIndex == 0) return;
|
||||
@ -128,7 +128,7 @@ contract multiowned {
|
||||
OwnerChanged(_from, _to);
|
||||
}
|
||||
|
||||
function addOwner(address _owner) onlymanyowners(sha3(msg.data, block.number)) external {
|
||||
function addOwner(address _owner) onlymanyowners(sha3(msg.data)) external {
|
||||
if (isOwner(_owner)) return;
|
||||
|
||||
clearPending();
|
||||
@ -142,7 +142,7 @@ contract multiowned {
|
||||
OwnerAdded(_owner);
|
||||
}
|
||||
|
||||
function removeOwner(address _owner) onlymanyowners(sha3(msg.data, block.number)) external {
|
||||
function removeOwner(address _owner) onlymanyowners(sha3(msg.data)) external {
|
||||
uint ownerIndex = m_ownerIndex[uint(_owner)];
|
||||
if (ownerIndex == 0) return;
|
||||
if (m_required > m_numOwners - 1) return;
|
||||
@ -154,7 +154,7 @@ contract multiowned {
|
||||
OwnerRemoved(_owner);
|
||||
}
|
||||
|
||||
function changeRequirement(uint _newRequired) onlymanyowners(sha3(msg.data, block.number)) external {
|
||||
function changeRequirement(uint _newRequired) onlymanyowners(sha3(msg.data)) external {
|
||||
if (_newRequired > m_numOwners) return;
|
||||
m_required = _newRequired;
|
||||
clearPending();
|
||||
@ -275,16 +275,17 @@ contract daylimit is multiowned {
|
||||
|
||||
// METHODS
|
||||
|
||||
// constructor - just records the present day's index.
|
||||
function daylimit() {
|
||||
// constructor - stores initial daily limit and records the present day's index.
|
||||
function daylimit(uint _limit) {
|
||||
m_dailyLimit = _limit;
|
||||
m_lastDay = today();
|
||||
}
|
||||
// (re)sets the daily limit. needs many of the owners to confirm. doesn't alter the amount already spent today.
|
||||
function setDailyLimit(uint _newLimit) onlymanyowners(sha3(msg.data, block.number)) external {
|
||||
function setDailyLimit(uint _newLimit) onlymanyowners(sha3(msg.data)) external {
|
||||
m_dailyLimit = _newLimit;
|
||||
}
|
||||
// (re)sets the daily limit. needs many of the owners to confirm. doesn't alter the amount already spent today.
|
||||
function resetSpentToday() onlymanyowners(sha3(msg.data, block.number)) external {
|
||||
function resetSpentToday() onlymanyowners(sha3(msg.data)) external {
|
||||
m_spentToday = 0;
|
||||
}
|
||||
|
||||
@ -354,12 +355,14 @@ contract Wallet is multisig, multiowned, daylimit {
|
||||
|
||||
// METHODS
|
||||
|
||||
// constructor - just pass on the owner array to the multiowned.
|
||||
function Wallet(address[] _owners, uint _required) multiowned(_owners, _required) {
|
||||
// constructor - just pass on the owner array to the multiowned and
|
||||
// the limit to daylimit
|
||||
function Wallet(address[] _owners, uint _required, uint _daylimit)
|
||||
multiowned(_owners, _required) daylimit(_daylimit) {
|
||||
}
|
||||
|
||||
// kills the contract sending everything to `_to`.
|
||||
function kill(address _to) onlymanyowners(sha3(msg.data, block.number)) external {
|
||||
function kill(address _to) onlymanyowners(sha3(msg.data)) external {
|
||||
suicide(_to);
|
||||
}
|
||||
|
||||
@ -424,7 +427,12 @@ static unique_ptr<bytes> s_compiledWallet;
|
||||
class WalletTestFramework: public ExecutionFramework
|
||||
{
|
||||
protected:
|
||||
void deployWallet(u256 const& _value = 0, vector<u256> const& _owners = vector<u256>{}, u256 _required = 1)
|
||||
void deployWallet(
|
||||
u256 const& _value = 0,
|
||||
vector<u256> const& _owners = vector<u256>{},
|
||||
u256 _required = 1,
|
||||
u256 _dailyLimit = 0
|
||||
)
|
||||
{
|
||||
if (!s_compiledWallet)
|
||||
{
|
||||
@ -434,7 +442,7 @@ protected:
|
||||
ETH_TEST_REQUIRE_NO_THROW(m_compiler.compile(m_optimize, m_optimizeRuns), "Compiling contract failed");
|
||||
s_compiledWallet.reset(new bytes(m_compiler.getBytecode("Wallet")));
|
||||
}
|
||||
bytes args = encodeArgs(u256(0x40), _required, u256(_owners.size()), _owners);
|
||||
bytes args = encodeArgs(u256(0x60), _required, _dailyLimit, u256(_owners.size()), _owners);
|
||||
sendMessage(*s_compiledWallet + args, true, _value);
|
||||
BOOST_REQUIRE(!m_output.empty());
|
||||
}
|
||||
@ -519,7 +527,7 @@ BOOST_AUTO_TEST_CASE(initial_owners)
|
||||
u256("0x0000000000000000000000004c9113886af165b2de069d6e99430647e94a9fff"),
|
||||
u256("0x0000000000000000000000003fb1cd2cd96c6d5c0b5eb3322d807b34482481d4")
|
||||
};
|
||||
deployWallet(0, owners, 4);
|
||||
deployWallet(0, owners, 4, 2);
|
||||
BOOST_CHECK(callContractFunction("m_numOwners()") == encodeArgs(u256(8)));
|
||||
BOOST_CHECK(callContractFunction("isOwner(address)", h256(m_sender, h256::AlignRight)) == encodeArgs(true));
|
||||
for (u256 const& owner: owners)
|
||||
@ -554,7 +562,9 @@ BOOST_AUTO_TEST_CASE(multisig_value_transfer)
|
||||
BOOST_AUTO_TEST_CASE(daylimit)
|
||||
{
|
||||
deployWallet(200);
|
||||
BOOST_REQUIRE(callContractFunction("m_dailyLimit()") == encodeArgs(u256(0)));
|
||||
BOOST_REQUIRE(callContractFunction("setDailyLimit(uint256)", h256(100)) == encodeArgs());
|
||||
BOOST_REQUIRE(callContractFunction("m_dailyLimit()") == encodeArgs(u256(100)));
|
||||
BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(0x12)) == encodeArgs());
|
||||
BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(0x13)) == encodeArgs());
|
||||
BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(0x14)) == encodeArgs());
|
||||
@ -585,6 +595,14 @@ BOOST_AUTO_TEST_CASE(daylimit)
|
||||
BOOST_CHECK_EQUAL(m_state.balance(Address(0x05)), 90);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(daylimit_constructor)
|
||||
{
|
||||
deployWallet(200, {}, 1, 20);
|
||||
BOOST_REQUIRE(callContractFunction("m_dailyLimit()") == encodeArgs(u256(20)));
|
||||
BOOST_REQUIRE(callContractFunction("setDailyLimit(uint256)", h256(30)) == encodeArgs());
|
||||
BOOST_REQUIRE(callContractFunction("m_dailyLimit()") == encodeArgs(u256(30)));
|
||||
}
|
||||
|
||||
//@todo test data calls
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
Loading…
Reference in New Issue
Block a user