Created
May 25, 2016 11:39
-
-
Save nmushegian/e98f5bb2f473459c2791653d0da12e43 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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( DSController 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()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment