diff options
author | Sebastian <sebasjm@gmail.com> | 2024-02-16 16:09:49 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2024-02-16 16:09:49 -0300 |
commit | 90c7dc49b7d377b4b3e691f45b84b51f6b03f9af (patch) | |
tree | 25778b155e7dba168eab981ca47d6d63cba94163 /packages | |
parent | 366e1fb65fb33b7b17b61e2f90269b7fd4097fb4 (diff) | |
download | wallet-core-90c7dc49b7d377b4b3e691f45b84b51f6b03f9af.tar.gz wallet-core-90c7dc49b7d377b4b3e691f45b84b51f6b03f9af.tar.bz2 wallet-core-90c7dc49b7d377b4b3e691f45b84b51f6b03f9af.zip |
fix #8415
Diffstat (limited to 'packages')
11 files changed, 65 insertions, 41 deletions
diff --git a/packages/taler-harness/src/harness/harness.ts b/packages/taler-harness/src/harness/harness.ts index 410462af2..2199824e4 100644 --- a/packages/taler-harness/src/harness/harness.ts +++ b/packages/taler-harness/src/harness/harness.ts @@ -592,7 +592,7 @@ class BankServiceBase { protected globalTestState: GlobalTestState, protected bankConfig: BankConfig, protected configFile: string, - ) {} + ) { } } export interface HarnessExchangeBankAccount { @@ -612,8 +612,7 @@ export interface HarnessExchangeBankAccount { */ export class FakebankService extends BankServiceBase - implements BankServiceHandle -{ + implements BankServiceHandle { proc: ProcessWrapper | undefined; http = createPlatformHttpLib({ enableThrottling: false }); @@ -743,8 +742,7 @@ export class FakebankService */ export class LibeufinBankService extends BankServiceBase - implements BankServiceHandle -{ + implements BankServiceHandle { proc: ProcessWrapper | undefined; http = createPlatformHttpLib({ enableThrottling: false }); @@ -1210,7 +1208,7 @@ export class ExchangeService implements ExchangeServiceInterface { private exchangeConfig: ExchangeConfig, private configFilename: string, private keyPair: EddsaKeyPair, - ) {} + ) { } get name() { return this.exchangeConfig.name; @@ -1566,7 +1564,7 @@ export class MerchantService implements MerchantServiceInterface { private globalState: GlobalTestState, private merchantConfig: MerchantConfig, private configFilename: string, - ) {} + ) { } private currentTimetravelOffsetMs: number | undefined; @@ -1988,6 +1986,7 @@ export class WalletService { } export interface WalletClientArgs { + name?: string; unixPath: string; onNotification?(n: WalletNotification): void; } @@ -2024,12 +2023,13 @@ export class WalletClient { return client.call(operation, payload); } - constructor(private args: WalletClientArgs) {} + constructor(private args: WalletClientArgs) { } async connect(): Promise<void> { const waiter = this.waiter; const walletClient = this; const w = await createRemoteWallet({ + name: this.args.name, socketFilename: this.args.unixPath, notificationHandler(n) { if (walletClient.args.onNotification) { @@ -2091,11 +2091,9 @@ export class WalletCli { ? `--crypto-worker=${cliOpts.cryptoWorkerType}` : ""; const logName = `wallet-${self.name}`; - const command = `taler-wallet-cli ${ - self.timetravelArg ?? "" - } ${cryptoWorkerArg} --no-throttle -LTRACE --skip-defaults --wallet-db '${ - self.dbfile - }' api '${op}' ${shellWrap(JSON.stringify(payload))}`; + const command = `taler-wallet-cli ${self.timetravelArg ?? "" + } ${cryptoWorkerArg} --no-throttle -LTRACE --skip-defaults --wallet-db '${self.dbfile + }' api '${op}' ${shellWrap(JSON.stringify(payload))}`; const resp = await sh(self.globalTestState, logName, command); logger.info("--- wallet core response ---"); logger.info(resp); diff --git a/packages/taler-harness/src/harness/helpers.ts b/packages/taler-harness/src/harness/helpers.ts index bb6f28246..7a91353c8 100644 --- a/packages/taler-harness/src/harness/helpers.ts +++ b/packages/taler-harness/src/harness/helpers.ts @@ -421,6 +421,7 @@ export async function createWalletDaemonWithClient( await walletService.pingUntilAvailable(); const walletClient = new WalletClient({ + name: args.name, unixPath: walletService.socketPath, onNotification(n) { console.log(`got ${args.name} notification`, n); diff --git a/packages/taler-harness/src/integrationtests/test-kyc.ts b/packages/taler-harness/src/integrationtests/test-kyc.ts index a0196c81c..cc756f617 100644 --- a/packages/taler-harness/src/integrationtests/test-kyc.ts +++ b/packages/taler-harness/src/integrationtests/test-kyc.ts @@ -191,6 +191,7 @@ export async function createKycTestkudosEnvironment( await walletService.pingUntilAvailable(); const walletClient = new WalletClient({ + name: "wallet", unixPath: walletService.socketPath, onNotification(n) { console.log("got notification", n); diff --git a/packages/taler-harness/src/integrationtests/test-payment-share.ts b/packages/taler-harness/src/integrationtests/test-payment-share.ts index 034bbc98d..d832a7e50 100644 --- a/packages/taler-harness/src/integrationtests/test-payment-share.ts +++ b/packages/taler-harness/src/integrationtests/test-payment-share.ts @@ -65,6 +65,13 @@ export async function runPaymentShareTest(t: GlobalTestState) { }); await secondWallet.call(WalletApiOperation.TestingWaitTransactionsFinal, {}); + { + const first = await firstWallet.call(WalletApiOperation.GetBalances, {}); + const second = await secondWallet.call(WalletApiOperation.GetBalances, {}); + t.assertAmountEquals(first.balances[0].available, "TESTKUDOS:19.53"); + t.assertAmountEquals(second.balances[0].available, "TESTKUDOS:19.53"); + } + t.logStep("setup-done"); // create two orders to pay @@ -179,6 +186,9 @@ export async function runPaymentShareTest(t: GlobalTestState) { t.logStep("w1-confirmed-shared"); + /** + * only the second wallet balance was affected + */ { const first = await firstWallet.call(WalletApiOperation.GetBalances, {}); const second = await secondWallet.call( @@ -237,10 +247,12 @@ export async function runPaymentShareTest(t: GlobalTestState) { // Wait for refreshes to settle before doing checks await firstWallet.call(WalletApiOperation.TestingWaitTransactionsFinal, {}); + /** + * only the first wallet balance was affected + */ const bal1 = await firstWallet.call(WalletApiOperation.GetBalances, {}); - t.assertAmountEquals(bal1.balances[0].available, "TESTKUDOS:16.18"); - const bal2 = await secondWallet.call(WalletApiOperation.GetBalances, {}); + t.assertAmountEquals(bal1.balances[0].available, "TESTKUDOS:16.18"); t.assertAmountEquals(bal2.balances[0].available, "TESTKUDOS:14.23"); // Claim the order with the first wallet diff --git a/packages/taler-harness/src/integrationtests/test-wallet-dd48.ts b/packages/taler-harness/src/integrationtests/test-wallet-dd48.ts index c4fe40586..47c96e0e2 100644 --- a/packages/taler-harness/src/integrationtests/test-wallet-dd48.ts +++ b/packages/taler-harness/src/integrationtests/test-wallet-dd48.ts @@ -87,6 +87,7 @@ export async function runWalletDd48Test(t: GlobalTestState) { const allNotifications: WalletNotification[] = []; const walletClient = new WalletClient({ + name: "wallet", unixPath: walletService.socketPath, onNotification(n) { console.log("got notification", n); @@ -151,7 +152,7 @@ export async function runWalletDd48Test(t: GlobalTestState) { x.type === NotificationType.ExchangeStateTransition && x.oldExchangeState == null && x.newExchangeState.exchangeEntryStatus === - ExchangeEntryStatus.Ephemeral, + ExchangeEntryStatus.Ephemeral, ), ); diff --git a/packages/taler-harness/src/integrationtests/test-wallet-notifications.ts b/packages/taler-harness/src/integrationtests/test-wallet-notifications.ts index c87a9a264..c0c32a008 100644 --- a/packages/taler-harness/src/integrationtests/test-wallet-notifications.ts +++ b/packages/taler-harness/src/integrationtests/test-wallet-notifications.ts @@ -111,6 +111,7 @@ export async function runWalletNotificationsTest(t: GlobalTestState) { await walletService.pingUntilAvailable(); const walletClient = new WalletClient({ + name: "wallet", unixPath: walletService.socketPath, onNotification(n) { console.log("got notification", n); diff --git a/packages/taler-harness/src/integrationtests/test-withdrawal-huge.ts b/packages/taler-harness/src/integrationtests/test-withdrawal-huge.ts index 0ad60bcdd..b483b8706 100644 --- a/packages/taler-harness/src/integrationtests/test-withdrawal-huge.ts +++ b/packages/taler-harness/src/integrationtests/test-withdrawal-huge.ts @@ -84,6 +84,7 @@ export async function runWithdrawalHugeTest(t: GlobalTestState) { await walletService.pingUntilAvailable(); const wallet = new WalletClient({ + name: "wallet", unixPath: walletService.socketPath, }); await wallet.connect(); diff --git a/packages/taler-wallet-cli/src/index.ts b/packages/taler-wallet-cli/src/index.ts index f81236cd4..a8a2e2ba0 100644 --- a/packages/taler-wallet-cli/src/index.ts +++ b/packages/taler-wallet-cli/src/index.ts @@ -296,6 +296,7 @@ async function withWallet<T>( if (walletCliArgs.wallet.walletConnection) { logger.info("creating remote wallet"); const w = await createRemoteWallet({ + name: "wallet", notificationHandler: waiter.notify, socketFilename: walletCliArgs.wallet.walletConnection, }); @@ -1220,7 +1221,7 @@ advancedCli help: "Initialize the wallet (with DB) and exit.", }) .action(async (args) => { - await withWallet(args, async () => {}); + await withWallet(args, async () => { }); }); advancedCli diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts index 3b53bbf35..0aae2ddff 100644 --- a/packages/taler-wallet-core/src/db.ts +++ b/packages/taler-wallet-core/src/db.ts @@ -1284,8 +1284,9 @@ export interface PurchaseRecord { posConfirmation: string | undefined; /** - * This purchase was created by sharing nonce or - * did the wallet made the nonce public + * This purchase was created by reading + * a payment share or the wallet + * the nonce public by a payment share */ shared: boolean; @@ -1337,9 +1338,9 @@ export enum ConfigRecordKey { */ export type ConfigRecord = | { - key: ConfigRecordKey.WalletBackupState; - value: WalletBackupConfState; - } + key: ConfigRecordKey.WalletBackupState; + value: WalletBackupConfState; + } | { key: ConfigRecordKey.CurrencyDefaultsApplied; value: boolean } | { key: ConfigRecordKey.DevMode; value: boolean } | { key: ConfigRecordKey.TestLoopTx; value: number }; @@ -1617,15 +1618,15 @@ export enum BackupProviderStateTag { export type BackupProviderState = | { - tag: BackupProviderStateTag.Provisional; - } + tag: BackupProviderStateTag.Provisional; + } | { - tag: BackupProviderStateTag.Ready; - nextBackupTimestamp: DbPreciseTimestamp; - } + tag: BackupProviderStateTag.Ready; + nextBackupTimestamp: DbPreciseTimestamp; + } | { - tag: BackupProviderStateTag.Retrying; - }; + tag: BackupProviderStateTag.Retrying; + }; export interface BackupProviderTerms { supportedProtocolVersion: string; @@ -3155,7 +3156,7 @@ export async function openStoredBackupsDatabase( idbFactory, TALER_WALLET_STORED_BACKUPS_DB_NAME, 1, - () => {}, + () => { }, onStoredBackupsDbUpgradeNeeded, ); @@ -3178,7 +3179,7 @@ export async function openTalerDatabase( idbFactory, TALER_WALLET_META_DB_NAME, 1, - () => {}, + () => { }, onMetaDbUpgradeNeeded, ); diff --git a/packages/taler-wallet-core/src/operations/pay-merchant.ts b/packages/taler-wallet-core/src/operations/pay-merchant.ts index 4b692fe69..63bef3add 100644 --- a/packages/taler-wallet-core/src/operations/pay-merchant.ts +++ b/packages/taler-wallet-core/src/operations/pay-merchant.ts @@ -640,8 +640,7 @@ async function processDownloadProposal( if (proposal.purchaseStatus != PurchaseStatus.PendingDownloadingProposal) { logger.error( - `unexpected state ${proposal.purchaseStatus}/${ - PurchaseStatus[proposal.purchaseStatus] + `unexpected state ${proposal.purchaseStatus}/${PurchaseStatus[proposal.purchaseStatus] } for ${ctx.transactionId} in processDownloadProposal`, ); return TaskRunResult.finished(); @@ -900,8 +899,7 @@ async function createOrReusePurchase( oldProposal.claimToken === claimToken ) { logger.info( - `Found old proposal (status=${ - PurchaseStatus[oldProposal.purchaseStatus] + `Found old proposal (status=${PurchaseStatus[oldProposal.purchaseStatus] }) for order ${orderId} at ${merchantBaseUrl}`, ); if (oldProposal.purchaseStatus === PurchaseStatus.DialogShared) { @@ -1721,6 +1719,14 @@ async function internalWaitPaymentResult( }; } + if (txRes.purchase.purchaseStatus > PurchaseStatus.Done) { + return { + type: ConfirmPayResultType.Done, + contractTerms: d.contractTermsRaw, + transactionId: ctx.transactionId, + }; + } + await purchaseNotifFlag.wait(); purchaseNotifFlag.reset(); } diff --git a/packages/taler-wallet-core/src/remote.ts b/packages/taler-wallet-core/src/remote.ts index 1ee0e1993..030b7a943 100644 --- a/packages/taler-wallet-core/src/remote.ts +++ b/packages/taler-wallet-core/src/remote.ts @@ -45,6 +45,7 @@ export interface RemoteWallet { } export interface RemoteWalletConnectArgs { + name?: string; socketFilename: string; notificationHandler?: (n: WalletNotification) => void; } @@ -86,14 +87,14 @@ export async function createRemoteWallet( return { result: ctx, onDisconnect() { - logger.info("remote wallet disconnected"); + logger.info(`${args.name}: remote wallet disconnected`); }, onMessage(m) { // FIXME: use a codec for parsing the response envelope! - logger.info(`got message from remote wallet: ${j2s(m)}`); + logger.info(`${args.name}: got message from remote: ${j2s(m)}`); if (typeof m !== "object" || m == null) { - logger.warn("message from wallet not understood (wrong type)"); + logger.warn(`${args.name}: message not understood (wrong type)`); return; } const type = (m as any).type; @@ -101,13 +102,13 @@ export async function createRemoteWallet( const id = (m as any).id; if (typeof id !== "string") { logger.warn( - "message from wallet not understood (no id in response)", + `${args.name}: message not understood (no id in response)`, ); return; } const h = requestMap.get(id); if (!h) { - logger.warn(`no handler registered for response id ${id}`); + logger.warn(`${args.name}: no handler registered for response id ${id}`); return; } h.promiseCapability.resolve(m as any); @@ -116,7 +117,7 @@ export async function createRemoteWallet( args.notificationHandler((m as any).payload); } } else { - logger.warn("message from wallet not understood"); + logger.warn(`${args.name}: message not understood`); } }, }; |