Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nmushegian/e655af82ced9e79f931b5fad69b3a0a1 to your computer and use it in GitHub Desktop.
Save nmushegian/e655af82ced9e79f931b5fad69b3a0a1 to your computer and use it in GitHub Desktop.
contract MyTargetInterface {
function func1(int arg1, int arg2) returns (int ret);
function func2(bytes32 arg1) returns (bytes32 ret);
}
contract MyActions is DSControlledAction, MyTargetInterface {
function MyActions( DSNullMap env ) DSControlledAction( env ) {}
function func1(int arg1, int arg2) returns (int ret) {
setReturn(bytes32(arg1 + arg2));
return 0; // doesn't matter
}
function func2(bytes32 adder_location) returns (bytes32 ret) {
// Dev doesn't care it's actually also the same controller/action objects - that's an implementation detail
var adder = MyTargetInterface(address(getEnv(adder_location)));
setReturn(bytes32(adder.func1(1, 2)));
}
}
contract DSControllerTest is Test {
DSController controller;
function setUp() {
controller = new DSController();
controller.set("adder", controller);
DSControlledAction actions = DSControlledAction(new MyActions(controller));
var sig1 = bytes4(sha3("func1(int256,int256)"));
var sig2 = bytes4(sha3("func2(int256,int256)"));
controller._ds_pushAction(sig1, actions, 0, true);
controller._ds_pushAction(sig2, actions, 0, true);
}
function testBasic() {
assertEq(3, MyTargetInterface(controller).func2("adder"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment