Skip to content

Commit

Permalink
Merge pull request #593 from daostack/wallet
Browse files Browse the repository at this point in the history
add wallet.sol
  • Loading branch information
leviadam authored Jan 31, 2019
2 parents 8dfd70d + b407f47 commit 14acc6f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
20 changes: 20 additions & 0 deletions contracts/test/Wallet.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
pragma solidity ^0.5.2;
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";


contract Wallet is Ownable {

event ReceiveEther(address indexed _sender, uint256 _value);
event Pay(address indexed _sender, uint256 _value);

function() external payable {
emit ReceiveEther(msg.sender, msg.value);
}

function pay(address payable _beneficiary) public onlyOwner {
uint256 amount = address(this).balance;
_beneficiary.transfer(amount);
emit Pay(_beneficiary, amount);
}

}
20 changes: 18 additions & 2 deletions test/genericscheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ const GenericScheme = artifacts.require('./GenericScheme.sol');
const DaoCreator = artifacts.require("./DaoCreator.sol");
const ControllerCreator = artifacts.require("./ControllerCreator.sol");
const ERC20Mock = artifacts.require("./ERC20Mock.sol");


const ActionMock = artifacts.require("./ActionMock.sol");
const Wallet = artifacts.require("./Wallet.sol");

export class GenericSchemeParams {
constructor() {
Expand Down Expand Up @@ -232,4 +231,21 @@ contract('genericScheme', function(accounts) {
assert.equal(events[0].args._param,2);
});
});

it("Wallet - execute proposeVote -positive decision - check action - with GenesisProtocol", async function() {
var wallet =await Wallet.new();
await web3.eth.sendTransaction({from:accounts[0],to:wallet.address, value: web3.utils.toWei('1', "ether")});
var standardTokenMock = await ERC20Mock.new(accounts[0],1000);
var testSetup = await setup(accounts,wallet.address,0,true,standardTokenMock.address);
var callData = await new web3.eth.Contract(wallet.abi).methods.pay(accounts[1]).encodeABI();
var tx = await testSetup.genericScheme.proposeCall(testSetup.org.avatar.address,callData,helpers.NULL_HASH);
var proposalId = await helpers.getValueFromLogs(tx, '_proposalId');
assert.equal(await web3.eth.getBalance(wallet.address),web3.utils.toWei('1', "ether"));
await testSetup.genericSchemeParams.votingMachine.genesisProtocol.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]});
assert.equal(await web3.eth.getBalance(wallet.address),web3.utils.toWei('1', "ether"));
await wallet.transferOwnership(testSetup.org.avatar.address);
await testSetup.genericScheme.execute(proposalId);
assert.equal(await web3.eth.getBalance(wallet.address),0);
});

});

0 comments on commit 14acc6f

Please sign in to comment.