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
import 'dapple/test/test.sol'; | |
import 'mydapp/math.sol'; | |
contract MathTest is Test { | |
Math m; | |
function setUp() { | |
m = new Math(); | |
} | |
function testAdd() { | |
// tests start with `test`. Each is called on a new |
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
import 'dappsys/test/debug.sol'; | |
contract Test is Debug { | |
bytes32 testname; | |
address me; | |
// easy way to detect if its a test from the abi | |
bool public IS_TEST; | |
bool public failed; | |
function Test() { | |
me = address(this); |
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
### Keybase proof | |
I hereby claim: | |
* I am nmushegian on github. | |
* I am nikolai (https://keybase.io/nikolai) on keybase. | |
* I have a public key ASDofU01Z_R3rrE14Z8hXW7SoYlDl8TngurdU66CLi_w0Qo | |
To claim this, I am signing this object: |
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 |
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 |
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( DSNullMap env ) DSControlledAction( env ) {} | |
function func1(int arg1, int arg2) returns (int ret) { | |
setReturn(bytes32(arg1 + arg2)); | |
return 0; // doesn't matter |
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
import 'erc20/erc20.sol' | |
import 'feedbase/user.sol'; | |
contract TokenOption is FeedBaseUser(0) { | |
address _beneficiary; | |
ERC20 _token; | |
ERC20 _buy_with; | |
address _optionee; | |
uint _expiration; | |
uint _price; |
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
``` | |
// This code snippet shows how an external function can use a pattern like | |
// python's `try..except..else` with `.call`, `throw`, and reentry | |
contract TryExceptElsePatternUser { | |
address _sender; | |
function tryExceptElsePatternExample() | |
external // must be external | |
{ | |
if( msg.sender == address(this) ) { |
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
// This is a really bad and wasteful pattern from a long time ago! | |
// Just prorate against an internal continuously-growing conversion rate! | |
// See Maker code or similar | |
import 'dappsys/auth.sol'; | |
import 'misc/math.sol'; | |
// maintain a `last_touched` with each balance, then prorate it before any time it is touched. | |
// addPoint to change the rate | |
// this will ensure all balances appear to have the correct continuous growth/decay even if |
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 When { | |
modifier when(bool b) { b||1/0;_; } | |
} |
OlderNewer