solidity/test/contracts/Wallet.cpp

708 lines
25 KiB
C++
Raw Normal View History

2015-06-10 15:37:17 +00:00
/*
This file is part of solidity.
2015-06-10 15:37:17 +00:00
solidity is free software: you can redistribute it and/or modify
2015-06-10 15:37:17 +00:00
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,
2015-06-10 15:37:17 +00:00
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/>.
2015-06-10 15:37:17 +00:00
*/
// SPDX-License-Identifier: GPL-3.0
2015-06-10 15:37:17 +00:00
/**
* @author Christian <c@ethdev.com>
* @date 2015
* Tests for a (comparatively) complex multisig wallet contract.
*/
#include <libsolutil/LazyInit.h>
2015-06-10 15:37:17 +00:00
#include <string>
#include <tuple>
#include <optional>
2016-03-18 08:22:15 +00:00
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4535) // calling _set_se_translator requires /EHa
#endif
2015-06-10 15:37:17 +00:00
#include <boost/test/unit_test.hpp>
2016-03-18 08:22:15 +00:00
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
2016-06-09 16:54:29 +00:00
#include <test/libsolidity/SolidityExecutionFramework.h>
2015-06-10 15:37:17 +00:00
using namespace std;
using namespace solidity::test;
using namespace solidity::util;
2015-06-10 15:37:17 +00:00
namespace solidity::frontend::test
2015-06-10 15:37:17 +00:00
{
static char const* walletCode = R"DELIMITER(
//sol Wallet
// Multi-sig, daily-limited account proxy/wallet.
// @authors:
// Gav Wood <g@ethdev.com>
// inheritable "property" contract that enables methods to be protected by requiring the acquiescence of either a
// single, or, crucially, each of a number of, designated owners.
// usage:
// use modifiers onlyowner (just own owned) or onlymanyowners(hash), whereby the same hash must be provided by
// some number (specified in constructor) of the set of owners (specified in the constructor, modifiable) before the
// interior is executed.
2016-08-19 17:57:21 +00:00
2020-01-10 17:13:57 +00:00
pragma solidity >=0.4.0 <0.8.0;
2016-08-19 17:57:21 +00:00
2015-06-10 15:37:17 +00:00
contract multiowned {
2015-07-06 16:04:26 +00:00
// TYPES
2015-06-10 15:37:17 +00:00
// struct for the status of a pending operation.
struct PendingState {
uint yetNeeded;
uint ownersDone;
uint index;
}
2015-07-06 16:04:26 +00:00
// EVENTS
2015-06-10 15:37:17 +00:00
// this contract only has five types of events: it can accept a confirmation, in which case
// we record owner and operation (hash) alongside it.
event Confirmation(address owner, bytes32 operation);
event Revoke(address owner, bytes32 operation);
// some others are in the case of an owner changing.
event OwnerChanged(address oldOwner, address newOwner);
event OwnerAdded(address newOwner);
event OwnerRemoved(address oldOwner);
// the last one is emitted if the required signatures change
event RequirementChanged(uint newRequirement);
2015-07-06 16:04:26 +00:00
// MODIFIERS
2015-06-10 15:37:17 +00:00
// simple single-sig function modifier.
modifier onlyowner {
if (isOwner(msg.sender))
2016-09-05 12:54:50 +00:00
_;
2015-06-10 15:37:17 +00:00
}
// multi-sig function modifier: the operation must have an intrinsic hash in order
// that later attempts can be realised as the same underlying operation and
// thus count as confirmations.
modifier onlymanyowners(bytes32 _operation) {
2015-07-06 16:04:26 +00:00
if (confirmAndCheck(_operation))
2016-09-05 12:54:50 +00:00
_;
2015-06-10 15:37:17 +00:00
}
2015-07-06 16:04:26 +00:00
// METHODS
// constructor is given number of sigs required to do protected "onlymanyowners" transactions
// as well as the selection of addresses capable of confirming them.
2020-06-23 12:14:24 +00:00
constructor(address[] memory _owners, uint _required) {
2015-07-16 14:25:23 +00:00
m_numOwners = _owners.length + 1;
m_owners[1] = uint(msg.sender);
m_ownerIndex[uint(msg.sender)] = 1;
for (uint i = 0; i < _owners.length; ++i)
{
m_owners[2 + i] = uint(_owners[i]);
m_ownerIndex[uint(_owners[i])] = 2 + i;
}
m_required = _required;
2015-07-06 16:04:26 +00:00
}
2015-06-10 15:37:17 +00:00
// Revokes a prior confirmation of the given operation
function revoke(bytes32 _operation) external {
uint ownerIndex = m_ownerIndex[uint(msg.sender)];
// make sure they're an owner
if (ownerIndex == 0) return;
uint ownerIndexBit = 2**ownerIndex;
PendingState storage pending = m_pending[_operation];
2015-06-10 15:37:17 +00:00
if (pending.ownersDone & ownerIndexBit > 0) {
pending.yetNeeded++;
pending.ownersDone -= ownerIndexBit;
2018-06-26 18:09:54 +00:00
emit Revoke(msg.sender, _operation);
2015-06-10 15:37:17 +00:00
}
}
2015-07-06 16:04:26 +00:00
// Replaces an owner `_from` with another `_to`.
2019-11-05 17:25:34 +00:00
function changeOwner(address _from, address _to) onlymanyowners(keccak256(msg.data)) public virtual {
2015-07-06 16:04:26 +00:00
if (isOwner(_to)) return;
uint ownerIndex = m_ownerIndex[uint(_from)];
if (ownerIndex == 0) return;
clearPending();
m_owners[ownerIndex] = uint(_to);
m_ownerIndex[uint(_from)] = 0;
m_ownerIndex[uint(_to)] = ownerIndex;
2018-06-26 18:09:54 +00:00
emit OwnerChanged(_from, _to);
2015-07-06 16:04:26 +00:00
}
2015-07-16 14:25:23 +00:00
function addOwner(address _owner) onlymanyowners(keccak256(msg.data)) external {
2015-07-06 16:04:26 +00:00
if (isOwner(_owner)) return;
clearPending();
if (m_numOwners >= c_maxOwners)
reorganizeOwners();
if (m_numOwners >= c_maxOwners)
return;
m_numOwners++;
m_owners[m_numOwners] = uint(_owner);
m_ownerIndex[uint(_owner)] = m_numOwners;
2018-06-26 18:09:54 +00:00
emit OwnerAdded(_owner);
2015-07-06 16:04:26 +00:00
}
function removeOwner(address _owner) onlymanyowners(keccak256(msg.data)) external {
2015-07-06 16:04:26 +00:00
uint ownerIndex = m_ownerIndex[uint(_owner)];
if (ownerIndex == 0) return;
if (m_required > m_numOwners - 1) return;
m_owners[ownerIndex] = 0;
m_ownerIndex[uint(_owner)] = 0;
clearPending();
reorganizeOwners(); //make sure m_numOwner is equal to the number of owners and always points to the optimal free slot
2018-06-26 18:09:54 +00:00
emit OwnerRemoved(_owner);
2015-07-06 16:04:26 +00:00
}
function changeRequirement(uint _newRequired) onlymanyowners(keccak256(msg.data)) external {
2015-07-06 16:04:26 +00:00
if (_newRequired > m_numOwners) return;
m_required = _newRequired;
clearPending();
2018-06-26 18:09:54 +00:00
emit RequirementChanged(_newRequired);
2015-07-06 16:04:26 +00:00
}
2018-07-11 13:57:07 +00:00
function isOwner(address _addr) public returns (bool) {
2015-07-06 16:04:26 +00:00
return m_ownerIndex[uint(_addr)] > 0;
}
2018-07-11 13:57:07 +00:00
function hasConfirmed(bytes32 _operation, address _owner) public view returns (bool) {
PendingState storage pending = m_pending[_operation];
2015-07-06 16:04:26 +00:00
uint ownerIndex = m_ownerIndex[uint(_owner)];
// make sure they're an owner
if (ownerIndex == 0) return false;
// determine the bit to set for this owner.
uint ownerIndexBit = 2**ownerIndex;
if (pending.ownersDone & ownerIndexBit == 0) {
return false;
} else {
return true;
}
}
// INTERNAL METHODS
function confirmAndCheck(bytes32 _operation) internal returns (bool) {
2015-06-10 15:37:17 +00:00
// determine what index the present sender is:
uint ownerIndex = m_ownerIndex[uint(msg.sender)];
// make sure they're an owner
if (ownerIndex == 0) return false;
2015-06-10 15:37:17 +00:00
PendingState storage pending = m_pending[_operation];
2015-06-10 15:37:17 +00:00
// if we're not yet working on this operation, switch over and reset the confirmation status.
if (pending.yetNeeded == 0) {
// reset count of confirmations needed.
pending.yetNeeded = m_required;
// reset which owners have confirmed (none) - set our bitmap to 0.
pending.ownersDone = 0;
m_pendingIndex.push(_operation);
pending.index = m_pendingIndex.length - 1;
2015-06-10 15:37:17 +00:00
}
// determine the bit to set for this owner.
uint ownerIndexBit = 2**ownerIndex;
// make sure we (the message sender) haven't confirmed this operation previously.
if (pending.ownersDone & ownerIndexBit == 0) {
2018-06-27 08:48:03 +00:00
emit Confirmation(msg.sender, _operation);
2015-06-10 15:37:17 +00:00
// ok - check if count is enough to go ahead.
if (pending.yetNeeded <= 1) {
// enough confirmations: reset and run interior.
delete m_pendingIndex[m_pending[_operation].index];
delete m_pending[_operation];
return true;
}
else
{
// not enough: record that this owner in particular confirmed.
pending.yetNeeded--;
pending.ownersDone |= ownerIndexBit;
return false;
2015-06-10 15:37:17 +00:00
}
}
}
function reorganizeOwners() private returns (bool) {
uint free = 1;
while (free < m_numOwners)
{
while (free < m_numOwners && m_owners[free] != 0) free++;
while (m_numOwners > 1 && m_owners[m_numOwners] == 0) m_numOwners--;
if (free < m_numOwners && m_owners[m_numOwners] != 0 && m_owners[free] == 0)
{
m_owners[free] = m_owners[m_numOwners];
m_ownerIndex[m_owners[free]] = free;
m_owners[m_numOwners] = 0;
}
}
}
2015-07-06 16:04:26 +00:00
2019-11-05 17:25:34 +00:00
function clearPending() internal virtual {
2015-06-10 15:37:17 +00:00
uint length = m_pendingIndex.length;
for (uint i = 0; i < length; ++i)
if (m_pendingIndex[i] != 0)
delete m_pending[m_pendingIndex[i]];
delete m_pendingIndex;
}
2015-07-06 16:04:26 +00:00
// FIELDS
2015-06-10 15:37:17 +00:00
// the number of owners that must confirm the same operation before it is run.
uint public m_required;
2015-06-10 15:37:17 +00:00
// pointer used to find a free slot in m_owners
uint public m_numOwners;
2015-07-06 16:04:26 +00:00
2015-06-10 15:37:17 +00:00
// list of owners
2015-07-06 16:04:26 +00:00
uint[256] m_owners;
2015-06-10 15:37:17 +00:00
uint constant c_maxOwners = 250;
// index on the list of owners to allow reverse lookup
2015-07-06 16:04:26 +00:00
mapping(uint => uint) m_ownerIndex;
2015-06-10 15:37:17 +00:00
// the ongoing operations.
2015-07-06 16:04:26 +00:00
mapping(bytes32 => PendingState) m_pending;
bytes32[] m_pendingIndex;
2015-06-10 15:37:17 +00:00
}
// inheritable "property" contract that enables methods to be protected by placing a linear limit (specifiable)
// on a particular resource per calendar day. is multiowned to allow the limit to be altered. resource that method
// uses is specified in the modifier.
2019-09-19 19:31:42 +00:00
abstract contract daylimit is multiowned {
2015-07-06 16:04:26 +00:00
// MODIFIERS
// simple modifier for daily limit.
modifier limitedDaily(uint _value) {
if (underLimit(_value))
2016-09-05 12:54:50 +00:00
_;
2015-07-06 16:04:26 +00:00
}
// METHODS
// constructor - stores initial daily limit and records the present day's index.
2020-06-23 12:14:24 +00:00
constructor(uint _limit) {
m_dailyLimit = _limit;
2015-06-10 15:37:17 +00:00
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(keccak256(msg.data)) external {
2015-06-10 15:37:17 +00:00
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(keccak256(msg.data)) external {
2015-06-10 15:37:17 +00:00
m_spentToday = 0;
}
2015-07-06 16:04:26 +00:00
// INTERNAL METHODS
2015-06-10 15:37:17 +00:00
// checks to see if there is at least `_value` left from the daily limit today. if there is, subtracts it and
// returns true. otherwise just returns false.
function underLimit(uint _value) internal onlyowner returns (bool) {
// reset the spend limit if we're on a different day to last time.
if (today() > m_lastDay) {
m_spentToday = 0;
m_lastDay = today();
}
// check to see if there's enough left - if so, subtract and return true.
if (m_spentToday + _value >= m_spentToday && m_spentToday + _value <= m_dailyLimit) {
m_spentToday += _value;
return true;
}
return false;
}
// determines today's index.
function today() private view returns (uint) { return block.timestamp / 1 days; }
2015-07-06 16:04:26 +00:00
// FIELDS
uint public m_dailyLimit;
2015-07-06 16:04:26 +00:00
uint m_spentToday;
uint m_lastDay;
2015-06-10 15:37:17 +00:00
}
2015-07-06 16:04:26 +00:00
2015-06-10 15:37:17 +00:00
// interface contract for multisig proxy contracts; see below for docs.
2019-09-19 19:31:42 +00:00
abstract contract multisig {
2015-07-06 16:04:26 +00:00
// EVENTS
// logged events:
// Funds has arrived into the wallet (record how much).
2015-06-10 15:37:17 +00:00
event Deposit(address from, uint value);
2015-07-06 16:04:26 +00:00
// Single transaction going out of the wallet (record who signed for it, how much, and to whom it's going).
2015-06-10 15:37:17 +00:00
event SingleTransact(address owner, uint value, address to, bytes data);
2015-07-06 16:04:26 +00:00
// Multi-sig transaction going out of the wallet (record who signed for it last, the operation hash, how much, and to whom it's going).
2015-06-10 15:37:17 +00:00
event MultiTransact(address owner, bytes32 operation, uint value, address to, bytes data);
2015-07-06 16:04:26 +00:00
// Confirmation still needed for a transaction.
2015-06-10 15:37:17 +00:00
event ConfirmationNeeded(bytes32 operation, address initiator, uint value, address to, bytes data);
2015-07-06 16:04:26 +00:00
// FUNCTIONS
// TODO: document
2019-11-05 17:25:34 +00:00
function changeOwner(address _from, address _to) public virtual;
function execute(address _to, uint _value, bytes calldata _data) external virtual returns (bytes32);
function confirm(bytes32 _h) public virtual returns (bool);
2015-06-10 15:37:17 +00:00
}
2015-07-06 16:04:26 +00:00
2015-06-10 15:37:17 +00:00
// usage:
// bytes32 h = Wallet(w).from(oneOwner).transact(to, value, data);
// Wallet(w).from(anotherOwner).confirm(h);
contract Wallet is multisig, multiowned, daylimit {
2015-07-06 16:04:26 +00:00
// TYPES
2015-06-10 15:37:17 +00:00
// Transaction structure to remember details of transaction lest it need be saved for a later call.
struct Transaction {
address to;
uint value;
bytes data;
}
2015-07-06 16:04:26 +00:00
// METHODS
// constructor - just pass on the owner array to the multiowned and
// the limit to daylimit
2020-06-23 12:14:24 +00:00
constructor(address[] memory _owners, uint _required, uint _daylimit) payable
multiowned(_owners, _required) daylimit(_daylimit) {
2015-06-10 15:37:17 +00:00
}
2015-07-06 16:04:26 +00:00
2019-09-16 12:33:43 +00:00
function changeOwner(address _from, address _to) public override(multiowned, multisig) {
multiowned.changeOwner(_from, _to);
}
// destroys the contract sending everything to `_to`.
2019-12-04 01:39:24 +00:00
function shutdown(address payable _to) onlymanyowners(keccak256(msg.data)) external {
selfdestruct(_to);
2015-06-10 15:37:17 +00:00
}
2015-07-06 16:04:26 +00:00
// gets called for plain ether transfers
receive() external payable {
// did we actually receive value?
2015-06-10 15:37:17 +00:00
if (msg.value > 0)
2018-06-26 18:09:54 +00:00
emit Deposit(msg.sender, msg.value);
2015-06-10 15:37:17 +00:00
}
2015-07-06 16:04:26 +00:00
2018-07-16 10:23:06 +00:00
// Outside-visible transact entry point. Executes transaction immediately if below daily spend limit.
2015-06-10 15:37:17 +00:00
// If not, goes into multisig process. We provide a hash on return to allow the sender to provide
// shortcuts for the other confirmations (allowing them to avoid replicating the _to, _value
// and _data arguments). They still get the option of using them if they want, anyways.
2019-09-16 12:33:43 +00:00
function execute(address _to, uint _value, bytes calldata _data) external override onlyowner returns (bytes32 _r) {
2015-06-10 15:37:17 +00:00
// first, take the opportunity to check that we're under the daily limit.
if (underLimit(_value)) {
2018-06-27 08:48:03 +00:00
emit SingleTransact(msg.sender, _value, _to, _data);
2015-06-10 15:37:17 +00:00
// yes - just execute the call.
2020-04-03 14:29:17 +00:00
_to.call{value: _value}(_data);
2015-06-10 15:37:17 +00:00
return 0;
}
// determine our operation hash.
2018-05-23 13:39:26 +00:00
_r = keccak256(abi.encodePacked(msg.data, block.number));
if (!confirm(_r) && m_txs[_r].to == 0x0000000000000000000000000000000000000000) {
2015-06-10 15:37:17 +00:00
m_txs[_r].to = _to;
m_txs[_r].value = _value;
m_txs[_r].data = _data;
2018-06-26 18:09:54 +00:00
emit ConfirmationNeeded(_r, msg.sender, _value, _to, _data);
2015-06-10 15:37:17 +00:00
}
}
2015-07-06 16:04:26 +00:00
2015-06-10 15:37:17 +00:00
// confirm a transaction through just the hash. we use the previous transactions map, m_txs, in order
// to determine the body of the transaction from the hash provided.
2019-09-16 12:33:43 +00:00
function confirm(bytes32 _h) onlymanyowners(_h) public override returns (bool) {
if (m_txs[_h].to != 0x0000000000000000000000000000000000000000) {
2020-04-03 14:29:17 +00:00
m_txs[_h].to.call{value: m_txs[_h].value}(m_txs[_h].data);
2018-06-27 08:48:03 +00:00
emit MultiTransact(msg.sender, _h, m_txs[_h].value, m_txs[_h].to, m_txs[_h].data);
2015-06-10 15:37:17 +00:00
delete m_txs[_h];
return true;
}
}
2015-07-06 16:04:26 +00:00
// INTERNAL METHODS
2019-09-16 12:33:43 +00:00
function clearPending() internal override {
2015-06-10 15:37:17 +00:00
uint length = m_pendingIndex.length;
for (uint i = 0; i < length; ++i)
delete m_txs[m_pendingIndex[i]];
super.clearPending();
}
2015-07-06 16:04:26 +00:00
// FIELDS
2015-06-10 15:37:17 +00:00
// pending transactions we have at present.
2015-07-06 16:04:26 +00:00
mapping (bytes32 => Transaction) m_txs;
2015-06-10 15:37:17 +00:00
}
)DELIMITER";
static LazyInit<bytes> s_compiledWallet;
2015-06-10 15:37:17 +00:00
class WalletTestFramework: public SolidityExecutionFramework
2015-06-10 15:37:17 +00:00
{
protected:
void deployWallet(
u256 const& _value = 0,
vector<h160> const& _owners = vector<h160>{},
u256 _required = 1,
u256 _dailyLimit = 0
)
2015-06-10 15:37:17 +00:00
{
bytes const& compiled = s_compiledWallet.init([&]{
return compileContract(walletCode, "Wallet");
});
2018-02-27 18:32:05 +00:00
bytes args = encodeArgs(u256(0x60), _required, _dailyLimit, u256(_owners.size()), _owners);
sendMessage(compiled + args, true, _value);
BOOST_REQUIRE(m_transactionSuccessful);
2015-06-10 15:37:17 +00:00
BOOST_REQUIRE(!m_output.empty());
}
};
/// This is a test suite that tests optimised code!
BOOST_FIXTURE_TEST_SUITE(SolidityWallet, WalletTestFramework)
BOOST_AUTO_TEST_CASE(creation)
{
deployWallet(200);
BOOST_REQUIRE(callContractFunction("isOwner(address)", m_sender) == encodeArgs(true));
bool v2 = solidity::test::CommonOptions::get().useABIEncoderV2;
2019-12-14 13:42:04 +00:00
BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(~0)) == (v2 ? encodeArgs() : encodeArgs(false)));
2015-06-10 15:37:17 +00:00
}
BOOST_AUTO_TEST_CASE(add_owners)
{
deployWallet(200);
h160 originalOwner = m_sender;
BOOST_REQUIRE(callContractFunction("addOwner(address)", account(1)) == encodeArgs());
BOOST_REQUIRE(callContractFunction("isOwner(address)", account(1)) == encodeArgs(true));
2015-06-10 15:37:17 +00:00
// now let the new owner add someone
Make the Solidity repository standalone. This commit is the culmination of several months of work to decouple Solidity from the webthree-umbrella so that it can be developed in parallel with cpp-ethereum (the Ethereum C++ runtime) and so that even for the Solidity unit-tests there is no hard-dependency onto the C++ runtime. The Tests-over-IPC refactoring was a major step in the same process which was already committed. This commit contains the following changes: - A subset of the CMake functionality in webthree-helpers was extracted and tailored for Solidity into ./cmake. Further cleanup is certainly possible. - A subset of the libdevcore functionality in libweb3core was extracted and tailored for Solidity into ./libdevcore. Further cleanup is certainly possible - The gas price constants in EVMSchedule were orphaned into libevmasm. - Some other refactorings and cleanups were made to sever unnecessary EVM dependencies in the Solidity unit-tests. - TravisCI and Appveyor support was added, covering builds and running of the unit-tests (Linux and macOS only for now) - A bug-fix was made to get the Tests-over-IPC running on macOS. - There are still reliability issues in the unit-tests, which need immediate attention. The Travis build has been flipped to run the unit-tests 5 times, to try to flush these out. - The Emscripten automation which was previously in webthree-umbrella was merged into the TravisCI automation here. - The development ZIP deployment step has been commented out, but we will want to read that ONLY for release branch. Further iteration on these changes will definitely be needed, but I feel these have got to sufficient maturity than holding them back further isn't winning us anything. It is go time :-)
2016-08-01 05:25:37 +00:00
sendEther(account(1), 10 * ether);
2016-06-18 00:08:20 +00:00
m_sender = account(1);
BOOST_REQUIRE(callContractFunction("addOwner(address)", h160(0x13)) == encodeArgs());
BOOST_REQUIRE(callContractFunction("isOwner(address)", h160(0x13)) == encodeArgs(true));
2015-06-10 15:37:17 +00:00
// and check that a non-owner cannot add a new owner
2016-06-18 00:08:20 +00:00
m_sender = account(0);
Make the Solidity repository standalone. This commit is the culmination of several months of work to decouple Solidity from the webthree-umbrella so that it can be developed in parallel with cpp-ethereum (the Ethereum C++ runtime) and so that even for the Solidity unit-tests there is no hard-dependency onto the C++ runtime. The Tests-over-IPC refactoring was a major step in the same process which was already committed. This commit contains the following changes: - A subset of the CMake functionality in webthree-helpers was extracted and tailored for Solidity into ./cmake. Further cleanup is certainly possible. - A subset of the libdevcore functionality in libweb3core was extracted and tailored for Solidity into ./libdevcore. Further cleanup is certainly possible - The gas price constants in EVMSchedule were orphaned into libevmasm. - Some other refactorings and cleanups were made to sever unnecessary EVM dependencies in the Solidity unit-tests. - TravisCI and Appveyor support was added, covering builds and running of the unit-tests (Linux and macOS only for now) - A bug-fix was made to get the Tests-over-IPC running on macOS. - There are still reliability issues in the unit-tests, which need immediate attention. The Travis build has been flipped to run the unit-tests 5 times, to try to flush these out. - The Emscripten automation which was previously in webthree-umbrella was merged into the TravisCI automation here. - The development ZIP deployment step has been commented out, but we will want to read that ONLY for release branch. Further iteration on these changes will definitely be needed, but I feel these have got to sufficient maturity than holding them back further isn't winning us anything. It is go time :-)
2016-08-01 05:25:37 +00:00
sendEther(account(2), 10 * ether);
2016-06-18 00:08:20 +00:00
m_sender = account(2);
BOOST_REQUIRE(callContractFunction("addOwner(address)", h160(0x20)) == encodeArgs());
BOOST_REQUIRE(callContractFunction("isOwner(address)", h160(0x20)) == encodeArgs(false));
2015-06-10 15:37:17 +00:00
// finally check that all the owners are there
BOOST_REQUIRE(callContractFunction("isOwner(address)", originalOwner) == encodeArgs(true));
BOOST_REQUIRE(callContractFunction("isOwner(address)", account(1)) == encodeArgs(true));
BOOST_REQUIRE(callContractFunction("isOwner(address)", h160(0x13)) == encodeArgs(true));
2015-06-10 15:37:17 +00:00
}
BOOST_AUTO_TEST_CASE(change_owners)
{
deployWallet(200);
BOOST_REQUIRE(callContractFunction("addOwner(address)", h160(0x12)) == encodeArgs());
BOOST_REQUIRE(callContractFunction("isOwner(address)", h160(0x12)) == encodeArgs(true));
BOOST_REQUIRE(callContractFunction("changeOwner(address,address)", h160(0x12), h160(0x13)) == encodeArgs());
BOOST_REQUIRE(callContractFunction("isOwner(address)", h160(0x12)) == encodeArgs(false));
BOOST_REQUIRE(callContractFunction("isOwner(address)", h160(0x13)) == encodeArgs(true));
2015-06-10 15:37:17 +00:00
}
BOOST_AUTO_TEST_CASE(remove_owner)
{
deployWallet(200);
// add 10 owners
for (unsigned i = 0; i < 10; ++i)
{
BOOST_REQUIRE(callContractFunction("addOwner(address)", h160(0x12 + i)) == encodeArgs());
BOOST_REQUIRE(callContractFunction("isOwner(address)", h160(0x12 + i)) == encodeArgs(true));
2015-06-10 15:37:17 +00:00
}
// check they are there again
for (unsigned i = 0; i < 10; ++i)
BOOST_REQUIRE(callContractFunction("isOwner(address)", h160(0x12 + i)) == encodeArgs(true));
2015-06-10 15:37:17 +00:00
// remove the odd owners
for (unsigned i = 0; i < 10; ++i)
if (i % 2 == 1)
BOOST_REQUIRE(callContractFunction("removeOwner(address)", h160(0x12 + i)) == encodeArgs());
2015-06-10 15:37:17 +00:00
// check the result
for (unsigned i = 0; i < 10; ++i)
BOOST_REQUIRE(callContractFunction("isOwner(address)", h160(0x12 + i)) == encodeArgs(i % 2 == 0));
2015-06-10 15:37:17 +00:00
// add them again
for (unsigned i = 0; i < 10; ++i)
if (i % 2 == 1)
BOOST_REQUIRE(callContractFunction("addOwner(address)", h160(0x12 + i)) == encodeArgs());
2015-06-10 15:37:17 +00:00
// check everyone is there
for (unsigned i = 0; i < 10; ++i)
BOOST_REQUIRE(callContractFunction("isOwner(address)", h160(0x12 + i)) == encodeArgs(true));
2015-06-10 15:37:17 +00:00
}
2015-07-16 14:25:23 +00:00
BOOST_AUTO_TEST_CASE(initial_owners)
{
vector<h160> owners{
h160("0x42c56279432962a17176998a4747d1b4d6ed4367"),
h160("0xd4d4669f5ba9f4c27d38ef02a358c339b5560c47"),
h160("0xe6716f9544a56c530d868e4bfbacb172315bdead"),
h160("0x775e18be7a50a0abb8a4e82b1bd697d79f31fe04"),
h160("0xf4dd5c3794f1fd0cdc0327a83aa472609c806e99"),
h160("0x4c9113886af165b2de069d6e99430647e94a9fff"),
h160("0x3fb1cd2cd96c6d5c0b5eb3322d807b34482481d4")
2015-07-20 15:51:28 +00:00
};
deployWallet(0, owners, 4, 2);
2015-07-20 15:51:28 +00:00
BOOST_CHECK(callContractFunction("m_numOwners()") == encodeArgs(u256(8)));
BOOST_CHECK(callContractFunction("isOwner(address)", m_sender) == encodeArgs(true));
for (h160 const& owner: owners)
2015-07-20 16:44:06 +00:00
{
2015-07-20 15:51:28 +00:00
BOOST_CHECK(callContractFunction("isOwner(address)", owner) == encodeArgs(true));
2015-07-20 16:44:06 +00:00
}
2015-07-16 14:25:23 +00:00
}
2015-06-10 15:37:17 +00:00
BOOST_AUTO_TEST_CASE(multisig_value_transfer)
{
deployWallet(200);
BOOST_REQUIRE(callContractFunction("addOwner(address)", account(1)) == encodeArgs());
BOOST_REQUIRE(callContractFunction("addOwner(address)", account(2)) == encodeArgs());
BOOST_REQUIRE(callContractFunction("addOwner(address)", account(3)) == encodeArgs());
2015-06-10 15:37:17 +00:00
// 4 owners, set required to 3
BOOST_REQUIRE(callContractFunction("changeRequirement(uint256)", u256(3)) == encodeArgs());
h160 destination = h160("0x5c6d6026d3fb35cd7175fd0054ae8df50d8f8b41");
BOOST_CHECK_EQUAL(balanceAt(destination), 0);
2016-06-18 00:08:20 +00:00
m_sender = account(0);
Make the Solidity repository standalone. This commit is the culmination of several months of work to decouple Solidity from the webthree-umbrella so that it can be developed in parallel with cpp-ethereum (the Ethereum C++ runtime) and so that even for the Solidity unit-tests there is no hard-dependency onto the C++ runtime. The Tests-over-IPC refactoring was a major step in the same process which was already committed. This commit contains the following changes: - A subset of the CMake functionality in webthree-helpers was extracted and tailored for Solidity into ./cmake. Further cleanup is certainly possible. - A subset of the libdevcore functionality in libweb3core was extracted and tailored for Solidity into ./libdevcore. Further cleanup is certainly possible - The gas price constants in EVMSchedule were orphaned into libevmasm. - Some other refactorings and cleanups were made to sever unnecessary EVM dependencies in the Solidity unit-tests. - TravisCI and Appveyor support was added, covering builds and running of the unit-tests (Linux and macOS only for now) - A bug-fix was made to get the Tests-over-IPC running on macOS. - There are still reliability issues in the unit-tests, which need immediate attention. The Travis build has been flipped to run the unit-tests 5 times, to try to flush these out. - The Emscripten automation which was previously in webthree-umbrella was merged into the TravisCI automation here. - The development ZIP deployment step has been commented out, but we will want to read that ONLY for release branch. Further iteration on these changes will definitely be needed, but I feel these have got to sufficient maturity than holding them back further isn't winning us anything. It is go time :-)
2016-08-01 05:25:37 +00:00
sendEther(account(1), 10 * ether);
2016-06-18 00:08:20 +00:00
m_sender = account(1);
auto ophash = callContractFunction("execute(address,uint256,bytes)", destination, 100, 0x60, 0x00);
BOOST_CHECK_EQUAL(balanceAt(destination), 0);
2016-06-18 00:08:20 +00:00
m_sender = account(0);
Make the Solidity repository standalone. This commit is the culmination of several months of work to decouple Solidity from the webthree-umbrella so that it can be developed in parallel with cpp-ethereum (the Ethereum C++ runtime) and so that even for the Solidity unit-tests there is no hard-dependency onto the C++ runtime. The Tests-over-IPC refactoring was a major step in the same process which was already committed. This commit contains the following changes: - A subset of the CMake functionality in webthree-helpers was extracted and tailored for Solidity into ./cmake. Further cleanup is certainly possible. - A subset of the libdevcore functionality in libweb3core was extracted and tailored for Solidity into ./libdevcore. Further cleanup is certainly possible - The gas price constants in EVMSchedule were orphaned into libevmasm. - Some other refactorings and cleanups were made to sever unnecessary EVM dependencies in the Solidity unit-tests. - TravisCI and Appveyor support was added, covering builds and running of the unit-tests (Linux and macOS only for now) - A bug-fix was made to get the Tests-over-IPC running on macOS. - There are still reliability issues in the unit-tests, which need immediate attention. The Travis build has been flipped to run the unit-tests 5 times, to try to flush these out. - The Emscripten automation which was previously in webthree-umbrella was merged into the TravisCI automation here. - The development ZIP deployment step has been commented out, but we will want to read that ONLY for release branch. Further iteration on these changes will definitely be needed, but I feel these have got to sufficient maturity than holding them back further isn't winning us anything. It is go time :-)
2016-08-01 05:25:37 +00:00
sendEther(account(2), 10 * ether);
2016-06-18 00:08:20 +00:00
m_sender = account(2);
callContractFunction("confirm(bytes32)", ophash);
BOOST_CHECK_EQUAL(balanceAt(destination), 0);
2016-06-18 00:08:20 +00:00
m_sender = account(0);
Make the Solidity repository standalone. This commit is the culmination of several months of work to decouple Solidity from the webthree-umbrella so that it can be developed in parallel with cpp-ethereum (the Ethereum C++ runtime) and so that even for the Solidity unit-tests there is no hard-dependency onto the C++ runtime. The Tests-over-IPC refactoring was a major step in the same process which was already committed. This commit contains the following changes: - A subset of the CMake functionality in webthree-helpers was extracted and tailored for Solidity into ./cmake. Further cleanup is certainly possible. - A subset of the libdevcore functionality in libweb3core was extracted and tailored for Solidity into ./libdevcore. Further cleanup is certainly possible - The gas price constants in EVMSchedule were orphaned into libevmasm. - Some other refactorings and cleanups were made to sever unnecessary EVM dependencies in the Solidity unit-tests. - TravisCI and Appveyor support was added, covering builds and running of the unit-tests (Linux and macOS only for now) - A bug-fix was made to get the Tests-over-IPC running on macOS. - There are still reliability issues in the unit-tests, which need immediate attention. The Travis build has been flipped to run the unit-tests 5 times, to try to flush these out. - The Emscripten automation which was previously in webthree-umbrella was merged into the TravisCI automation here. - The development ZIP deployment step has been commented out, but we will want to read that ONLY for release branch. Further iteration on these changes will definitely be needed, but I feel these have got to sufficient maturity than holding them back further isn't winning us anything. It is go time :-)
2016-08-01 05:25:37 +00:00
sendEther(account(3), 10 * ether);
2016-06-18 00:08:20 +00:00
m_sender = account(3);
callContractFunction("confirm(bytes32)", ophash);
2015-07-23 21:44:35 +00:00
// now it should go through
BOOST_CHECK_EQUAL(balanceAt(destination), 100);
2015-07-23 21:44:35 +00:00
}
BOOST_AUTO_TEST_CASE(revoke_addOwner)
{
deployWallet();
BOOST_REQUIRE(callContractFunction("addOwner(address)", account(1)) == encodeArgs());
BOOST_REQUIRE(callContractFunction("addOwner(address)", account(2)) == encodeArgs());
BOOST_REQUIRE(callContractFunction("addOwner(address)", account(3)) == encodeArgs());
2015-07-23 21:44:35 +00:00
// 4 owners, set required to 3
BOOST_REQUIRE(callContractFunction("changeRequirement(uint256)", u256(3)) == encodeArgs());
// add a new owner
h160 deployer = m_sender;
h256 opHash = util::keccak256(FixedHash<4>(util::keccak256("addOwner(address)")).asBytes() + h256(0x33).asBytes());
BOOST_REQUIRE(callContractFunction("addOwner(address)", h160(0x33)) == encodeArgs());
BOOST_REQUIRE(callContractFunction("isOwner(address)", h160(0x33)) == encodeArgs(false));
2016-06-18 00:08:20 +00:00
m_sender = account(0);
Make the Solidity repository standalone. This commit is the culmination of several months of work to decouple Solidity from the webthree-umbrella so that it can be developed in parallel with cpp-ethereum (the Ethereum C++ runtime) and so that even for the Solidity unit-tests there is no hard-dependency onto the C++ runtime. The Tests-over-IPC refactoring was a major step in the same process which was already committed. This commit contains the following changes: - A subset of the CMake functionality in webthree-helpers was extracted and tailored for Solidity into ./cmake. Further cleanup is certainly possible. - A subset of the libdevcore functionality in libweb3core was extracted and tailored for Solidity into ./libdevcore. Further cleanup is certainly possible - The gas price constants in EVMSchedule were orphaned into libevmasm. - Some other refactorings and cleanups were made to sever unnecessary EVM dependencies in the Solidity unit-tests. - TravisCI and Appveyor support was added, covering builds and running of the unit-tests (Linux and macOS only for now) - A bug-fix was made to get the Tests-over-IPC running on macOS. - There are still reliability issues in the unit-tests, which need immediate attention. The Travis build has been flipped to run the unit-tests 5 times, to try to flush these out. - The Emscripten automation which was previously in webthree-umbrella was merged into the TravisCI automation here. - The development ZIP deployment step has been commented out, but we will want to read that ONLY for release branch. Further iteration on these changes will definitely be needed, but I feel these have got to sufficient maturity than holding them back further isn't winning us anything. It is go time :-)
2016-08-01 05:25:37 +00:00
sendEther(account(1), 10 * ether);
2016-06-18 00:08:20 +00:00
m_sender = account(1);
BOOST_REQUIRE(callContractFunction("addOwner(address)", h160(0x33)) == encodeArgs());
BOOST_REQUIRE(callContractFunction("isOwner(address)", h160(0x33)) == encodeArgs(false));
2015-07-23 21:44:35 +00:00
// revoke one confirmation
m_sender = deployer;
BOOST_REQUIRE(callContractFunction("revoke(bytes32)", opHash) == encodeArgs());
2016-06-18 00:08:20 +00:00
m_sender = account(0);
Make the Solidity repository standalone. This commit is the culmination of several months of work to decouple Solidity from the webthree-umbrella so that it can be developed in parallel with cpp-ethereum (the Ethereum C++ runtime) and so that even for the Solidity unit-tests there is no hard-dependency onto the C++ runtime. The Tests-over-IPC refactoring was a major step in the same process which was already committed. This commit contains the following changes: - A subset of the CMake functionality in webthree-helpers was extracted and tailored for Solidity into ./cmake. Further cleanup is certainly possible. - A subset of the libdevcore functionality in libweb3core was extracted and tailored for Solidity into ./libdevcore. Further cleanup is certainly possible - The gas price constants in EVMSchedule were orphaned into libevmasm. - Some other refactorings and cleanups were made to sever unnecessary EVM dependencies in the Solidity unit-tests. - TravisCI and Appveyor support was added, covering builds and running of the unit-tests (Linux and macOS only for now) - A bug-fix was made to get the Tests-over-IPC running on macOS. - There are still reliability issues in the unit-tests, which need immediate attention. The Travis build has been flipped to run the unit-tests 5 times, to try to flush these out. - The Emscripten automation which was previously in webthree-umbrella was merged into the TravisCI automation here. - The development ZIP deployment step has been commented out, but we will want to read that ONLY for release branch. Further iteration on these changes will definitely be needed, but I feel these have got to sufficient maturity than holding them back further isn't winning us anything. It is go time :-)
2016-08-01 05:25:37 +00:00
sendEther(account(2), 10 * ether);
2016-06-18 00:08:20 +00:00
m_sender = account(2);
BOOST_REQUIRE(callContractFunction("addOwner(address)", h160(0x33)) == encodeArgs());
BOOST_REQUIRE(callContractFunction("isOwner(address)", h160(0x33)) == encodeArgs(false));
2016-06-18 00:08:20 +00:00
m_sender = account(0);
Make the Solidity repository standalone. This commit is the culmination of several months of work to decouple Solidity from the webthree-umbrella so that it can be developed in parallel with cpp-ethereum (the Ethereum C++ runtime) and so that even for the Solidity unit-tests there is no hard-dependency onto the C++ runtime. The Tests-over-IPC refactoring was a major step in the same process which was already committed. This commit contains the following changes: - A subset of the CMake functionality in webthree-helpers was extracted and tailored for Solidity into ./cmake. Further cleanup is certainly possible. - A subset of the libdevcore functionality in libweb3core was extracted and tailored for Solidity into ./libdevcore. Further cleanup is certainly possible - The gas price constants in EVMSchedule were orphaned into libevmasm. - Some other refactorings and cleanups were made to sever unnecessary EVM dependencies in the Solidity unit-tests. - TravisCI and Appveyor support was added, covering builds and running of the unit-tests (Linux and macOS only for now) - A bug-fix was made to get the Tests-over-IPC running on macOS. - There are still reliability issues in the unit-tests, which need immediate attention. The Travis build has been flipped to run the unit-tests 5 times, to try to flush these out. - The Emscripten automation which was previously in webthree-umbrella was merged into the TravisCI automation here. - The development ZIP deployment step has been commented out, but we will want to read that ONLY for release branch. Further iteration on these changes will definitely be needed, but I feel these have got to sufficient maturity than holding them back further isn't winning us anything. It is go time :-)
2016-08-01 05:25:37 +00:00
sendEther(account(3), 10 * ether);
2016-06-18 00:08:20 +00:00
m_sender = account(3);
BOOST_REQUIRE(callContractFunction("addOwner(address)", h160(0x33)) == encodeArgs());
BOOST_REQUIRE(callContractFunction("isOwner(address)", h160(0x33)) == encodeArgs(true));
2015-07-23 21:44:35 +00:00
}
BOOST_AUTO_TEST_CASE(revoke_transaction)
{
deployWallet(200);
BOOST_REQUIRE(callContractFunction("addOwner(address)", account(1)) == encodeArgs());
BOOST_REQUIRE(callContractFunction("addOwner(address)", account(2)) == encodeArgs());
BOOST_REQUIRE(callContractFunction("addOwner(address)", account(3)) == encodeArgs());
2015-07-23 21:44:35 +00:00
// 4 owners, set required to 3
BOOST_REQUIRE(callContractFunction("changeRequirement(uint256)", u256(3)) == encodeArgs());
// create a transaction
h160 deployer = m_sender;
h160 destination = h160("0x5c6d6026d3fb35cd7175fd0054ae8df50d8f8b41");
BOOST_CHECK_EQUAL(balanceAt(destination), 0);
2016-06-18 00:08:20 +00:00
m_sender = account(0);
Make the Solidity repository standalone. This commit is the culmination of several months of work to decouple Solidity from the webthree-umbrella so that it can be developed in parallel with cpp-ethereum (the Ethereum C++ runtime) and so that even for the Solidity unit-tests there is no hard-dependency onto the C++ runtime. The Tests-over-IPC refactoring was a major step in the same process which was already committed. This commit contains the following changes: - A subset of the CMake functionality in webthree-helpers was extracted and tailored for Solidity into ./cmake. Further cleanup is certainly possible. - A subset of the libdevcore functionality in libweb3core was extracted and tailored for Solidity into ./libdevcore. Further cleanup is certainly possible - The gas price constants in EVMSchedule were orphaned into libevmasm. - Some other refactorings and cleanups were made to sever unnecessary EVM dependencies in the Solidity unit-tests. - TravisCI and Appveyor support was added, covering builds and running of the unit-tests (Linux and macOS only for now) - A bug-fix was made to get the Tests-over-IPC running on macOS. - There are still reliability issues in the unit-tests, which need immediate attention. The Travis build has been flipped to run the unit-tests 5 times, to try to flush these out. - The Emscripten automation which was previously in webthree-umbrella was merged into the TravisCI automation here. - The development ZIP deployment step has been commented out, but we will want to read that ONLY for release branch. Further iteration on these changes will definitely be needed, but I feel these have got to sufficient maturity than holding them back further isn't winning us anything. It is go time :-)
2016-08-01 05:25:37 +00:00
sendEther(account(1), 10 * ether);
2016-06-18 00:08:20 +00:00
m_sender = account(1);
auto opHash = callContractFunction("execute(address,uint256,bytes)", destination, 100, 0x60, 0x00);
BOOST_CHECK_EQUAL(balanceAt(destination), 0);
2016-06-18 00:08:20 +00:00
m_sender = account(0);
Make the Solidity repository standalone. This commit is the culmination of several months of work to decouple Solidity from the webthree-umbrella so that it can be developed in parallel with cpp-ethereum (the Ethereum C++ runtime) and so that even for the Solidity unit-tests there is no hard-dependency onto the C++ runtime. The Tests-over-IPC refactoring was a major step in the same process which was already committed. This commit contains the following changes: - A subset of the CMake functionality in webthree-helpers was extracted and tailored for Solidity into ./cmake. Further cleanup is certainly possible. - A subset of the libdevcore functionality in libweb3core was extracted and tailored for Solidity into ./libdevcore. Further cleanup is certainly possible - The gas price constants in EVMSchedule were orphaned into libevmasm. - Some other refactorings and cleanups were made to sever unnecessary EVM dependencies in the Solidity unit-tests. - TravisCI and Appveyor support was added, covering builds and running of the unit-tests (Linux and macOS only for now) - A bug-fix was made to get the Tests-over-IPC running on macOS. - There are still reliability issues in the unit-tests, which need immediate attention. The Travis build has been flipped to run the unit-tests 5 times, to try to flush these out. - The Emscripten automation which was previously in webthree-umbrella was merged into the TravisCI automation here. - The development ZIP deployment step has been commented out, but we will want to read that ONLY for release branch. Further iteration on these changes will definitely be needed, but I feel these have got to sufficient maturity than holding them back further isn't winning us anything. It is go time :-)
2016-08-01 05:25:37 +00:00
sendEther(account(2), 10 * ether);
2016-06-18 00:08:20 +00:00
m_sender = account(2);
callContractFunction("confirm(bytes32)", opHash);
BOOST_CHECK_EQUAL(balanceAt(destination), 0);
2016-06-18 00:08:20 +00:00
m_sender = account(0);
Make the Solidity repository standalone. This commit is the culmination of several months of work to decouple Solidity from the webthree-umbrella so that it can be developed in parallel with cpp-ethereum (the Ethereum C++ runtime) and so that even for the Solidity unit-tests there is no hard-dependency onto the C++ runtime. The Tests-over-IPC refactoring was a major step in the same process which was already committed. This commit contains the following changes: - A subset of the CMake functionality in webthree-helpers was extracted and tailored for Solidity into ./cmake. Further cleanup is certainly possible. - A subset of the libdevcore functionality in libweb3core was extracted and tailored for Solidity into ./libdevcore. Further cleanup is certainly possible - The gas price constants in EVMSchedule were orphaned into libevmasm. - Some other refactorings and cleanups were made to sever unnecessary EVM dependencies in the Solidity unit-tests. - TravisCI and Appveyor support was added, covering builds and running of the unit-tests (Linux and macOS only for now) - A bug-fix was made to get the Tests-over-IPC running on macOS. - There are still reliability issues in the unit-tests, which need immediate attention. The Travis build has been flipped to run the unit-tests 5 times, to try to flush these out. - The Emscripten automation which was previously in webthree-umbrella was merged into the TravisCI automation here. - The development ZIP deployment step has been commented out, but we will want to read that ONLY for release branch. Further iteration on these changes will definitely be needed, but I feel these have got to sufficient maturity than holding them back further isn't winning us anything. It is go time :-)
2016-08-01 05:25:37 +00:00
sendEther(account(1), 10 * ether);
2016-06-18 00:08:20 +00:00
m_sender = account(1);
2015-07-23 21:44:35 +00:00
BOOST_REQUIRE(callContractFunction("revoke(bytes32)", opHash) == encodeArgs());
m_sender = deployer;
2016-06-18 00:08:20 +00:00
callContractFunction("confirm(bytes32)", opHash);
BOOST_CHECK_EQUAL(balanceAt(destination), 0);
2016-06-18 00:08:20 +00:00
m_sender = account(0);
Make the Solidity repository standalone. This commit is the culmination of several months of work to decouple Solidity from the webthree-umbrella so that it can be developed in parallel with cpp-ethereum (the Ethereum C++ runtime) and so that even for the Solidity unit-tests there is no hard-dependency onto the C++ runtime. The Tests-over-IPC refactoring was a major step in the same process which was already committed. This commit contains the following changes: - A subset of the CMake functionality in webthree-helpers was extracted and tailored for Solidity into ./cmake. Further cleanup is certainly possible. - A subset of the libdevcore functionality in libweb3core was extracted and tailored for Solidity into ./libdevcore. Further cleanup is certainly possible - The gas price constants in EVMSchedule were orphaned into libevmasm. - Some other refactorings and cleanups were made to sever unnecessary EVM dependencies in the Solidity unit-tests. - TravisCI and Appveyor support was added, covering builds and running of the unit-tests (Linux and macOS only for now) - A bug-fix was made to get the Tests-over-IPC running on macOS. - There are still reliability issues in the unit-tests, which need immediate attention. The Travis build has been flipped to run the unit-tests 5 times, to try to flush these out. - The Emscripten automation which was previously in webthree-umbrella was merged into the TravisCI automation here. - The development ZIP deployment step has been commented out, but we will want to read that ONLY for release branch. Further iteration on these changes will definitely be needed, but I feel these have got to sufficient maturity than holding them back further isn't winning us anything. It is go time :-)
2016-08-01 05:25:37 +00:00
sendEther(account(3), 10 * ether);
2016-06-18 00:08:20 +00:00
m_sender = account(3);
callContractFunction("confirm(bytes32)", opHash);
2015-06-10 15:37:17 +00:00
// now it should go through
BOOST_CHECK_EQUAL(balanceAt(destination), 100);
2015-06-10 15:37:17 +00:00
}
BOOST_AUTO_TEST_CASE(daylimit)
{
deployWallet(200);
BOOST_REQUIRE(callContractFunction("m_dailyLimit()") == encodeArgs(u256(0)));
BOOST_REQUIRE(callContractFunction("setDailyLimit(uint256)", u256(100)) == encodeArgs());
BOOST_REQUIRE(callContractFunction("m_dailyLimit()") == encodeArgs(u256(100)));
BOOST_REQUIRE(callContractFunction("addOwner(address)", account(1)) == encodeArgs());
BOOST_REQUIRE(callContractFunction("addOwner(address)", account(2)) == encodeArgs());
BOOST_REQUIRE(callContractFunction("addOwner(address)", account(3)) == encodeArgs());
2015-06-10 15:37:17 +00:00
// 4 owners, set required to 3
BOOST_REQUIRE(callContractFunction("changeRequirement(uint256)", u256(3)) == encodeArgs());
// try to send tx over daylimit
h160 destination = h160("0x5c6d6026d3fb35cd7175fd0054ae8df50d8f8b41");
BOOST_CHECK_EQUAL(balanceAt(destination), 0);
Make the Solidity repository standalone. This commit is the culmination of several months of work to decouple Solidity from the webthree-umbrella so that it can be developed in parallel with cpp-ethereum (the Ethereum C++ runtime) and so that even for the Solidity unit-tests there is no hard-dependency onto the C++ runtime. The Tests-over-IPC refactoring was a major step in the same process which was already committed. This commit contains the following changes: - A subset of the CMake functionality in webthree-helpers was extracted and tailored for Solidity into ./cmake. Further cleanup is certainly possible. - A subset of the libdevcore functionality in libweb3core was extracted and tailored for Solidity into ./libdevcore. Further cleanup is certainly possible - The gas price constants in EVMSchedule were orphaned into libevmasm. - Some other refactorings and cleanups were made to sever unnecessary EVM dependencies in the Solidity unit-tests. - TravisCI and Appveyor support was added, covering builds and running of the unit-tests (Linux and macOS only for now) - A bug-fix was made to get the Tests-over-IPC running on macOS. - There are still reliability issues in the unit-tests, which need immediate attention. The Travis build has been flipped to run the unit-tests 5 times, to try to flush these out. - The Emscripten automation which was previously in webthree-umbrella was merged into the TravisCI automation here. - The development ZIP deployment step has been commented out, but we will want to read that ONLY for release branch. Further iteration on these changes will definitely be needed, but I feel these have got to sufficient maturity than holding them back further isn't winning us anything. It is go time :-)
2016-08-01 05:25:37 +00:00
sendEther(account(1), 10 * ether);
2016-06-18 00:08:20 +00:00
m_sender = account(1);
2015-06-10 15:37:17 +00:00
BOOST_REQUIRE(
callContractFunction("execute(address,uint256,bytes)", destination, 150, 0x60, 0x00) !=
2015-06-10 15:37:17 +00:00
encodeArgs(u256(0))
);
BOOST_CHECK_EQUAL(balanceAt(destination), 0);
2015-06-10 15:37:17 +00:00
// try to send tx under daylimit by stranger
2016-06-18 00:08:20 +00:00
m_sender = account(0);
Make the Solidity repository standalone. This commit is the culmination of several months of work to decouple Solidity from the webthree-umbrella so that it can be developed in parallel with cpp-ethereum (the Ethereum C++ runtime) and so that even for the Solidity unit-tests there is no hard-dependency onto the C++ runtime. The Tests-over-IPC refactoring was a major step in the same process which was already committed. This commit contains the following changes: - A subset of the CMake functionality in webthree-helpers was extracted and tailored for Solidity into ./cmake. Further cleanup is certainly possible. - A subset of the libdevcore functionality in libweb3core was extracted and tailored for Solidity into ./libdevcore. Further cleanup is certainly possible - The gas price constants in EVMSchedule were orphaned into libevmasm. - Some other refactorings and cleanups were made to sever unnecessary EVM dependencies in the Solidity unit-tests. - TravisCI and Appveyor support was added, covering builds and running of the unit-tests (Linux and macOS only for now) - A bug-fix was made to get the Tests-over-IPC running on macOS. - There are still reliability issues in the unit-tests, which need immediate attention. The Travis build has been flipped to run the unit-tests 5 times, to try to flush these out. - The Emscripten automation which was previously in webthree-umbrella was merged into the TravisCI automation here. - The development ZIP deployment step has been commented out, but we will want to read that ONLY for release branch. Further iteration on these changes will definitely be needed, but I feel these have got to sufficient maturity than holding them back further isn't winning us anything. It is go time :-)
2016-08-01 05:25:37 +00:00
sendEther(account(4), 10 * ether);
2016-06-18 00:08:20 +00:00
m_sender = account(4);
2015-06-10 15:37:17 +00:00
BOOST_REQUIRE(
callContractFunction("execute(address,uint256,bytes)", destination, 90, 0x60, 0x00) ==
2015-06-10 15:37:17 +00:00
encodeArgs(u256(0))
);
BOOST_CHECK_EQUAL(balanceAt(destination), 0);
2015-06-10 15:37:17 +00:00
// now send below limit by owner
2016-06-18 00:08:20 +00:00
m_sender = account(0);
Make the Solidity repository standalone. This commit is the culmination of several months of work to decouple Solidity from the webthree-umbrella so that it can be developed in parallel with cpp-ethereum (the Ethereum C++ runtime) and so that even for the Solidity unit-tests there is no hard-dependency onto the C++ runtime. The Tests-over-IPC refactoring was a major step in the same process which was already committed. This commit contains the following changes: - A subset of the CMake functionality in webthree-helpers was extracted and tailored for Solidity into ./cmake. Further cleanup is certainly possible. - A subset of the libdevcore functionality in libweb3core was extracted and tailored for Solidity into ./libdevcore. Further cleanup is certainly possible - The gas price constants in EVMSchedule were orphaned into libevmasm. - Some other refactorings and cleanups were made to sever unnecessary EVM dependencies in the Solidity unit-tests. - TravisCI and Appveyor support was added, covering builds and running of the unit-tests (Linux and macOS only for now) - A bug-fix was made to get the Tests-over-IPC running on macOS. - There are still reliability issues in the unit-tests, which need immediate attention. The Travis build has been flipped to run the unit-tests 5 times, to try to flush these out. - The Emscripten automation which was previously in webthree-umbrella was merged into the TravisCI automation here. - The development ZIP deployment step has been commented out, but we will want to read that ONLY for release branch. Further iteration on these changes will definitely be needed, but I feel these have got to sufficient maturity than holding them back further isn't winning us anything. It is go time :-)
2016-08-01 05:25:37 +00:00
sendEther(account(1), 10 * ether);
2015-06-10 15:37:17 +00:00
BOOST_REQUIRE(
callContractFunction("execute(address,uint256,bytes)", destination, 90, 0x60, 0x00) ==
2015-06-10 15:37:17 +00:00
encodeArgs(u256(0))
);
BOOST_CHECK_EQUAL(balanceAt(destination), 90);
2015-06-10 15:37:17 +00:00
}
BOOST_AUTO_TEST_CASE(daylimit_constructor)
{
deployWallet(200, {}, 1, 20);
BOOST_REQUIRE(callContractFunction("m_dailyLimit()") == encodeArgs(u256(20)));
BOOST_REQUIRE(callContractFunction("setDailyLimit(uint256)", u256(30)) == encodeArgs());
BOOST_REQUIRE(callContractFunction("m_dailyLimit()") == encodeArgs(u256(30)));
}
2015-06-10 15:37:17 +00:00
//@todo test data calls
BOOST_AUTO_TEST_SUITE_END()
} // end namespaces