Browse Source

add PullPaymentCapable test

Manuel Araoz 9 years ago
parent
commit
8f4027cdf6
2 changed files with 35 additions and 0 deletions
  1. 26 0
      test/PullPaymentCapable.js
  2. 9 0
      test/PullPaymentCapableExample.sol

+ 26 - 0
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);
+  });
+
+});

+ 9 - 0
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);
+  }
+}