remove MultisigWallet in favor of ConsenSys/MultiSigWallet
This commit is contained in:
@ -1,119 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var MultisigWalletMock = artifacts.require('./helpers/MultisigWalletMock.sol');
|
||||
require('./helpers/transactionMined.js');
|
||||
|
||||
contract('MultisigWallet', function(accounts) {
|
||||
let shouldntFail = function(err) {
|
||||
assert.isFalse(!!err);
|
||||
};
|
||||
it('should send balance to passed address upon death', async function() {
|
||||
//Give account[0] 20 ether
|
||||
web3.eth.sendTransaction({from: web3.eth.coinbase, to: accounts[0], value: web3.toWei('20','ether')}, shouldntFail);
|
||||
|
||||
let dailyLimit = 10;
|
||||
let ownersRequired = 2;
|
||||
|
||||
//Create MultisigWallet contract with 10 ether
|
||||
let wallet = await MultisigWalletMock.new(accounts, ownersRequired, dailyLimit, {value: web3.toWei('10', 'ether')});
|
||||
|
||||
//Get balances of owner and wallet after wallet creation.
|
||||
let ownerBalance = web3.eth.getBalance(accounts[0]);
|
||||
let walletBalance = web3.eth.getBalance(wallet.address);
|
||||
let hash = 1234;
|
||||
|
||||
//Call destroy function from two different owner accounts, satisfying owners required
|
||||
await wallet.destroy(accounts[0], {data: hash});
|
||||
let txnHash = await wallet.destroy(accounts[0], {from: accounts[1], data: hash});
|
||||
|
||||
//Get balances of owner and wallet after destroy function is complete, compare with previous values
|
||||
let newOwnerBalance = web3.eth.getBalance(accounts[0]);
|
||||
let newWalletBalance = web3.eth.getBalance(wallet.address);
|
||||
|
||||
assert.isTrue(newOwnerBalance > ownerBalance);
|
||||
assert.isTrue(newWalletBalance < walletBalance);
|
||||
});
|
||||
|
||||
it('should execute transaction if below daily limit', async function() {
|
||||
//Give account[0] 20 ether
|
||||
web3.eth.sendTransaction({from: web3.eth.coinbase, to: accounts[0], value: web3.toWei('20','ether')}, shouldntFail);
|
||||
|
||||
let dailyLimit = 10;
|
||||
let ownersRequired = 2;
|
||||
|
||||
//Create MultisigWallet contract with 10 ether
|
||||
let wallet = await MultisigWalletMock.new(accounts, ownersRequired, dailyLimit, {value: web3.toWei('10', 'ether')});
|
||||
|
||||
let accountBalance = web3.eth.getBalance(accounts[2]);
|
||||
let hash = 1234;
|
||||
|
||||
//Owner account0 commands wallet to send 9 wei to account2
|
||||
let txnHash = await wallet.execute(accounts[2], 9, hash);
|
||||
|
||||
//Balance of account2 should have increased
|
||||
let newAccountBalance = web3.eth.getBalance(accounts[2]);
|
||||
assert.isTrue(newAccountBalance.greaterThan(accountBalance));
|
||||
});
|
||||
|
||||
it('should prevent execution of transaction if above daily limit', async function() {
|
||||
//Give account[0] 20 ether
|
||||
web3.eth.sendTransaction({from: web3.eth.coinbase, to: accounts[0], value: web3.toWei('20','ether')}, shouldntFail);
|
||||
|
||||
let dailyLimit = 10;
|
||||
let ownersRequired = 2;
|
||||
|
||||
//Create MultisigWallet contract with 10 ether
|
||||
let wallet = await MultisigWalletMock.new(accounts, ownersRequired, dailyLimit, {value: web3.toWei('10', 'ether')});
|
||||
|
||||
let accountBalance = web3.eth.getBalance(accounts[2]);
|
||||
let hash = 1234;
|
||||
|
||||
//Owner account0 commands wallet to send 9 wei to account2
|
||||
let txnHash = await wallet.execute(accounts[2], 9, hash);
|
||||
|
||||
//Balance of account2 should have increased
|
||||
let newAccountBalance = web3.eth.getBalance(accounts[2]);
|
||||
assert.isTrue(newAccountBalance > accountBalance);
|
||||
|
||||
accountBalance = newAccountBalance;
|
||||
hash = 4567;
|
||||
|
||||
//Owner account0 commands wallet to send 2 more wei to account2, going over the daily limit of 10
|
||||
txnHash = await wallet.execute(accounts[2], 2, hash);
|
||||
|
||||
//Balance of account2 should not change
|
||||
newAccountBalance = web3.eth.getBalance(accounts[2]);
|
||||
assert.equal(newAccountBalance.toString(), accountBalance.toString());
|
||||
});
|
||||
|
||||
it('should execute transaction if above daily limit and enough owners approve', async function() {
|
||||
//Give account[0] 20 ether
|
||||
web3.eth.sendTransaction({from: web3.eth.coinbase, to: accounts[0], value: web3.toWei('20','ether')}, shouldntFail);
|
||||
|
||||
let dailyLimit = 10;
|
||||
let ownersRequired = 2;
|
||||
|
||||
//Create MultisigWallet contract with 10 ether
|
||||
let wallet = await MultisigWalletMock.new(accounts, ownersRequired, dailyLimit, {value: web3.toWei('10', 'ether')});
|
||||
|
||||
let accountBalance = web3.eth.getBalance(accounts[2]);
|
||||
let hash = 1234;
|
||||
|
||||
//Owner account0 commands wallet to send 11 wei to account2
|
||||
let txnHash = await wallet.execute(accounts[2], 11, hash);
|
||||
|
||||
//Balance of account2 should not change
|
||||
let newAccountBalance = web3.eth.getBalance(accounts[2]);
|
||||
assert.equal(newAccountBalance.toString(), accountBalance.toString());
|
||||
|
||||
accountBalance = newAccountBalance;
|
||||
|
||||
//Owner account1 commands wallet to send 11 wei to account2
|
||||
txnHash = await wallet.execute(accounts[2], 2, hash);
|
||||
|
||||
//Balance of account2 should change
|
||||
newAccountBalance = web3.eth.getBalance(accounts[2]);
|
||||
assert.isTrue(newAccountBalance > accountBalance);
|
||||
});
|
||||
|
||||
});
|
||||
@ -1,103 +0,0 @@
|
||||
var ShareableMock = artifacts.require("./helpers/ShareableMock.sol");
|
||||
|
||||
contract('Shareable', function(accounts) {
|
||||
|
||||
it('should construct with correct owners and number of sigs required', async function() {
|
||||
let requiredSigs = 2;
|
||||
let owners = accounts.slice(1,4);
|
||||
let shareable = await ShareableMock.new(owners, requiredSigs);
|
||||
|
||||
let required = await shareable.required();
|
||||
assert.equal(required, requiredSigs);
|
||||
let owner = await shareable.getOwner(0);
|
||||
assert.equal(owner, accounts[0]);
|
||||
|
||||
for(let i = 0; i < accounts.length; i++) {
|
||||
let owner = await shareable.getOwner(i);
|
||||
let isowner = await shareable.isOwner(accounts[i]);
|
||||
if(i <= owners.length) {
|
||||
assert.equal(accounts[i], owner);
|
||||
assert.isTrue(isowner);
|
||||
} else {
|
||||
assert.notEqual(accounts[i], owner);
|
||||
assert.isFalse(isowner);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it('should only perform multisig function with enough sigs', async function() {
|
||||
let requiredSigs = 3;
|
||||
let owners = accounts.slice(1,4);
|
||||
let shareable = await ShareableMock.new(owners, requiredSigs);
|
||||
let hash = 1234;
|
||||
|
||||
let initCount = await shareable.count();
|
||||
initCount = initCount.toString();
|
||||
|
||||
for(let i = 0; i < requiredSigs; i++) {
|
||||
await shareable.increaseCount(hash, {from: accounts[i]});
|
||||
let count = await shareable.count();
|
||||
if(i == requiredSigs - 1) {
|
||||
assert.equal(Number(initCount)+1, count.toString());
|
||||
} else {
|
||||
assert.equal(initCount, count.toString());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it('should require approval from different owners', async function() {
|
||||
let requiredSigs = 2;
|
||||
let owners = accounts.slice(1,4);
|
||||
let shareable = await ShareableMock.new(owners, requiredSigs);
|
||||
let hash = 1234;
|
||||
|
||||
let initCount = await shareable.count();
|
||||
initCount = initCount.toString();
|
||||
|
||||
//Count shouldn't increase when the same owner calls repeatedly
|
||||
for(let i = 0; i < 2; i++) {
|
||||
await shareable.increaseCount(hash);
|
||||
let count = await shareable.count();
|
||||
assert.equal(initCount, count.toString());
|
||||
}
|
||||
});
|
||||
|
||||
it('should reset sig count after operation is approved', async function() {
|
||||
let requiredSigs = 3;
|
||||
let owners = accounts.slice(1,4);
|
||||
let shareable = await ShareableMock.new(owners, requiredSigs);
|
||||
let hash = 1234;
|
||||
|
||||
let initCount = await shareable.count();
|
||||
|
||||
for(let i = 0; i < requiredSigs * 3; i++) {
|
||||
await shareable.increaseCount(hash, {from: accounts[i % 4]});
|
||||
let count = await shareable.count();
|
||||
if((i%(requiredSigs)) == requiredSigs - 1) {
|
||||
initCount = Number(initCount)+1;
|
||||
assert.equal(initCount, count);
|
||||
} else {
|
||||
assert.equal(initCount.toString(), count);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it('should not perform multisig function after an owner revokes', async function() {
|
||||
let requiredSigs = 3;
|
||||
let owners = accounts.slice(1,4);
|
||||
let shareable = await ShareableMock.new(owners, requiredSigs);
|
||||
let hash = 1234;
|
||||
|
||||
let initCount = await shareable.count();
|
||||
|
||||
for(let i = 0; i < requiredSigs; i++) {
|
||||
if(i == 1) {
|
||||
await shareable.revoke(hash, {from: accounts[i-1]});
|
||||
}
|
||||
await shareable.increaseCount(hash, {from: accounts[i]});
|
||||
let count = await shareable.count();
|
||||
assert.equal(initCount.toString(), count);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
@ -1,12 +0,0 @@
|
||||
pragma solidity ^0.4.11;
|
||||
import "../../contracts/MultisigWallet.sol";
|
||||
|
||||
contract MultisigWalletMock is MultisigWallet {
|
||||
uint256 public totalSpending;
|
||||
|
||||
function MultisigWalletMock(address[] _owners, uint256 _required, uint256 _daylimit)
|
||||
MultisigWallet(_owners, _required, _daylimit) payable { }
|
||||
|
||||
function changeOwner(address _from, address _to) external { }
|
||||
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
pragma solidity ^0.4.11;
|
||||
import "../../contracts/ownership/Shareable.sol";
|
||||
|
||||
contract ShareableMock is Shareable {
|
||||
|
||||
uint256 public count = 0;
|
||||
|
||||
function ShareableMock(address[] _owners, uint256 _required) Shareable(_owners, _required) {
|
||||
|
||||
}
|
||||
|
||||
function increaseCount(bytes32 action) onlymanyowners(action) {
|
||||
count = count + 1;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user