commit
570d6cb940
@ -0,0 +1,9 @@ |
|||||||
|
import '../PullPaymentCapable.sol'; |
||||||
|
|
||||||
|
// Example class using PullPaymentCapable |
||||||
|
contract PullPaymentCapableExample is PullPaymentCapable { |
||||||
|
// test helper function to call asyncSend |
||||||
|
function callSend(address dest, uint amount) external { |
||||||
|
asyncSend(dest, amount); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,9 @@ |
|||||||
|
import '../PullPayment.sol'; |
||||||
|
|
||||||
|
// mock class using PullPayment |
||||||
|
contract PullPaymentMock is PullPayment { |
||||||
|
// test helper function to call asyncSend |
||||||
|
function callSend(address dest, uint amount) external { |
||||||
|
asyncSend(dest, amount); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,29 @@ |
|||||||
|
contract('PullPaymentCapable', function(accounts) { |
||||||
|
|
||||||
|
it("can't call asyncSend externally", function(done) { |
||||||
|
var ppc; |
||||||
|
return PullPaymentCapableExample.new() |
||||||
|
.then(function(ppc) { |
||||||
|
assert.isUndefined(ppc.asyncSend); |
||||||
|
}) |
||||||
|
.then(done); |
||||||
|
}); |
||||||
|
|
||||||
|
it("can record an async payment correctly", function(done) { |
||||||
|
var ppce; |
||||||
|
var AMOUNT = 100; |
||||||
|
return PullPaymentCapableExample.new() |
||||||
|
.then(function(_ppce) { |
||||||
|
ppce = _ppce; |
||||||
|
ppce.callSend(accounts[0], AMOUNT) |
||||||
|
}) |
||||||
|
.then(function() { |
||||||
|
return ppce.payments(accounts[0]); |
||||||
|
}) |
||||||
|
.then(function(paymentsToAccount0) { |
||||||
|
assert.equal(paymentsToAccount0, AMOUNT); |
||||||
|
}) |
||||||
|
.then(done); |
||||||
|
}); |
||||||
|
|
||||||
|
}); |
Loading…
Reference in new issue