gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] branch master updated: Add more checks to new withdr


From: gnunet
Subject: [taler-wallet-core] branch master updated: Add more checks to new withdrawal API test
Date: Wed, 29 Jul 2020 14:34:01 +0200

This is an automated email from the git hooks/post-receive script.

torsten-grote pushed a commit to branch master
in repository wallet-core.

The following commit(s) were added to refs/heads/master by this push:
     new 9a4cbcd9 Add more checks to new withdrawal API test
9a4cbcd9 is described below

commit 9a4cbcd9549fee9865a537ed5236e2a2ebe52cf1
Author: Torsten Grote <t@grobox.de>
AuthorDate: Wed Jul 29 09:33:41 2020 -0300

    Add more checks to new withdrawal API test
---
 tests/__init__.py        | 14 ++++++++++----
 tests/components/bank.py | 15 +++++++--------
 tests/test_withdrawal.py | 32 ++++++++++++++++++++++++--------
 3 files changed, 41 insertions(+), 20 deletions(-)

diff --git a/tests/__init__.py b/tests/__init__.py
index 9f0dc11d..333953b9 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -1,11 +1,13 @@
+import json
+
 from taler.util.amount import Amount
 
 
 def check_single_balance(
-    balances,
-    available,
-    pending_in=Amount.parse("TESTKUDOS:0"),
-    pending_out=Amount.parse("TESTKUDOS:0"),
+        balances,
+        available,
+        pending_in=Amount.parse("TESTKUDOS:0"),
+        pending_out=Amount.parse("TESTKUDOS:0"),
 ):
     assert len(balances) == 1
     assert Amount.parse(balances[0]["available"]) == available
@@ -15,3 +17,7 @@ def check_single_balance(
 
 def json_to_amount(d):
     return Amount(d["currency"], d["value"], d["fraction"])
+
+
+def print_json(obj):
+    print(json.dumps(obj, indent=2))
diff --git a/tests/components/bank.py b/tests/components/bank.py
index ee2d6e92..f6551b49 100644
--- a/tests/components/bank.py
+++ b/tests/components/bank.py
@@ -1,21 +1,20 @@
 import os
+import secrets
+from dataclasses import dataclass
 from subprocess import run
 
 import psutil
-
 import requests
 
-import secrets
-
 from .taler_service import TalerService
 
-from dataclasses import dataclass
 
 @dataclass
 class BankUser:
     username: str
     password: str
 
+
 @dataclass
 class WithdrawUriResponse:
     taler_withdraw_uri: str
@@ -71,10 +70,10 @@ class Bank(TalerService):
             withdrawal_id=rj["withdrawal_id"],
         )
 
-    def confirm_withdrawal(self, bankuser, withdrawal_id):
-        auth = (bankuser.username, bankuser.password)
-        resp = requests.post(
-            
f"{self.url}accounts/{bankuser.username}/withdrawals/{withdrawal_id}/confirm",
+    def confirm_withdrawal(self, bank_user, withdrawal_id):
+        auth = (bank_user.username, bank_user.password)
+        requests.post(
+            
f"{self.url}accounts/{bank_user.username}/withdrawals/{withdrawal_id}/confirm",
             auth=auth
         )
 
diff --git a/tests/test_withdrawal.py b/tests/test_withdrawal.py
index 0f5c8435..6392891f 100644
--- a/tests/test_withdrawal.py
+++ b/tests/test_withdrawal.py
@@ -78,13 +78,11 @@ def test_withdrawal(exchange, bank, wallet):
     confirm_url = result["confirmTransferUrl"]
 
     # Let the wallet do its work.  At this point, the bank-integrated
-    # withdrawal won't have succeeded yet, as it's not confirmed at the bank
-    # side.
+    # withdrawal won't have succeeded yet, as it's not confirmed at the bank 
side.
     wallet.run_pending()
 
     # check that balance is correct
     result = wallet.cmd("getBalances")
-    print(result)
     check_single_balance(result["balances"], amount_effective, 
amount_effective)
 
     # assert that 2nd withdrawal shows up properly in transactions
@@ -114,11 +112,18 @@ def test_withdrawal(exchange, bank, wallet):
 
     # check that balance is correct
     result = wallet.cmd("getBalances")
-    print(result)
     check_single_balance(
         result["balances"], Amount.parse("TESTKUDOS:9.68"), 
Amount.parse("TESTKUDOS:0"),
     )
 
+    # check that transaction is no longer pending, but confirmed
+    result = wallet.cmd("getTransactions")
+    assert len(result["transactions"]) == 2
+    transaction = result["transactions"][1]  # TODO this transaction should be 
at the top now
+    assert transaction["type"] == "withdrawal"
+    assert not transaction["pending"]
+    assert transaction["withdrawalDetails"]["confirmed"]
+
     # one more manual withdrawal
     request = {"exchangeBaseUrl": exchange.url, "amount": 
amount_raw.stringify()}
     result = wallet.cmd("acceptManualWithdrawal", request)
@@ -127,7 +132,6 @@ def test_withdrawal(exchange, bank, wallet):
 
     # check that balance is correct
     result = wallet.cmd("getBalances")
-    print(result)
     check_single_balance(
         result["balances"], amount_effective + amount_effective, 
amount_effective
     )
@@ -135,6 +139,18 @@ def test_withdrawal(exchange, bank, wallet):
     # assert that 3nd withdrawal shows up properly in transactions
     result = wallet.cmd("getTransactions")
     assert len(result["transactions"]) == 3
-    for t in result["transactions"]:
-        print(t)
-        print()
+    transaction = result["transactions"][0]
+    assert transaction["type"] == "withdrawal"
+    assert Amount.parse(transaction["amountEffective"]) == amount_effective
+    assert Amount.parse(transaction["amountRaw"]) == amount_raw
+    assert transaction["exchangeBaseUrl"] == exchange.url
+    assert transaction["pending"]
+    withdrawal_details = transaction["withdrawalDetails"]
+    assert withdrawal_details["type"] == "manual-transfer"
+    assert len(withdrawal_details["exchangePaytoUris"]) == 1
+    assert withdrawal_details["exchangePaytoUris"][0].startswith(payto_list[0])
+
+    # last withdrawal is newest
+    timestamp3 = transaction["timestamp"]["t_ms"]
+    assert timestamp3 > timestamp0
+    assert timestamp3 > timestamp1

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]