summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2024-03-07 23:38:15 +0100
committerFlorian Dold <florian@dold.me>2024-03-07 23:38:15 +0100
commita63dd3900ab4b5cff6c2d571bae3a85847aa803f (patch)
treed0b5853c672d79180e335cb238585778d9c43769
parentdb97953bdb424c9847b39a27502f67315a266220 (diff)
downloadwallet-core-a63dd3900ab4b5cff6c2d571bae3a85847aa803f.tar.gz
wallet-core-a63dd3900ab4b5cff6c2d571bae3a85847aa803f.tar.bz2
wallet-core-a63dd3900ab4b5cff6c2d571bae3a85847aa803f.zip
remove deprecated function, remove outdated FIXMEs
-rw-r--r--packages/taler-harness/src/integrationtests/test-exchange-timetravel.ts3
-rw-r--r--packages/taler-harness/src/integrationtests/test-merchant-refund-api.ts5
-rw-r--r--packages/taler-harness/src/integrationtests/test-refund-auto.ts8
-rw-r--r--packages/taler-harness/src/integrationtests/test-refund-gone.ts5
-rw-r--r--packages/taler-harness/src/integrationtests/test-refund-incremental.ts3
-rw-r--r--packages/taler-harness/src/integrationtests/test-refund.ts27
-rw-r--r--packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts12
-rw-r--r--packages/taler-util/src/time.ts39
-rw-r--r--packages/taler-wallet-core/src/backup/index.ts4
-rw-r--r--packages/taler-wallet-core/src/deposits.ts5
-rw-r--r--packages/taler-wallet-core/src/exchanges.ts3
11 files changed, 37 insertions, 77 deletions
diff --git a/packages/taler-harness/src/integrationtests/test-exchange-timetravel.ts b/packages/taler-harness/src/integrationtests/test-exchange-timetravel.ts
index efa21e1a0..74ef64234 100644
--- a/packages/taler-harness/src/integrationtests/test-exchange-timetravel.ts
+++ b/packages/taler-harness/src/integrationtests/test-exchange-timetravel.ts
@@ -23,7 +23,6 @@ import {
DenominationPubKey,
DenomKeyType,
Duration,
- durationFromSpec,
ExchangeKeysJson,
Logger,
} from "@gnu-taler/taler-util";
@@ -190,7 +189,7 @@ export async function runExchangeTimetravelTest(t: GlobalTestState) {
// into the future.
console.log("applying first time travel");
await applyTimeTravelV2(
- Duration.toMilliseconds(durationFromSpec({ days: 400 })),
+ Duration.toMilliseconds(Duration.fromSpec({ days: 400 })),
{
walletClient,
exchange,
diff --git a/packages/taler-harness/src/integrationtests/test-merchant-refund-api.ts b/packages/taler-harness/src/integrationtests/test-merchant-refund-api.ts
index 1b69b9de6..7ee4c977b 100644
--- a/packages/taler-harness/src/integrationtests/test-merchant-refund-api.ts
+++ b/packages/taler-harness/src/integrationtests/test-merchant-refund-api.ts
@@ -22,7 +22,6 @@ import {
MerchantApiClient,
PreparePayResultType,
URL,
- durationFromSpec,
} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import {
@@ -59,7 +58,7 @@ async function testRefundApiWithFulfillmentUrl(
fulfillment_url: "https://example.com/fulfillment",
},
refund_delay: Duration.toTalerProtocolDuration(
- durationFromSpec({ minutes: 5 }),
+ Duration.fromSpec({ minutes: 5 }),
),
});
@@ -175,7 +174,7 @@ async function testRefundApiWithFulfillmentMessage(
fulfillment_message: "Thank you for buying foobar",
},
refund_delay: Duration.toTalerProtocolDuration(
- durationFromSpec({ minutes: 5 }),
+ Duration.fromSpec({ minutes: 5 }),
),
});
diff --git a/packages/taler-harness/src/integrationtests/test-refund-auto.ts b/packages/taler-harness/src/integrationtests/test-refund-auto.ts
index e8bfecefa..2a2e26ea4 100644
--- a/packages/taler-harness/src/integrationtests/test-refund-auto.ts
+++ b/packages/taler-harness/src/integrationtests/test-refund-auto.ts
@@ -17,11 +17,7 @@
/**
* Imports.
*/
-import {
- Duration,
- MerchantApiClient,
- durationFromSpec,
-} from "@gnu-taler/taler-util";
+import { Duration, MerchantApiClient } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState } from "../harness/harness.js";
import {
@@ -62,7 +58,7 @@ export async function runRefundAutoTest(t: GlobalTestState) {
},
},
refund_delay: Duration.toTalerProtocolDuration(
- durationFromSpec({ minutes: 5 }),
+ Duration.fromSpec({ minutes: 5 }),
),
});
diff --git a/packages/taler-harness/src/integrationtests/test-refund-gone.ts b/packages/taler-harness/src/integrationtests/test-refund-gone.ts
index 056560eb8..8a661868f 100644
--- a/packages/taler-harness/src/integrationtests/test-refund-gone.ts
+++ b/packages/taler-harness/src/integrationtests/test-refund-gone.ts
@@ -23,7 +23,6 @@ import {
MerchantApiClient,
TransactionMajorState,
TransactionType,
- durationFromSpec,
} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState } from "../harness/harness.js";
@@ -66,14 +65,14 @@ export async function runRefundGoneTest(t: GlobalTestState) {
pay_deadline: AbsoluteTime.toProtocolTimestamp(
AbsoluteTime.addDuration(
AbsoluteTime.now(),
- durationFromSpec({
+ Duration.fromSpec({
minutes: 10,
}),
),
),
},
refund_delay: Duration.toTalerProtocolDuration(
- durationFromSpec({ minutes: 1 }),
+ Duration.fromSpec({ minutes: 1 }),
),
});
diff --git a/packages/taler-harness/src/integrationtests/test-refund-incremental.ts b/packages/taler-harness/src/integrationtests/test-refund-incremental.ts
index e7e041ce6..8a5d23315 100644
--- a/packages/taler-harness/src/integrationtests/test-refund-incremental.ts
+++ b/packages/taler-harness/src/integrationtests/test-refund-incremental.ts
@@ -22,7 +22,6 @@ import {
Duration,
MerchantApiClient,
TransactionType,
- durationFromSpec,
} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState, delayMs } from "../harness/harness.js";
@@ -62,7 +61,7 @@ export async function runRefundIncrementalTest(t: GlobalTestState) {
fulfillment_url: "taler://fulfillment-success/thx",
},
refund_delay: Duration.toTalerProtocolDuration(
- durationFromSpec({ minutes: 5 }),
+ Duration.fromSpec({ minutes: 5 }),
),
});
diff --git a/packages/taler-harness/src/integrationtests/test-refund.ts b/packages/taler-harness/src/integrationtests/test-refund.ts
index aa245803d..999a9b621 100644
--- a/packages/taler-harness/src/integrationtests/test-refund.ts
+++ b/packages/taler-harness/src/integrationtests/test-refund.ts
@@ -1,6 +1,6 @@
/*
This file is part of GNU Taler
- (C) 2020 Taler Systems S.A.
+ (C) 2020-2024 Taler Systems S.A.
GNU Taler is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -19,7 +19,6 @@
*/
import {
Duration,
- durationFromSpec,
j2s,
MerchantApiClient,
NotificationType,
@@ -33,9 +32,6 @@ import {
withdrawViaBankV2,
} from "../harness/helpers.js";
-/**
- * Run test for basic, bank-integrated withdrawal.
- */
export async function runRefundTest(t: GlobalTestState) {
// Set up test environment
@@ -67,7 +63,7 @@ export async function runRefundTest(t: GlobalTestState) {
fulfillment_url: "taler://fulfillment-success/thx",
},
refund_delay: Duration.toTalerProtocolDuration(
- durationFromSpec({ minutes: 5 }),
+ Duration.fromSpec({ minutes: 5 }),
),
});
@@ -84,7 +80,7 @@ export async function runRefundTest(t: GlobalTestState) {
});
await wallet.client.call(WalletApiOperation.ConfirmPay, {
- proposalId: r1.proposalId,
+ transactionId: r1.transactionId,
});
// Check if payment was successful.
@@ -115,7 +111,6 @@ export async function runRefundTest(t: GlobalTestState) {
console.log(ref);
{
- // FIXME!
const refundFinishedCond = wallet.waitForNotificationCond(
(x) =>
x.type === NotificationType.TransactionStateTransition &&
@@ -125,7 +120,6 @@ export async function runRefundTest(t: GlobalTestState) {
await wallet.client.call(WalletApiOperation.StartRefundQuery, {
transactionId: r1.transactionId,
});
-
await refundFinishedCond;
}
@@ -150,21 +144,6 @@ export async function runRefundTest(t: GlobalTestState) {
tx.type === TransactionType.Payment && tx.refundPending === undefined,
);
}
-
- // FIXME: Test is incomplete without this!
- // {
- // const refundQueriedCond = wallet.waitForNotificationCond(
- // (x) => x.type === NotificationType.RefundQueried,
- // );
- // const r3 = await wallet.client.call(
- // WalletApiOperation.ApplyRefundFromPurchaseId,
- // {
- // purchaseId: r1.proposalId,
- // },
- // );
- // console.log(r3);
- // await refundQueriedCond;
- // }
}
runRefundTest.suites = ["wallet"];
diff --git a/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts b/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts
index 98ac7adae..e144683cb 100644
--- a/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts
+++ b/packages/taler-harness/src/integrationtests/test-timetravel-autorefresh.ts
@@ -20,22 +20,18 @@
import {
ConfirmPayResultType,
Duration,
- durationFromSpec,
MerchantApiClient,
NotificationType,
PreparePayResultType,
} from "@gnu-taler/taler-util";
-import {
- PendingOperationsResponse,
- WalletApiOperation,
-} from "@gnu-taler/taler-wallet-core";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { makeNoFeeCoinConfig } from "../harness/denomStructures.js";
import {
BankService,
ExchangeService,
- generateRandomPayto,
GlobalTestState,
MerchantService,
+ generateRandomPayto,
setupDb,
} from "../harness/harness.js";
import {
@@ -135,7 +131,7 @@ export async function runTimetravelAutorefreshTest(t: GlobalTestState) {
// into the future.
console.log("applying first time travel");
await applyTimeTravelV2(
- Duration.toMilliseconds(durationFromSpec({ days: 400 })),
+ Duration.toMilliseconds(Duration.fromSpec({ days: 400 })),
{
walletClient,
exchange,
@@ -167,7 +163,7 @@ export async function runTimetravelAutorefreshTest(t: GlobalTestState) {
// into the future.
console.log("applying second time travel");
await applyTimeTravelV2(
- Duration.toMilliseconds(durationFromSpec({ years: 2, months: 6 })),
+ Duration.toMilliseconds(Duration.fromSpec({ years: 2, months: 6 })),
{
walletClient,
exchange,
diff --git a/packages/taler-util/src/time.ts b/packages/taler-util/src/time.ts
index cec41fdd0..2e24856ee 100644
--- a/packages/taler-util/src/time.ts
+++ b/packages/taler-util/src/time.ts
@@ -280,7 +280,23 @@ export namespace Duration {
return Math.ceil(d.d_ms / 1000 / 60 / 60 / 24 / 365);
}
- export const fromSpec = durationFromSpec;
+ export function fromSpec(spec: {
+ seconds?: number;
+ minutes?: number;
+ hours?: number;
+ days?: number;
+ months?: number;
+ years?: number;
+ }): Duration {
+ let d_ms = 0;
+ d_ms += (spec.seconds ?? 0) * SECONDS;
+ d_ms += (spec.minutes ?? 0) * MINUTES;
+ d_ms += (spec.hours ?? 0) * HOURS;
+ d_ms += (spec.days ?? 0) * DAYS;
+ d_ms += (spec.months ?? 0) * MONTHS;
+ d_ms += (spec.years ?? 0) * YEARS;
+ return { d_ms };
+ }
export function getForever(): Duration {
return { d_ms: "forever" };
@@ -552,27 +568,6 @@ const DAYS = HOURS * 24;
const MONTHS = DAYS * 30;
const YEARS = DAYS * 365;
-/**
- * @deprecated use Duration.fromSpec
- */
-export function durationFromSpec(spec: {
- seconds?: number;
- minutes?: number;
- hours?: number;
- days?: number;
- months?: number;
- years?: number;
-}): Duration {
- let d_ms = 0;
- d_ms += (spec.seconds ?? 0) * SECONDS;
- d_ms += (spec.minutes ?? 0) * MINUTES;
- d_ms += (spec.hours ?? 0) * HOURS;
- d_ms += (spec.days ?? 0) * DAYS;
- d_ms += (spec.months ?? 0) * MONTHS;
- d_ms += (spec.years ?? 0) * YEARS;
- return { d_ms };
-}
-
export function durationMin(d1: Duration, d2: Duration): Duration {
if (d1.d_ms === "forever") {
return { d_ms: d2.d_ms };
diff --git a/packages/taler-wallet-core/src/backup/index.ts b/packages/taler-wallet-core/src/backup/index.ts
index 04c53526d..c32ed8b8c 100644
--- a/packages/taler-wallet-core/src/backup/index.ts
+++ b/packages/taler-wallet-core/src/backup/index.ts
@@ -29,6 +29,7 @@ import {
AttentionType,
BackupRecovery,
Codec,
+ Duration,
EddsaKeyPair,
HttpStatusCode,
Logger,
@@ -55,7 +56,6 @@ import {
codecForSyncTermsOfServiceResponse,
codecOptional,
decodeCrock,
- durationFromSpec,
eddsaGetPublic,
encodeCrock,
getRandomBytes,
@@ -173,7 +173,7 @@ function getNextBackupTimestamp(): TalerPreciseTimestamp {
return AbsoluteTime.toPreciseTimestamp(
AbsoluteTime.addDuration(
AbsoluteTime.now(),
- durationFromSpec({ minutes: 5 }),
+ Duration.fromSpec({ minutes: 5 }),
),
);
}
diff --git a/packages/taler-wallet-core/src/deposits.ts b/packages/taler-wallet-core/src/deposits.ts
index 2ee452de7..93f70c2ce 100644
--- a/packages/taler-wallet-core/src/deposits.ts
+++ b/packages/taler-wallet-core/src/deposits.ts
@@ -62,7 +62,6 @@ import {
codecForBatchDepositSuccess,
codecForTackTransactionAccepted,
codecForTackTransactionWired,
- durationFromSpec,
encodeCrock,
getRandomBytes,
hashTruncate32,
@@ -1200,7 +1199,7 @@ export async function prepareDepositGroup(
order_id: "",
h_wire: "",
pay_deadline: AbsoluteTime.toProtocolTimestamp(
- AbsoluteTime.addDuration(now, durationFromSpec({ hours: 1 })),
+ AbsoluteTime.addDuration(now, Duration.fromSpec({ hours: 1 })),
),
merchant: {
name: "(wallet)",
@@ -1320,7 +1319,7 @@ export async function createDepositGroup(
order_id: "",
h_wire: wireHash,
pay_deadline: AbsoluteTime.toProtocolTimestamp(
- AbsoluteTime.addDuration(now, durationFromSpec({ hours: 1 })),
+ AbsoluteTime.addDuration(now, Duration.fromSpec({ hours: 1 })),
),
merchant: {
name: "(wallet)",
diff --git a/packages/taler-wallet-core/src/exchanges.ts b/packages/taler-wallet-core/src/exchanges.ts
index c44178de8..1fb3a8795 100644
--- a/packages/taler-wallet-core/src/exchanges.ts
+++ b/packages/taler-wallet-core/src/exchanges.ts
@@ -75,7 +75,6 @@ import {
canonicalizeBaseUrl,
checkDbInvariant,
codecForExchangeKeysJson,
- durationFromSpec,
durationMul,
encodeCrock,
hashDenomPub,
@@ -1546,7 +1545,7 @@ export async function updateExchangeFromUrlHandler(
let minCheckThreshold = AbsoluteTime.addDuration(
AbsoluteTime.now(),
- durationFromSpec({ days: 1 }),
+ Duration.fromSpec({ days: 1 }),
);
if (refreshCheckNecessary) {