diff options
author | Florian Dold <florian@dold.me> | 2024-01-29 22:20:57 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2024-01-29 22:20:57 +0100 |
commit | 95e87d8f4863f3db37504e78913381f775f8f73a (patch) | |
tree | 0d5f1527ba9cbb596b99e5256b0aaeac9f204cab /packages/taler-wallet-core/src | |
parent | 2c9c3d4cdf3f59eabbb47327f78966b781d77256 (diff) | |
download | wallet-core-95e87d8f4863f3db37504e78913381f775f8f73a.tar.xz |
wallet-core: create dev experiment for pending refresh
Diffstat (limited to 'packages/taler-wallet-core/src')
-rw-r--r-- | packages/taler-wallet-core/src/dev-experiments.ts | 39 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/operations/refresh.ts | 4 |
2 files changed, 40 insertions, 3 deletions
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) => |