From a748ebd053a09dcbabbb70fbc719206d9fd75c19 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Tue, 22 Aug 2023 08:54:48 +0200 Subject: harness: remove unused file --- .../integrationtests/scenario-prompt-payment.ts | 59 ---------------------- 1 file changed, 59 deletions(-) delete mode 100644 packages/taler-harness/src/integrationtests/scenario-prompt-payment.ts (limited to 'packages/taler-harness/src') diff --git a/packages/taler-harness/src/integrationtests/scenario-prompt-payment.ts b/packages/taler-harness/src/integrationtests/scenario-prompt-payment.ts deleted file mode 100644 index 7177a017c..000000000 --- a/packages/taler-harness/src/integrationtests/scenario-prompt-payment.ts +++ /dev/null @@ -1,59 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see - */ - -/** - * Imports. - */ -import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js"; -import { - createSimpleTestkudosEnvironment, - withdrawViaBank, -} from "../harness/helpers.js"; - -/** - * Run test for basic, bank-integrated withdrawal. - */ -export async function runPromptPaymentScenario(t: GlobalTestState) { - // Set up test environment - - const { wallet, bank, exchange, merchant } = - await createSimpleTestkudosEnvironment(t); - - // Withdraw digital cash into the wallet. - - await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:20" }); - - // Set up order. - - const orderResp = await MerchantPrivateApi.createOrder(merchant, "default", { - order: { - summary: "Buy me!", - amount: "TESTKUDOS:5", - fulfillment_url: "taler://fulfillment-success/thx", - }, - }); - - let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { - orderId: orderResp.order_id, - }); - - t.assertTrue(orderStatus.order_status === "unpaid"); - - console.log(orderStatus); - - // Wait "forever" - await new Promise(() => {}); -} -- cgit v1.2.3 From 0a05f6d9030b5a2ce201a98553fa4e6ff13eb907 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Tue, 22 Aug 2023 16:37:27 +0200 Subject: wallet-core: always use batch withdrawal --- packages/taler-harness/src/bench1.ts | 5 +- packages/taler-harness/src/bench3.ts | 6 +-- .../src/integrationtests/testrunner.ts | 2 + packages/taler-wallet-cli/src/index.ts | 1 - .../taler-wallet-core/src/operations/withdraw.ts | 55 ---------------------- packages/taler-wallet-core/src/wallet-api-types.ts | 1 - packages/taler-wallet-core/src/wallet.ts | 1 - .../src/hooks/useSettings.ts | 1 - .../taler-wallet-webextension/src/platform/api.ts | 1 - .../src/wallet/Settings.tsx | 4 -- .../taler-wallet-webextension/src/wxBackend.ts | 1 - 11 files changed, 4 insertions(+), 74 deletions(-) (limited to 'packages/taler-harness/src') diff --git a/packages/taler-harness/src/bench1.ts b/packages/taler-harness/src/bench1.ts index fb7cc9e1f..6aa444e0a 100644 --- a/packages/taler-harness/src/bench1.ts +++ b/packages/taler-harness/src/bench1.ts @@ -68,7 +68,6 @@ export async function runBench1(configJson: any): Promise { } else { logger.info("not trusting exchange (validating signatures)"); } - const batchWithdrawal = !!process.env["TALER_WALLET_BATCH_WITHDRAWAL"]; let wallet = {} as Wallet; let getDbStats: () => AccessStats; @@ -91,9 +90,7 @@ export async function runBench1(configJson: any): Promise { testing: { insecureTrustExchange: trustExchange, }, - features: { - batchWithdrawal, - }, + features: {}, }, }); wallet = res.wallet; diff --git a/packages/taler-harness/src/bench3.ts b/packages/taler-harness/src/bench3.ts index ffafc75d2..c7eca90a8 100644 --- a/packages/taler-harness/src/bench3.ts +++ b/packages/taler-harness/src/bench3.ts @@ -76,8 +76,6 @@ export async function runBench3(configJson: any): Promise { } else { logger.info("not trusting exchange (validating signatures)"); } - const batchWithdrawal = !!process.env["TALER_WALLET_BATCH_WITHDRAWAL"]; - let wallet = {} as Wallet; let getDbStats: () => AccessStats; @@ -96,9 +94,7 @@ export async function runBench3(configJson: any): Promise { persistentStoragePath: undefined, httpLib: myHttpLib, config: { - features: { - batchWithdrawal, - }, + features: {}, testing: { insecureTrustExchange: trustExchange, }, diff --git a/packages/taler-harness/src/integrationtests/testrunner.ts b/packages/taler-harness/src/integrationtests/testrunner.ts index 67572f0f7..58e2a20f7 100644 --- a/packages/taler-harness/src/integrationtests/testrunner.ts +++ b/packages/taler-harness/src/integrationtests/testrunner.ts @@ -103,6 +103,7 @@ import { runPaymentTemplateTest } from "./test-payment-template.js"; import { runExchangeDepositTest } from "./test-exchange-deposit.js"; import { runPeerRepairTest } from "./test-peer-repair.js"; import { runPaymentShareTest } from "./test-payment-share.js"; +import { runSimplePaymentTest } from "./test-simple-payment.js"; /** * Test runner. @@ -129,6 +130,7 @@ const allTests: TestMainFunction[] = [ runClauseSchnorrTest, runDenomUnofferedTest, runDepositTest, + runSimplePaymentTest, runExchangeManagementTest, runExchangeTimetravelTest, runFeeRegressionTest, diff --git a/packages/taler-wallet-cli/src/index.ts b/packages/taler-wallet-cli/src/index.ts index e2787db66..9d840e5bb 100644 --- a/packages/taler-wallet-cli/src/index.ts +++ b/packages/taler-wallet-cli/src/index.ts @@ -258,7 +258,6 @@ async function createLocalWallet( cryptoWorkerType: walletCliArgs.wallet.cryptoWorker as any, config: { features: { - batchWithdrawal: checkEnvFlag("TALER_WALLET_BATCH_WITHDRAWAL"), }, testing: { devModeActive: checkEnvFlag("TALER_WALLET_DEV_MODE"), diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts b/packages/taler-wallet-core/src/operations/withdraw.ts index a1cb29e07..673129928 100644 --- a/packages/taler-wallet-core/src/operations/withdraw.ts +++ b/packages/taler-wallet-core/src/operations/withdraw.ts @@ -710,12 +710,6 @@ async function processPlanchetGenerate( } interface WithdrawalRequestBatchArgs { - /** - * Use the batched request on the network level. - * Not supported by older exchanges. - */ - useBatchRequest: boolean; - coinStartIndex: number; batchSize: number; @@ -923,7 +917,6 @@ async function processPlanchetExchangeBatchRequest( // FIXME: handle individual error codes better! - if (args.useBatchRequest) { const reqUrl = new URL( `reserves/${withdrawalGroup.reservePub}/batch-withdraw`, withdrawalGroup.exchangeBaseUrl, @@ -949,53 +942,6 @@ async function processPlanchetExchangeBatchRequest( coinIdxs: [], }; } - } else { - // We emulate the batch response here by making multiple individual requests - const responses: ExchangeWithdrawBatchResponse = { - ev_sigs: [], - }; - const responseCoinIdxs: number[] = []; - for (let i = 0; i < batchReq.planchets.length; i++) { - try { - const p = batchReq.planchets[i]; - const reqUrl = new URL( - `reserves/${withdrawalGroup.reservePub}/withdraw`, - withdrawalGroup.exchangeBaseUrl, - ).href; - const resp = await ws.http.fetch(reqUrl, { method: "POST", body: p }); - if (resp.status === HttpStatusCode.UnavailableForLegalReasons) { - await handleKycRequired( - ws, - withdrawalGroup, - resp, - i, - requestCoinIdxs, - ); - // We still return blinded coins that we could actually withdraw. - return { - coinIdxs: responseCoinIdxs, - batchResp: responses, - }; - } - const r = await readSuccessResponseJsonOrThrow( - resp, - codecForWithdrawResponse(), - ); - responses.ev_sigs.push(r); - responseCoinIdxs.push(requestCoinIdxs[i]); - } catch (e) { - if (e instanceof TalerError) { - logger.warn(`withdrawing planchet failed: ${j2s(e.errorDetail)}`); - logger.warn(`planchet denom pub hash: ${batchReq.planchets[i].denom_pub_hash}`); - } - await storeCoinError(e, requestCoinIdxs[i]); - } - } - return { - coinIdxs: responseCoinIdxs, - batchResp: responses, - }; - } } async function processPlanchetVerifyAndStoreCoin( @@ -1548,7 +1494,6 @@ async function processWithdrawalGroupPendingReady( const resp = await processPlanchetExchangeBatchRequest(ws, wgContext, { batchSize: maxBatchSize, coinStartIndex: i, - useBatchRequest: ws.config.features.batchWithdrawal, }); let work: Promise[] = []; work = []; diff --git a/packages/taler-wallet-core/src/wallet-api-types.ts b/packages/taler-wallet-core/src/wallet-api-types.ts index 36c4809af..2a7c96ad1 100644 --- a/packages/taler-wallet-core/src/wallet-api-types.ts +++ b/packages/taler-wallet-core/src/wallet-api-types.ts @@ -272,7 +272,6 @@ export interface WalletConfig { * Configurations values that may be safe to show to the user */ features: { - batchWithdrawal: boolean; allowHttp: boolean; }; } diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts index 8cd9bb8c3..b967571d0 100644 --- a/packages/taler-wallet-core/src/wallet.ts +++ b/packages/taler-wallet-core/src/wallet.ts @@ -1696,7 +1696,6 @@ export class Wallet { ], }, features: { - batchWithdrawal: false, allowHttp: false, }, testing: { diff --git a/packages/taler-wallet-webextension/src/hooks/useSettings.ts b/packages/taler-wallet-webextension/src/hooks/useSettings.ts index 5c1ed7924..7332c15bb 100644 --- a/packages/taler-wallet-webextension/src/hooks/useSettings.ts +++ b/packages/taler-wallet-webextension/src/hooks/useSettings.ts @@ -34,7 +34,6 @@ function parse_json_or_undefined(str: string | undefined): T | undefined { export const codecForSettings = (): Codec => buildCodecForObject() .property("walletAllowHttp", codecForBoolean()) - .property("walletBatchWithdrawal", codecForBoolean()) .property("injectTalerSupport", codecForBoolean()) .property("advanceMode", codecForBoolean()) .property("backup", codecForBoolean()) diff --git a/packages/taler-wallet-webextension/src/platform/api.ts b/packages/taler-wallet-webextension/src/platform/api.ts index 2537b16c2..ae57b8faf 100644 --- a/packages/taler-wallet-webextension/src/platform/api.ts +++ b/packages/taler-wallet-webextension/src/platform/api.ts @@ -119,7 +119,6 @@ export const defaultSettings: Settings = { showJsonOnError: false, extendedAccountTypes: false, walletAllowHttp: false, - walletBatchWithdrawal: false, }; /** diff --git a/packages/taler-wallet-webextension/src/wallet/Settings.tsx b/packages/taler-wallet-webextension/src/wallet/Settings.tsx index 4098fd55b..071d2a594 100644 --- a/packages/taler-wallet-webextension/src/wallet/Settings.tsx +++ b/packages/taler-wallet-webextension/src/wallet/Settings.tsx @@ -316,10 +316,6 @@ function AdvanceSettings(): VNode { label: i18n.str`Allow HTTP connections`, description: i18n.str`Using HTTP connection may be faster but unsafe (wallet restart required)`, }, - walletBatchWithdrawal: { - label: i18n.str`Allow batch withdrawals`, - description: i18n.str`Using the batch withdrawal API allows faster withdrawals (wallet restart required)`, - }, langSelector: { label: i18n.str`Lang selector`, description: i18n.str`Allows to manually change the language of the UI. Otherwise it will be automatically selected by your browser configuration.`, diff --git a/packages/taler-wallet-webextension/src/wxBackend.ts b/packages/taler-wallet-webextension/src/wxBackend.ts index dfdb1b0d5..95af1a3a4 100644 --- a/packages/taler-wallet-webextension/src/wxBackend.ts +++ b/packages/taler-wallet-webextension/src/wxBackend.ts @@ -332,7 +332,6 @@ async function reinitWallet(): Promise { { features: { allowHttp: settings.walletAllowHttp, - batchWithdrawal: settings.walletBatchWithdrawal, }, }, ); -- cgit v1.2.3 From 1ee601f70fb894a0d5b49e9800e9f5f3b5c4fc0f Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 23 Aug 2023 09:07:43 +0200 Subject: -missing file --- .../src/integrationtests/test-simple-payment.ts | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 packages/taler-harness/src/integrationtests/test-simple-payment.ts (limited to 'packages/taler-harness/src') diff --git a/packages/taler-harness/src/integrationtests/test-simple-payment.ts b/packages/taler-harness/src/integrationtests/test-simple-payment.ts new file mode 100644 index 000000000..82fa5f21d --- /dev/null +++ b/packages/taler-harness/src/integrationtests/test-simple-payment.ts @@ -0,0 +1,59 @@ +/* + This file is part of GNU Taler + (C) 2020 Taler Systems S.A. + + GNU Taler is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + GNU Taler; see the file COPYING. If not, see + */ + +/** + * Imports. + */ +import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; +import { GlobalTestState } from "../harness/harness.js"; +import { + createSimpleTestkudosEnvironmentV2, + withdrawViaBankV2, + makeTestPaymentV2, +} from "../harness/helpers.js"; +import { j2s } from "@gnu-taler/taler-util"; + +/** + * Run test for basic, bank-integrated withdrawal and payment. + */ +export async function runSimplePaymentTest(t: GlobalTestState) { + // Set up test environment + + const { walletClient, bank, exchange, merchant } = + await createSimpleTestkudosEnvironmentV2(t); + + // Withdraw digital cash into the wallet. + + await withdrawViaBankV2(t, { + walletClient, + bank, + exchange, + amount: "TESTKUDOS:20", + }); + + await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {}); + + const order = { + summary: "Buy me!", + amount: "TESTKUDOS:5", + fulfillment_url: "taler://fulfillment-success/thx", + }; + + await makeTestPaymentV2(t, { walletClient, merchant, order }); + await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {}); +} + +runSimplePaymentTest.suites = ["wallet"]; -- cgit v1.2.3