summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2024-01-13 14:24:28 +0100
committerFlorian Dold <florian@dold.me>2024-01-13 14:24:28 +0100
commit3277caa38a693e7faae588133d2604cd7072295a (patch)
tree80dd3fad250dc4080d974e7963ad729fc9660b86 /packages
parent2487a06bfea973dc92b7e3aff2e7a70f48d2cf17 (diff)
downloadwallet-core-3277caa38a693e7faae588133d2604cd7072295a.tar.gz
wallet-core-3277caa38a693e7faae588133d2604cd7072295a.tar.bz2
wallet-core-3277caa38a693e7faae588133d2604cd7072295a.zip
wallet-core: test request to diagnose sleep/wakeup issue on iOS
Diffstat (limited to 'packages')
-rw-r--r--packages/taler-wallet-core/src/db.ts5
-rw-r--r--packages/taler-wallet-core/src/wallet-api-types.ts10
-rw-r--r--packages/taler-wallet-core/src/wallet.ts21
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);
}