Commit 570d6cb9 by Manuel Aráoz Committed by GitHub

Merge pull request #24 from maraoz/ppc-test

add PullPaymentCapable test
parents 8ad21ca8 503faa05
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* Inherit from this contract and use asyncSend instead of send. * Inherit from this contract and use asyncSend instead of send.
*/ */
contract PullPaymentCapable { contract PullPaymentCapable {
mapping(address => uint) payments; mapping(address => uint) public payments;
// store sent amount as credit to be pulled, called by payer // store sent amount as credit to be pulled, called by payer
function asyncSend(address dest, uint amount) internal { function asyncSend(address dest, uint amount) internal {
......
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);
}
}
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);
}
}
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);
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment