diff options
-rw-r--r-- | packages/taler-util/src/time.ts | 14 | ||||
-rw-r--r-- | packages/taler-wallet-cli/src/harness/harness.ts | 2 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/operations/pay.ts | 10 |
3 files changed, 20 insertions, 6 deletions
diff --git a/packages/taler-util/src/time.ts b/packages/taler-util/src/time.ts index f12e8d32b..8b0516bf8 100644 --- a/packages/taler-util/src/time.ts +++ b/packages/taler-util/src/time.ts @@ -91,19 +91,24 @@ export namespace Duration { } return { d_ms: deadline.t_ms - now.t_ms }; } + export function toIntegerYears(d: Duration): number { if (typeof d.d_ms !== "number") { throw Error("infinite duration"); } return Math.ceil(d.d_ms / 1000 / 60 / 60 / 24 / 365); } + export const fromSpec = durationFromSpec; + export function getForever(): Duration { return { d_ms: "forever" }; } + export function getZero(): Duration { return { d_ms: 0 }; } + export function fromTalerProtocolDuration( d: TalerProtocolDuration, ): Duration { @@ -116,6 +121,7 @@ export namespace Duration { d_ms: d.d_us / 1000, }; } + export function toTalerProtocolDuration(d: Duration): TalerProtocolDuration { if (d.d_ms === "forever") { return { @@ -126,6 +132,14 @@ export namespace Duration { d_us: d.d_ms * 1000, }; } + + export function clamp(args: { + lower: Duration; + upper: Duration; + value: Duration; + }): Duration { + return durationMax(durationMin(args.value, args.upper), args.lower); + } } export namespace AbsoluteTime { diff --git a/packages/taler-wallet-cli/src/harness/harness.ts b/packages/taler-wallet-cli/src/harness/harness.ts index a2339e5f3..b0b4a137a 100644 --- a/packages/taler-wallet-cli/src/harness/harness.ts +++ b/packages/taler-wallet-cli/src/harness/harness.ts @@ -1659,7 +1659,7 @@ export class MerchantService implements MerchantServiceInterface { await exec(`taler-merchant-dbinit -c "${this.configFilename}"`); this.proc = this.globalState.spawnService( - "valgrind", + "taler-merchant-httpd", [ "taler-merchant-httpd", "-LDEBUG", diff --git a/packages/taler-wallet-core/src/operations/pay.ts b/packages/taler-wallet-core/src/operations/pay.ts index b28faa4c1..e8604d3fc 100644 --- a/packages/taler-wallet-core/src/operations/pay.ts +++ b/packages/taler-wallet-core/src/operations/pay.ts @@ -26,7 +26,6 @@ */ import { AbsoluteTime, - AgeRestriction, AmountJson, Amounts, codecForContractTerms, @@ -606,10 +605,11 @@ async function failProposalPermanently( } function getProposalRequestTimeout(proposal: ProposalRecord): Duration { - return durationMax( - { d_ms: 60000 }, - durationMin({ d_ms: 5000 }, RetryInfo.getDuration(proposal.retryInfo)), - ); + return Duration.clamp({ + lower: Duration.fromSpec({ seconds: 1}), + upper: Duration.fromSpec({seconds: 60}), + value: getRetryDuration(proposal.retryInfo), + }); } function getPayRequestTimeout(purchase: PurchaseRecord): Duration { |