Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions contracts/controller/Controller.sol
Original file line number Diff line number Diff line change
Expand Up @@ -419,15 +419,15 @@ contract Controller is ControllerInterface {
onlyGenericCallScheme
onlySubjectToConstraint("genericCall")
isAvatarValid(_avatar)
returns (bytes32)
returns (bytes32 returnValue)
{
emit GenericCall(_contract, _data);
avatar.genericCall(_contract, _data);
// solium-disable-next-line security/no-inline-assembly
assembly {
// Copy the returned data.
returndatacopy(0, 0, returndatasize)
return(0, returndatasize)
returndatacopy(returnValue, 0, returndatasize)
return(returnValue, 0x20)
}
}

Expand Down
6 changes: 3 additions & 3 deletions contracts/controller/UController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -402,15 +402,15 @@ contract UController is ControllerInterface {
external
onlyGenericCallScheme(_avatar)
onlySubjectToConstraint("genericCall",_avatar)
returns (bytes32)
returns (bytes32 returnValue)
{
emit GenericCall(_contract, _data,_avatar);
(Avatar(_avatar)).genericCall(_contract, _data);
// solium-disable-next-line security/no-inline-assembly
assembly {
// Copy the returned data.
returndatacopy(0, 0, returndatasize)
return(0, returndatasize)
returndatacopy(returnValue, 0, returndatasize)
return(returnValue, 0x20)
}
}

Expand Down
6 changes: 6 additions & 0 deletions contracts/test/ActionMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "../controller/Avatar.sol";

contract ActionMock {

event WithoutReturnValue(address _addr);
function test(uint _a,address _b,bytes32 _c) public view returns(uint) {
require(_a == 7);
require(_b == address(this));
Expand All @@ -17,4 +18,9 @@ contract ActionMock {
return true;
}

function withoutReturnValue(address _addr) public {
require(msg.sender == _addr,"the caller must be equal to _addr");
emit WithoutReturnValue(_addr);
}

}
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@daostack/arc",
"version": "0.0.0-alpha.50",
"version": "0.0.0-alpha.51",
"description": "A platform for building DAOs",
"files": [
"contracts/",
Expand Down
578 changes: 296 additions & 282 deletions test/controller.js

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions test/genericscheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,17 @@ contract('genericScheme', function(accounts) {
}
});

it("execute proposeVote without return value-positive decision - check action", async function() {
var actionMock =await ActionMock.new();
var testSetup = await setup(accounts,actionMock.address);
const extraData = await actionMock.withoutReturnValue.request(testSetup.org.avatar.address);
var tx = await testSetup.genericScheme.proposeCall(testSetup.org.avatar.address,extraData.params[0].data);
var proposalId = await helpers.getValueFromLogs(tx, '_proposalId');

await testSetup.genericSchemeParams.votingMachine.absoluteVote.vote(proposalId,1,{from:accounts[2]});

});

it("execute proposeVote -positive decision - check action - with GenesisProtocol", async function() {
var actionMock =await ActionMock.new();
var standardTokenMock = await StandardTokenMock.new(accounts[0],1000);
Expand Down
13 changes: 13 additions & 0 deletions test/ucontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,19 @@ contract('UController', function (accounts) {
assert.equal(result, 14);

});
it("generic call withoutReturnValue", async () => {
controller = await setup('0x00000010');
let actionMock = await ActionMock.new();
const extraData = await actionMock.withoutReturnValue.request(avatar.address);
var tx = await controller.genericCall(actionMock.address,extraData.params[0].data,avatar.address);
const log = await new Promise((resolve) => {
actionMock.WithoutReturnValue({_addr: avatar.address}, {fromBlock: tx.blockNumber})
.get((err,events) => {
resolve(events);
});
});
assert.equal(log[0].event,"WithoutReturnValue");
});

it("generic call via contract scheme", async () => {
var scheme = await UniversalSchemeMock.new();
Expand Down