diff options
author | Florian Dold <florian.dold@gmail.com> | 2020-09-01 18:00:46 +0530 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2020-09-01 18:00:51 +0530 |
commit | 5056da6548d5880211abd3e1cdacd92134e40dab (patch) | |
tree | db7ede721ddd33c52dd862562b340f0782dabb22 /packages/taler-integrationtests/src/test-timetravel.ts | |
parent | 5e7149f79eeb9988a7da45ecc8573c65e9680082 (diff) | |
download | wallet-core-5056da6548d5880211abd3e1cdacd92134e40dab.tar.gz wallet-core-5056da6548d5880211abd3e1cdacd92134e40dab.tar.bz2 wallet-core-5056da6548d5880211abd3e1cdacd92134e40dab.zip |
test error handling
Diffstat (limited to 'packages/taler-integrationtests/src/test-timetravel.ts')
-rw-r--r-- | packages/taler-integrationtests/src/test-timetravel.ts | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/packages/taler-integrationtests/src/test-timetravel.ts b/packages/taler-integrationtests/src/test-timetravel.ts index acc770d5d..086606b90 100644 --- a/packages/taler-integrationtests/src/test-timetravel.ts +++ b/packages/taler-integrationtests/src/test-timetravel.ts @@ -17,9 +17,18 @@ /** * Imports. */ -import { runTest, GlobalTestState, MerchantPrivateApi, WalletCli } from "./harness"; -import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers"; -import { PreparePayResultType, durationMin, Duration } from "taler-wallet-core"; +import { + runTest, + GlobalTestState, + MerchantPrivateApi, + WalletCli, +} from "./harness"; +import { + createSimpleTestkudosEnvironment, + withdrawViaBank, + startWithdrawViaBank, +} from "./helpers"; +import { PreparePayResultType, durationMin, Duration, TransactionType } from "taler-wallet-core"; /** * Basic time travel test. @@ -36,7 +45,7 @@ runTest(async (t: GlobalTestState) => { // Withdraw digital cash into the wallet. - await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:20" }); + await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:15" }); // Travel 400 days into the future, // as the deposit expiration is two years @@ -56,9 +65,28 @@ runTest(async (t: GlobalTestState) => { await merchant.pingUntilAvailable(); // This should fail, as the wallet didn't time travel yet. - await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:20" }); + await startWithdrawViaBank(t, { + wallet, + bank, + exchange, + amount: "TESTKUDOS:20", + }); + + // Check that transactions are correct for the failed withdrawal + { + await wallet.runUntilDone({ maxRetries: 5 }); + const transactions = await wallet.getTransactions(); + console.log(transactions); + const types = transactions.transactions.map((x) => x.type); + t.assertDeepEqual(types, ["withdrawal", "withdrawal"]); + const wtrans = transactions.transactions[0]; + t.assertTrue(wtrans.type === TransactionType.Withdrawal); + t.assertTrue(wtrans.pending); + } + + // Now we also let the wallet time travel - const bal = await wallet.getBalances(); + wallet.setTimetravel(timetravelDuration); - console.log(bal); + await wallet.runUntilDone({ maxRetries: 5 }); }); |