diff options
author | Florian Dold <florian@dold.me> | 2024-01-13 14:24:28 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2024-01-13 14:24:28 +0100 |
commit | 3277caa38a693e7faae588133d2604cd7072295a (patch) | |
tree | 80dd3fad250dc4080d974e7963ad729fc9660b86 /packages/taler-wallet-core | |
parent | 2487a06bfea973dc92b7e3aff2e7a70f48d2cf17 (diff) | |
download | wallet-core-3277caa38a693e7faae588133d2604cd7072295a.tar.xz |
wallet-core: test request to diagnose sleep/wakeup issue on iOS
Diffstat (limited to 'packages/taler-wallet-core')
-rw-r--r-- | packages/taler-wallet-core/src/db.ts | 5 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/wallet-api-types.ts | 10 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/wallet.ts | 21 |
3 files changed, 30 insertions, 6 deletions
diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts index 549bc7517..263de9d4c 100644 --- a/packages/taler-wallet-core/src/db.ts +++ b/packages/taler-wallet-core/src/db.ts @@ -1324,6 +1324,8 @@ export enum ConfigRecordKey { WalletBackupState = "walletBackupState", CurrencyDefaultsApplied = "currencyDefaultsApplied", DevMode = "devMode", + // Only for testing, do not use! + TestLoopTx = "testTxLoop", } /** @@ -1336,7 +1338,8 @@ export type ConfigRecord = value: WalletBackupConfState; } | { key: ConfigRecordKey.CurrencyDefaultsApplied; value: boolean } - | { key: ConfigRecordKey.DevMode; value: boolean }; + | { key: ConfigRecordKey.DevMode; value: boolean } + | { key: ConfigRecordKey.TestLoopTx; value: number }; export interface WalletBackupConfState { deviceId: string; diff --git a/packages/taler-wallet-core/src/wallet-api-types.ts b/packages/taler-wallet-core/src/wallet-api-types.ts index a4be0f448..7ac347b6d 100644 --- a/packages/taler-wallet-core/src/wallet-api-types.ts +++ b/packages/taler-wallet-core/src/wallet-api-types.ts @@ -234,6 +234,7 @@ export enum WalletApiOperation { TestingWaitTasksProcessed = "testingWaitTasksProcessed", ListExchangesForScopedCurrency = "listExchangesForScopedCurrency", PrepareWithdrawExchange = "prepareWithdrawExchange", + TestingInfiniteTransactionLoop = "testingInfiniteTransactionLoop", } // group: Initialization @@ -1194,6 +1195,7 @@ export type WalletOperations = { [WalletApiOperation.RecoverStoredBackup]: RecoverStoredBackupsOp; [WalletApiOperation.UpdateExchangeEntry]: UpdateExchangeEntryOp; [WalletApiOperation.PrepareWithdrawExchange]: PrepareWithdrawExchangeOp; + [WalletApiOperation.TestingInfiniteTransactionLoop]: any; }; export type WalletCoreRequestType< @@ -1219,8 +1221,8 @@ type RecursivePartial<T extends object> = { [P in keyof T]?: T[P] extends Array<infer U extends object> ? Array<RecursivePartial<U>> : T[P] extends Array<infer J extends Primitives> - ? Array<J> - : T[P] extends object - ? RecursivePartial<T[P]> - : T[P]; + ? Array<J> + : T[P] extends object + ? RecursivePartial<T[P]> + : T[P]; } & object; diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts index da34ff37f..8d5028d47 100644 --- a/packages/taler-wallet-core/src/wallet.ts +++ b/packages/taler-wallet-core/src/wallet.ts @@ -298,7 +298,7 @@ import { GetReadOnlyAccess, GetReadWriteAccess, } from "./util/query.js"; -import { TimerAPI, TimerGroup } from "./util/timer.js"; +import { TimerAPI, TimerGroup, timer } from "./util/timer.js"; import { WALLET_BANK_CONVERSION_API_PROTOCOL_VERSION, WALLET_BANK_INTEGRATION_PROTOCOL_VERSION, @@ -1393,6 +1393,25 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>( ws.workAvailable.trigger(); return {}; } + case WalletApiOperation.TestingInfiniteTransactionLoop: { + const myDelayMs = (payload as any).delayMs ?? 5; + let loopCount = 0; + while (true) { + logger.info(`looping test write tx, iteration ${loopCount}`); + await ws.db.runReadWriteTx(["config"], async (tx) => { + await tx.config.put({ + key: ConfigRecordKey.TestLoopTx, + value: loopCount, + }); + }); + if (myDelayMs != 0) { + await new Promise<void>((resolve, reject) => { + setTimeout(() => resolve(), myDelayMs); + }); + } + loopCount = (loopCount + 1) % (Number.MAX_SAFE_INTEGER - 1); + } + } // default: // assertUnreachable(operation); } |