diff options
author | Florian Dold <florian@dold.me> | 2021-06-22 13:52:28 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2021-06-22 13:52:28 +0200 |
commit | e35c2f581b49f6441b6f75bb9ce0a1677d5fb46f (patch) | |
tree | 1e94c19f47e6f4461977a5d2ee536439092acbb2 /packages/taler-wallet-cli/src/integrationtests | |
parent | 7383b89cabbfdb8f2fbd6bb9e7b64d09385f7bea (diff) | |
download | wallet-core-e35c2f581b49f6441b6f75bb9ce0a1677d5fb46f.tar.xz |
simplify task loop, test coin suspension
Diffstat (limited to 'packages/taler-wallet-cli/src/integrationtests')
-rw-r--r-- | packages/taler-wallet-cli/src/integrationtests/test-wallettesting.ts | 64 |
1 files changed, 61 insertions, 3 deletions
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-wallettesting.ts b/packages/taler-wallet-cli/src/integrationtests/test-wallettesting.ts index 5fb017edd..2499e65a0 100644 --- a/packages/taler-wallet-cli/src/integrationtests/test-wallettesting.ts +++ b/packages/taler-wallet-cli/src/integrationtests/test-wallettesting.ts @@ -22,8 +22,9 @@ /** * Imports. */ +import { Amounts } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; -import { CoinConfig, defaultCoinConfig } from "./denomStructures"; +import { CoinConfig, defaultCoinConfig } from "./denomStructures.js"; import { BankService, ExchangeService, @@ -31,8 +32,8 @@ import { MerchantService, setupDb, WalletCli, -} from "./harness"; -import { SimpleTestEnvironment } from "./helpers"; +} from "./harness.js"; +import { SimpleTestEnvironment } from "./helpers.js"; const merchantAuthToken = "secret-token:sandbox"; @@ -162,6 +163,63 @@ export async function runWallettestingTest(t: GlobalTestState) { t.assertDeepEqual(txTypes, ["withdrawal", "payment"]); + wallet.deleteDatabase(); + + await wallet.client.call(WalletApiOperation.WithdrawTestBalance, { + amount: "TESTKUDOS:10", + bankBaseUrl: bank.baseUrl, + exchangeBaseUrl: exchange.baseUrl, + }); + + await wallet.runUntilDone(); + + const coinDump = await wallet.client.call(WalletApiOperation.DumpCoins, {}); + + console.log("coin dump:", JSON.stringify(coinDump, undefined, 2)); + + let susp: string | undefined; + { + for (const c of coinDump.coins) { + if (0 === Amounts.cmp(c.remaining_value, "TESTKUDOS:8")) { + susp = c.coin_pub; + } + } + } + + t.assertTrue(susp !== undefined); + + console.log("suspending coin"); + + await wallet.client.call(WalletApiOperation.SetCoinSuspended, { + coinPub: susp, + suspended: true, + }); + + // This should fail, as we've suspended a coin that we need + // to pay. + await t.assertThrowsAsync(async () => { + await wallet.client.call(WalletApiOperation.TestPay, { + amount: "TESTKUDOS:5", + merchantAuthToken: merchantAuthToken, + merchantBaseUrl: merchant.makeInstanceBaseUrl(), + summary: "foo", + }); + }); + + console.log("unsuspending coin"); + + await wallet.client.call(WalletApiOperation.SetCoinSuspended, { + coinPub: susp, + suspended: false, + }); + + await wallet.client.call(WalletApiOperation.TestPay, { + amount: "TESTKUDOS:5", + merchantAuthToken: merchantAuthToken, + merchantBaseUrl: merchant.makeInstanceBaseUrl(), + summary: "foo", + }); + await t.shutdown(); } |