From 8f4027cdf6408355afb28b6225b32de39d31c9f1 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Fri, 30 Sep 2016 18:13:10 -0300 Subject: [PATCH] add PullPaymentCapable test --- test/PullPaymentCapable.js | 26 ++++++++++++++++++++++++++ test/PullPaymentCapableExample.sol | 9 +++++++++ 2 files changed, 35 insertions(+) create mode 100644 test/PullPaymentCapable.js create mode 100644 test/PullPaymentCapableExample.sol diff --git a/test/PullPaymentCapable.js b/test/PullPaymentCapable.js new file mode 100644 index 000000000..92c41a3d0 --- /dev/null +++ b/test/PullPaymentCapable.js @@ -0,0 +1,26 @@ +contract('PullPaymentCapable', function(accounts) { + + it("can't call asyncSend externally", function(done) { + var ppc = PullPaymentCapable.new(); + assert.isUndefined(ppc.asyncSend); + done(); + }); + + it("can record an async payment correctly", function(done) { + var ppce; + var AMOUNT = 1000; + 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); + }); + +}); diff --git a/test/PullPaymentCapableExample.sol b/test/PullPaymentCapableExample.sol new file mode 100644 index 000000000..e467f09da --- /dev/null +++ b/test/PullPaymentCapableExample.sol @@ -0,0 +1,9 @@ +import '../contracts/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); + } +}