diff options
author | Florian Dold <florian@dold.me> | 2020-11-16 14:52:12 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2020-11-16 14:52:16 +0100 |
commit | 768ecfc6008ff31cb1ac06f84dc082e2c8dac627 (patch) | |
tree | 7af6a34a569bbf9fb9d2abf614e28342fa9dd899 | |
parent | 7e07ad6b2abda4731c0d90038df179296f93d3b7 (diff) | |
download | wallet-core-768ecfc6008ff31cb1ac06f84dc082e2c8dac627.tar.xz |
check for idempotency in tip integration test
-rw-r--r-- | packages/taler-integrationtests/src/test-tipping.ts | 46 |
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(); }); |