taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit ad83c0f13add7850f5117e7f9d8736d7aaa917ca
parent 24abcbd76b859c56f1da4115802d2259ca5a8017
Author: Florian Dold <florian@dold.me>
Date:   Wed,  7 May 2025 01:26:14 +0200

harness: use new API in withdrawal-idempotent

Diffstat:
Mpackages/taler-harness/src/integrationtests/test-withdrawal-idempotent.ts | 60+++++++++++++++++++++++++++++++-----------------------------
1 file changed, 31 insertions(+), 29 deletions(-)

diff --git a/packages/taler-harness/src/integrationtests/test-withdrawal-idempotent.ts b/packages/taler-harness/src/integrationtests/test-withdrawal-idempotent.ts @@ -21,15 +21,13 @@ import { AgeRestriction, Amounts, AmountString, - codecForExchangeLegacyWithdrawBatchResponse, encodeCrock, - ExchangeLegacyBatchWithdrawRequest, + ExchangeWithdrawRequest, getRandomBytes, + succeedOrThrow, + TalerExchangeHttpClient2, } from "@gnu-taler/taler-util"; -import { - HttpRequestLibrary, - readSuccessResponseJsonOrThrow, -} from "@gnu-taler/taler-util/http"; +import { HttpRequestLibrary } from "@gnu-taler/taler-util/http"; import { CryptoDispatcher, SynchronousCryptoWorkerFactoryPlain, @@ -44,8 +42,8 @@ import { topupReserveWithBank, } from "@gnu-taler/taler-wallet-core/dbless"; import { DenominationRecord } from "../../../taler-wallet-core/src/db.js"; -import { GlobalTestState, harnessHttpLib } from "../harness/harness.js"; import { createSimpleTestkudosEnvironmentV2 } from "../harness/environments.js"; +import { GlobalTestState, harnessHttpLib } from "../harness/harness.js"; /** * Run test for basic, bank-integrated withdrawal and payment. @@ -119,38 +117,42 @@ async function myWithdrawCoin(args: { value: Amounts.parseOrThrow(denom.value), }); - const reqBody: ExchangeLegacyBatchWithdrawRequest = { - planchets: [ - { - denom_pub_hash: planchet.denomPubHash, - reserve_sig: planchet.withdrawSig, - coin_ev: planchet.coinEv, - }, - ], + const exchangeClient = new TalerExchangeHttpClient2(exchangeBaseUrl); + + const sigResp = await cryptoApi.signWithdrawal({ + amount: Amounts.stringify(denom.value), + fee: Amounts.stringify(denom.fees.feeWithdraw), + coinEvs: [planchet.coinEv], + denomsPubHashes: [planchet.denomPubHash], + reservePriv: reserveKeyPair.reservePriv, + }); + + const reqBody: ExchangeWithdrawRequest = { + cipher: "ED25519", + coin_evs: [planchet.coinEv], + denoms_h: [planchet.denomPubHash], + reserve_pub: planchet.reservePub, + reserve_sig: sigResp.sig, }; - const reqUrl = new URL( - `reserves/${planchet.reservePub}/batch-withdraw`, - exchangeBaseUrl, - ).href; - - const resp = await http.fetch(reqUrl, { method: "POST", body: reqBody }); - const rBatch = await readSuccessResponseJsonOrThrow( - resp, - codecForExchangeLegacyWithdrawBatchResponse(), + + const rBatch = succeedOrThrow( + await exchangeClient.withdraw({ + body: reqBody, + }), ); { // Check for idempotency! - const resp2 = await http.fetch(reqUrl, { method: "POST", body: reqBody }); - await readSuccessResponseJsonOrThrow( - resp2, - codecForExchangeLegacyWithdrawBatchResponse(), + succeedOrThrow( + await exchangeClient.withdraw({ + body: reqBody, + }), ); } const ubSig = await cryptoApi.unblindDenominationSignature({ planchet, - evSig: rBatch.ev_sigs[0].ev_sig, + evSig: rBatch.ev_sigs[0], }); return {