aboutsummaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2020-11-16 14:52:12 +0100
committerFlorian Dold <florian@dold.me>2020-11-16 14:52:16 +0100
commit768ecfc6008ff31cb1ac06f84dc082e2c8dac627 (patch)
tree7af6a34a569bbf9fb9d2abf614e28342fa9dd899 /packages
parent7e07ad6b2abda4731c0d90038df179296f93d3b7 (diff)
check for idempotency in tip integration test
Diffstat (limited to 'packages')
-rw-r--r--packages/taler-integrationtests/src/test-tipping.ts46
1 files changed, 27 insertions, 19 deletions
diff --git a/packages/taler-integrationtests/src/test-tipping.ts b/packages/taler-integrationtests/src/test-tipping.ts
index 6703ab4b2..4735de81a 100644
--- a/packages/taler-integrationtests/src/test-tipping.ts
+++ b/packages/taler-integrationtests/src/test-tipping.ts
@@ -87,34 +87,42 @@ runTest(async (t: GlobalTestState) => {
console.log("created tip", tip);
- const ptr = await wallet.prepareTip({
- talerTipUri: tip.taler_tip_uri,
- });
+ const doTip = async (): Promise<void> => {
+ const ptr = await wallet.prepareTip({
+ talerTipUri: tip.taler_tip_uri,
+ });
- console.log(ptr);
+ console.log(ptr);
- t.assertAmountEquals(ptr.tipAmountRaw, "TESTKUDOS:5");
- t.assertAmountEquals(ptr.tipAmountEffective, "TESTKUDOS:4.85");
+ t.assertAmountEquals(ptr.tipAmountRaw, "TESTKUDOS:5");
+ t.assertAmountEquals(ptr.tipAmountEffective, "TESTKUDOS:4.85");
- await wallet.acceptTip({
- walletTipId: ptr.walletTipId,
- });
+ await wallet.acceptTip({
+ walletTipId: ptr.walletTipId,
+ });
+ await wallet.runUntilDone();
- await wallet.runUntilDone();
+ const bal = await wallet.getBalances();
- const bal = await wallet.getBalances();
+ console.log(bal);
- console.log(bal);
+ t.assertAmountEquals(bal.balances[0].available, "TESTKUDOS:4.85");
- t.assertAmountEquals(bal.balances[0].available, "TESTKUDOS:4.85");
+ const txns = await wallet.getTransactions();
- const txns = await wallet.getTransactions();
+ console.log("Transactions:", JSON.stringify(txns, undefined, 2));
- console.log("Transactions:", JSON.stringify(txns, undefined, 2));
+ t.assertDeepEqual(txns.transactions[0].type, "tip");
+ t.assertDeepEqual(txns.transactions[0].pending, false);
+ t.assertAmountEquals(
+ txns.transactions[0].amountEffective,
+ "TESTKUDOS:4.85",
+ );
+ t.assertAmountEquals(txns.transactions[0].amountRaw, "TESTKUDOS:5.0");
+ };
- t.assertDeepEqual(txns.transactions[0].type, "tip");
- t.assertDeepEqual(txns.transactions[0].pending, false);
- t.assertAmountEquals(txns.transactions[0].amountEffective, "TESTKUDOS:4.85");
- t.assertAmountEquals(txns.transactions[0].amountRaw, "TESTKUDOS:5.0");
+ // Check twice so make sure tip handling is idempotent
+ await doTip();
+ await doTip();
});