From 95e87d8f4863f3db37504e78913381f775f8f73a Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 29 Jan 2024 22:20:57 +0100 Subject: wallet-core: create dev experiment for pending refresh --- packages/taler-wallet-core/src/dev-experiments.ts | 39 ++++++++++++++++++++-- .../taler-wallet-core/src/operations/refresh.ts | 4 ++- 2 files changed, 40 insertions(+), 3 deletions(-) (limited to 'packages') diff --git a/packages/taler-wallet-core/src/dev-experiments.ts b/packages/taler-wallet-core/src/dev-experiments.ts index cb8f7aa19..be42557e5 100644 --- a/packages/taler-wallet-core/src/dev-experiments.ts +++ b/packages/taler-wallet-core/src/dev-experiments.ts @@ -25,8 +25,20 @@ * Imports. */ -import { Logger, parseDevExperimentUri } from "@gnu-taler/taler-util"; -import { ConfigRecordKey } from "./db.js"; +import { + Logger, + RefreshReason, + TalerPreciseTimestamp, + encodeCrock, + getRandomBytes, + parseDevExperimentUri, +} from "@gnu-taler/taler-util"; +import { + ConfigRecordKey, + RefreshGroupRecord, + RefreshOperationStatus, + timestampPreciseToDb, +} from "./db.js"; import { InternalWalletState } from "./internal-wallet-state.js"; import { HttpRequestLibrary, @@ -54,6 +66,29 @@ export async function applyDevExperiment( "can't handle devmode URI (other than enable-devmode) unless devmode is active", ); } + + if (parsedUri.devExperimentId == "insert-pending-refresh") { + await ws.db.runReadWriteTx(["refreshGroups"], async (tx) => { + const refreshGroupId = encodeCrock(getRandomBytes(32)); + const newRg: RefreshGroupRecord = { + currency: "DEVKUDOS", + expectedOutputPerCoin: [], + inputPerCoin: [], + oldCoinPubs: [], + operationStatus: RefreshOperationStatus.Pending, + reason: RefreshReason.Manual, + refreshGroupId, + statusPerCoin: [], + timestampCreated: timestampPreciseToDb(TalerPreciseTimestamp.now()), + timestampFinished: undefined, + originatingTransactionId: undefined, + infoPerExchange: {}, + }; + await tx.refreshGroups.put(newRg); + }); + return; + } + throw Error(`dev-experiment id not understood ${parsedUri.devExperimentId}`); } diff --git a/packages/taler-wallet-core/src/operations/refresh.ts b/packages/taler-wallet-core/src/operations/refresh.ts index dff6d3019..5f7169dbd 100644 --- a/packages/taler-wallet-core/src/operations/refresh.ts +++ b/packages/taler-wallet-core/src/operations/refresh.ts @@ -1017,7 +1017,9 @@ export async function processRefreshGroup( return TaskRunResult.finished(); } // Process refresh sessions of the group in parallel. - logger.trace("processing refresh sessions for $ old coins"); + logger.trace( + `processing refresh sessions for ${refreshGroup.oldCoinPubs.length} old coins`, + ); let errors: TalerErrorDetail[] = []; let inShutdown = false; const ps = refreshGroup.oldCoinPubs.map((x, i) => -- cgit v1.2.3