commit ca2329e8edbe4029c99c13e666b485ae8781c92f
parent 62578f675fbb9a56574b58313b6dd72a021a721f
Author: Marc Stibane <marc@taler.net>
Date: Thu, 18 Jan 2024 09:34:48 +0100
InfiniteTransactionLoop
Diffstat:
2 files changed, 42 insertions(+), 0 deletions(-)
diff --git a/TalerWallet1/Model/Model+Settings.swift b/TalerWallet1/Model/Model+Settings.swift
@@ -93,3 +93,28 @@ extension WalletModel {
let _ = try await sendRequest(request, ASYNCDELAY)
}
} // runIntegrationTestM()
+ // MARK: -
+/// A request to add a test balance to the wallet.
+fileprivate struct InfiniteTransactionLoop: WalletBackendFormattedRequest {
+ struct Response: Decodable {} // no result - getting no error back means success
+ func operation() -> String { "testingInfiniteTransactionLoop" }
+ func args() -> Args { Args(delayMs: delayMs,
+ shouldFetch: shouldFetch)
+ }
+
+ let delayMs: Int32
+ let shouldFetch: Bool
+
+
+ struct Args: Encodable {
+ let delayMs: Int32
+ let shouldFetch: Bool
+ }
+}
+extension WalletModel {
+ func testingInfiniteTransaction(delayMs: Int32, shouldFetch: Bool)
+ async throws {
+ let request = InfiniteTransactionLoop(delayMs: delayMs, shouldFetch: shouldFetch)
+ let _ = try await sendRequest(request, ASYNCDELAY)
+ }
+} // runIntegrationTestM()
diff --git a/TalerWallet1/Views/Settings/SettingsView.swift b/TalerWallet1/Views/Settings/SettingsView.swift
@@ -246,6 +246,23 @@ struct SettingsView: View {
.buttonStyle(.bordered)
.disabled(checkDisabled)
}.id("test2runTest")
+ SettingsItem(name: String("Run Infinite Transaction Loop"), id1: "runInfinite",
+ description: hideDescriptions ? nil : String("Check DB in background")) {
+ let title = "Loop"
+ Button(title) {
+ checkDisabled = true // don't run twice
+ Task { // runs on MainActor
+ symLog.log("Running Infinite Transaction Loop")
+ do {
+ try await model.testingInfiniteTransaction(delayMs: 10_000, shouldFetch: true)
+ } catch { // TODO: show error
+ symLog.log(error.localizedDescription)
+ }
+ }
+ }
+ .buttonStyle(.bordered)
+ .disabled(checkDisabled)
+ }.id("runInfiniteLoop")
SettingsItem(name: String("Save Logfile"), id1: "save",
description: hideDescriptions ? nil : String("Help debugging wallet-core")) {
Button("Save") {