Skip to content

Commit

Permalink
#54
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirill authored and Kirill committed Sep 4, 2018
1 parent 1bf1af9 commit c330c2d
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 19 deletions.
13 changes: 7 additions & 6 deletions contracts/3-DevZenDao/DevZenDaoAuto.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ contract DevZenDaoAuto is GenericCaller{
devZenDao = _devZenDao;
}

// function updateDaoParamsAuto(DevZenDao.Params _params) public returns(address proposalOut) {
// emit UpdateDaoParamsAuto();
// bytes32[] memory params = new bytes32[](1);
// params[0] = bytes32(_params);
// return doAction(devZenDao.DEV_ZEN_UPDATE_DAO_PARAMS(), dao, msg.sender, "updateDaoParamsGeneric(bytes32[])", params);
// }
function updateDaoParamsAuto(bytes32 _param, uint _value) public returns(address proposalOut) {
emit UpdateDaoParamsAuto();
bytes32[] memory params = new bytes32[](2);
params[0] = _param;
params[1] = bytes32(_value);
return doAction(devZenDao.DEV_ZEN_UPDATE_DAO_PARAMS(), devZenDao, msg.sender, "updateDaoParamsGeneric(bytes32[])", params);
}

function withdrawEtherAuto(address _output) public returns(address proposalOut) {
emit WithdrawEtherAuto();
Expand Down
11 changes: 6 additions & 5 deletions contracts/3-DevZenDao/DevZenDaoAutoTestable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ contract DevZenDaoAutoTestable is GenericCaller{
devZenDao = _devZenDao;
}

// function updateDaoParamsAuto(DevZenDao.Params _params) public returns(address proposalOut) {
// bytes32[] memory params = new bytes32[](1);
// params[0] = bytes32(_params);
// return doAction(devZenDao.DEV_ZEN_UPDATE_DAO_PARAMS(), dao, msg.sender, "updateDaoParamsGeneric(bytes32[])", params);
// }
function updateDaoParamsAuto(bytes32 _param, uint _value) public returns(address proposalOut) {
bytes32[] memory params = new bytes32[](2);
params[0] = _param;
params[1] = bytes32(_value);
return doAction(devZenDao.DEV_ZEN_UPDATE_DAO_PARAMS(), dao, msg.sender, "updateDaoParamsGeneric(bytes32[])", params);
}

function withdrawEtherAuto(address _output) public returns(address proposalOut) {
bytes32[] memory params = new bytes32[](1);
Expand Down
9 changes: 5 additions & 4 deletions contracts/3-DevZenDao/DevZenDaoWithUnpackers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ contract DevZenDaoWithUnpackers is DevZenDao {
constructor(IDaoBase _daoBase, address[] _tokens) public
DevZenDao(_daoBase, _tokens){}

// function updateDaoParamsGeneric(bytes32[] _params) external {
// address params = address(_params[0]);
// updateDaoParams(params);
// }
function updateDaoParamsGeneric(bytes32[] _params) external {
bytes32 param = _params[0];
uint value = uint(_params[1]);
setParam(param, value);
}

function withdrawEtherGeneric(bytes32[] _params) external {
address output = address(_params[0]);
Expand Down
9 changes: 5 additions & 4 deletions contracts/3-DevZenDao/DevZenDaoWithUnpackersTestable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ contract DevZenDaoWithUnpackersTestable is DevZenDaoTestable {
constructor(IDaoBase _daoBase, address[] _tokens) public
DevZenDaoTestable(_daoBase, _tokens){}

// function updateDaoParamsGeneric(bytes32[] _params) external {
// address params = address(_params[0]);
// updateDaoParams(params);
// }
function updateDaoParamsGeneric(bytes32[] _params) external {
bytes32 param = _params[0];
uint value = uint(_params[1]);
setParam(param, value);
}

function withdrawEtherGeneric(bytes32[] _params) external {
address output = address(_params[0]);
Expand Down
15 changes: 15 additions & 0 deletions test/DevZenDao.functional.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,4 +264,19 @@ contract("DevZenDaoAuto", (accounts) => {
assert.equal(dztBalanceAfter.toNumber(), 5e18, "guest's 5 DZT were tansfered back to guest");
});
});

describe("updateDaoParamsAuto", () => {
it("should update param", async() => {
let paramHash = await devZenDao.MINT_TOKENS_PER_WEEK_AMOUNT();
let paramValueBefore = await devZenDao.params(paramHash);
await devZenDaoAuto.updateDaoParamsAuto(paramHash, paramValueBefore.toNumber()*2, {from:teamMember1}).should.be.fulfilled;
voting = await getVoting(daoBase,0);
await checkVoting(voting, 1, 0, false, false);
await voting.vote(true,{from:teamMember2});
await checkVoting(voting, 2, 0, true, true);

let paramValueAfter = await devZenDao.params(paramHash);
assert.equal(paramValueBefore.toNumber()*2, paramValueAfter.toNumber());
});
});
});
9 changes: 9 additions & 0 deletions test/DevZenDao.testable.functional.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,4 +459,13 @@ contract("DevZenDaoCore", (accounts) => {
});
});

describe("setParam", () => {
it("should set param", async() => {
let paramHash = await devZenDao.MINT_TOKENS_PER_WEEK_AMOUNT();
let paramValueBefore = await devZenDao.params(paramHash);
await devZenDao.setParam(paramHash, 2*paramValueBefore.toNumber()).should.be.fulfilled;
let paramValueAfter = await devZenDao.params(paramHash);
assert.equal(paramValueBefore.toNumber()*2, paramValueAfter.toNumber());
});
});
});

0 comments on commit c330c2d

Please sign in to comment.