wallet: more time format fixes
This commit is contained in:
parent
5d23eb3635
commit
739c2f9337
@ -101,6 +101,9 @@ export namespace Duration {
|
|||||||
export function getForever(): Duration {
|
export function getForever(): Duration {
|
||||||
return { d_ms: "forever" };
|
return { d_ms: "forever" };
|
||||||
}
|
}
|
||||||
|
export function getZero(): Duration {
|
||||||
|
return { d_ms: 0 };
|
||||||
|
}
|
||||||
export function fromTalerProtocolDuration(
|
export function fromTalerProtocolDuration(
|
||||||
d: TalerProtocolDuration,
|
d: TalerProtocolDuration,
|
||||||
): Duration {
|
): Duration {
|
||||||
@ -113,6 +116,16 @@ export namespace Duration {
|
|||||||
d_ms: d.d_us / 1000,
|
d_ms: d.d_us / 1000,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
export function toTalerProtocolDuration(d: Duration): TalerProtocolDuration {
|
||||||
|
if (d.d_ms === "forever") {
|
||||||
|
return {
|
||||||
|
d_us: "forever",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
d_us: d.d_ms * 1000,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace AbsoluteTime {
|
export namespace AbsoluteTime {
|
||||||
|
@ -24,26 +24,23 @@
|
|||||||
/**
|
/**
|
||||||
* Imports
|
* Imports
|
||||||
*/
|
*/
|
||||||
import * as util from "util";
|
|
||||||
import * as fs from "fs";
|
|
||||||
import * as path from "path";
|
|
||||||
import * as http from "http";
|
|
||||||
import * as readline from "readline";
|
|
||||||
import { deepStrictEqual } from "assert";
|
|
||||||
import { ChildProcess, spawn } from "child_process";
|
|
||||||
import { URL } from "url";
|
|
||||||
import axios, { AxiosError } from "axios";
|
|
||||||
import {
|
import {
|
||||||
codecForMerchantOrderPrivateStatusResponse,
|
AmountJson,
|
||||||
codecForPostOrderResponse,
|
Amounts,
|
||||||
PostOrderRequest,
|
AmountString,
|
||||||
PostOrderResponse,
|
Configuration,
|
||||||
MerchantOrderPrivateStatusResponse,
|
CoreApiResponse,
|
||||||
TippingReserveStatus,
|
createEddsaKeyPair,
|
||||||
TipCreateConfirmation,
|
Duration,
|
||||||
TipCreateRequest,
|
eddsaGetPublic,
|
||||||
MerchantInstancesResponse,
|
EddsaKeyPair,
|
||||||
} from "./merchantApiTypes";
|
encodeCrock,
|
||||||
|
hash,
|
||||||
|
j2s,
|
||||||
|
parsePaytoUri,
|
||||||
|
stringToBytes,
|
||||||
|
TalerProtocolDuration,
|
||||||
|
} from "@gnu-taler/taler-util";
|
||||||
import {
|
import {
|
||||||
BankServiceHandle,
|
BankServiceHandle,
|
||||||
HarnessExchangeBankAccount,
|
HarnessExchangeBankAccount,
|
||||||
@ -52,28 +49,28 @@ import {
|
|||||||
TalerError,
|
TalerError,
|
||||||
WalletCoreApiClient,
|
WalletCoreApiClient,
|
||||||
} from "@gnu-taler/taler-wallet-core";
|
} from "@gnu-taler/taler-wallet-core";
|
||||||
import {
|
import { deepStrictEqual } from "assert";
|
||||||
AmountJson,
|
import axios, { AxiosError } from "axios";
|
||||||
Amounts,
|
import { ChildProcess, spawn } from "child_process";
|
||||||
Configuration,
|
import * as fs from "fs";
|
||||||
AmountString,
|
import * as http from "http";
|
||||||
Codec,
|
import * as path from "path";
|
||||||
buildCodecForObject,
|
import * as readline from "readline";
|
||||||
codecForString,
|
import { URL } from "url";
|
||||||
Duration,
|
import * as util from "util";
|
||||||
parsePaytoUri,
|
|
||||||
CoreApiResponse,
|
|
||||||
createEddsaKeyPair,
|
|
||||||
eddsaGetPublic,
|
|
||||||
EddsaKeyPair,
|
|
||||||
encodeCrock,
|
|
||||||
getRandomBytes,
|
|
||||||
hash,
|
|
||||||
stringToBytes,
|
|
||||||
j2s,
|
|
||||||
} from "@gnu-taler/taler-util";
|
|
||||||
import { CoinConfig } from "./denomStructures.js";
|
import { CoinConfig } from "./denomStructures.js";
|
||||||
import { LibeufinNexusApi, LibeufinSandboxApi } from "./libeufin-apis.js";
|
import { LibeufinNexusApi, LibeufinSandboxApi } from "./libeufin-apis.js";
|
||||||
|
import {
|
||||||
|
codecForMerchantOrderPrivateStatusResponse,
|
||||||
|
codecForPostOrderResponse,
|
||||||
|
MerchantInstancesResponse,
|
||||||
|
MerchantOrderPrivateStatusResponse,
|
||||||
|
PostOrderRequest,
|
||||||
|
PostOrderResponse,
|
||||||
|
TipCreateConfirmation,
|
||||||
|
TipCreateRequest,
|
||||||
|
TippingReserveStatus,
|
||||||
|
} from "./merchantApiTypes";
|
||||||
|
|
||||||
const exec = util.promisify(require("child_process").exec);
|
const exec = util.promisify(require("child_process").exec);
|
||||||
|
|
||||||
@ -1712,7 +1709,8 @@ export class MerchantService implements MerchantServiceInterface {
|
|||||||
console.log("adding instance");
|
console.log("adding instance");
|
||||||
const url = `http://localhost:${this.merchantConfig.httpPort}/management/instances`;
|
const url = `http://localhost:${this.merchantConfig.httpPort}/management/instances`;
|
||||||
const auth = instanceConfig.auth ?? { method: "external" };
|
const auth = instanceConfig.auth ?? { method: "external" };
|
||||||
await axios.post(url, {
|
|
||||||
|
const body: MerchantInstanceConfig = {
|
||||||
auth,
|
auth,
|
||||||
payto_uris: instanceConfig.paytoUris,
|
payto_uris: instanceConfig.paytoUris,
|
||||||
id: instanceConfig.id,
|
id: instanceConfig.id,
|
||||||
@ -1729,11 +1727,16 @@ export class MerchantService implements MerchantServiceInterface {
|
|||||||
`${this.merchantConfig.currency}:1.0`,
|
`${this.merchantConfig.currency}:1.0`,
|
||||||
default_wire_transfer_delay:
|
default_wire_transfer_delay:
|
||||||
instanceConfig.defaultWireTransferDelay ??
|
instanceConfig.defaultWireTransferDelay ??
|
||||||
Duration.fromSpec({
|
Duration.toTalerProtocolDuration(
|
||||||
days: 1,
|
Duration.fromSpec({
|
||||||
}),
|
days: 1,
|
||||||
default_pay_delay: instanceConfig.defaultPayDelay ?? { d_ms: "forever" },
|
}),
|
||||||
});
|
),
|
||||||
|
default_pay_delay:
|
||||||
|
instanceConfig.defaultPayDelay ??
|
||||||
|
Duration.toTalerProtocolDuration(Duration.getForever()),
|
||||||
|
};
|
||||||
|
await axios.post(url, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
makeInstanceBaseUrl(instanceName?: string): string {
|
makeInstanceBaseUrl(instanceName?: string): string {
|
||||||
@ -1765,8 +1768,8 @@ export interface PartialMerchantInstanceConfig {
|
|||||||
defaultMaxWireFee?: string;
|
defaultMaxWireFee?: string;
|
||||||
defaultMaxDepositFee?: string;
|
defaultMaxDepositFee?: string;
|
||||||
defaultWireFeeAmortization?: number;
|
defaultWireFeeAmortization?: number;
|
||||||
defaultWireTransferDelay?: Duration;
|
defaultWireTransferDelay?: TalerProtocolDuration;
|
||||||
defaultPayDelay?: Duration;
|
defaultPayDelay?: TalerProtocolDuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MerchantInstanceConfig {
|
export interface MerchantInstanceConfig {
|
||||||
@ -1779,8 +1782,8 @@ export interface MerchantInstanceConfig {
|
|||||||
default_max_wire_fee: string;
|
default_max_wire_fee: string;
|
||||||
default_max_deposit_fee: string;
|
default_max_deposit_fee: string;
|
||||||
default_wire_fee_amortization: number;
|
default_wire_fee_amortization: number;
|
||||||
default_wire_transfer_delay: Duration;
|
default_wire_transfer_delay: TalerProtocolDuration;
|
||||||
default_pay_delay: Duration;
|
default_pay_delay: TalerProtocolDuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
type TestStatus = "pass" | "fail" | "skip";
|
type TestStatus = "pass" | "fail" | "skip";
|
||||||
|
@ -30,7 +30,12 @@ import {
|
|||||||
Duration,
|
Duration,
|
||||||
PreparePayResultType,
|
PreparePayResultType,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import { BankAccessApi, BankApi, HarnessExchangeBankAccount, WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
import {
|
||||||
|
BankAccessApi,
|
||||||
|
BankApi,
|
||||||
|
HarnessExchangeBankAccount,
|
||||||
|
WalletApiOperation,
|
||||||
|
} from "@gnu-taler/taler-wallet-core";
|
||||||
import { CoinConfig, defaultCoinConfig } from "./denomStructures.js";
|
import { CoinConfig, defaultCoinConfig } from "./denomStructures.js";
|
||||||
import {
|
import {
|
||||||
FaultInjectedExchangeService,
|
FaultInjectedExchangeService,
|
||||||
@ -117,14 +122,18 @@ export async function createSimpleTestkudosEnvironment(
|
|||||||
id: "default",
|
id: "default",
|
||||||
name: "Default Instance",
|
name: "Default Instance",
|
||||||
paytoUris: [getPayto("merchant-default")],
|
paytoUris: [getPayto("merchant-default")],
|
||||||
defaultWireTransferDelay: Duration.fromSpec({ minutes: 1 }),
|
defaultWireTransferDelay: Duration.toTalerProtocolDuration(
|
||||||
|
Duration.fromSpec({ minutes: 1 }),
|
||||||
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
await merchant.addInstance({
|
await merchant.addInstance({
|
||||||
id: "minst1",
|
id: "minst1",
|
||||||
name: "minst1",
|
name: "minst1",
|
||||||
paytoUris: [getPayto("minst1")],
|
paytoUris: [getPayto("minst1")],
|
||||||
defaultWireTransferDelay: Duration.fromSpec({ minutes: 1 }),
|
defaultWireTransferDelay: Duration.toTalerProtocolDuration(
|
||||||
|
Duration.fromSpec({ minutes: 1 }),
|
||||||
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("setup done!");
|
console.log("setup done!");
|
||||||
|
@ -42,6 +42,7 @@ import {
|
|||||||
CoinPublicKeyString,
|
CoinPublicKeyString,
|
||||||
EddsaPublicKeyString,
|
EddsaPublicKeyString,
|
||||||
codecForAmountString,
|
codecForAmountString,
|
||||||
|
TalerProtocolDuration,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
|
|
||||||
export interface PostOrderRequest {
|
export interface PostOrderRequest {
|
||||||
@ -51,7 +52,7 @@ export interface PostOrderRequest {
|
|||||||
|
|
||||||
// if set, the backend will then set the refund deadline to the current
|
// if set, the backend will then set the refund deadline to the current
|
||||||
// time plus the specified delay.
|
// time plus the specified delay.
|
||||||
refund_delay?: Duration;
|
refund_delay?: TalerProtocolDuration;
|
||||||
|
|
||||||
// specifies the payment target preferred by the client. Can be used
|
// specifies the payment target preferred by the client. Can be used
|
||||||
// to select among the various (active) wire methods supported by the instance.
|
// to select among the various (active) wire methods supported by the instance.
|
||||||
@ -79,44 +80,48 @@ export const codecForPostOrderResponse = (): Codec<PostOrderResponse> =>
|
|||||||
.property("token", codecOptional(codecForString()))
|
.property("token", codecOptional(codecForString()))
|
||||||
.build("PostOrderResponse");
|
.build("PostOrderResponse");
|
||||||
|
|
||||||
export const codecForCheckPaymentPaidResponse = (): Codec<CheckPaymentPaidResponse> =>
|
export const codecForCheckPaymentPaidResponse =
|
||||||
buildCodecForObject<CheckPaymentPaidResponse>()
|
(): Codec<CheckPaymentPaidResponse> =>
|
||||||
.property("order_status_url", codecForString())
|
buildCodecForObject<CheckPaymentPaidResponse>()
|
||||||
.property("order_status", codecForConstString("paid"))
|
.property("order_status_url", codecForString())
|
||||||
.property("refunded", codecForBoolean())
|
.property("order_status", codecForConstString("paid"))
|
||||||
.property("wired", codecForBoolean())
|
.property("refunded", codecForBoolean())
|
||||||
.property("deposit_total", codecForAmountString())
|
.property("wired", codecForBoolean())
|
||||||
.property("exchange_ec", codecForNumber())
|
.property("deposit_total", codecForAmountString())
|
||||||
.property("exchange_hc", codecForNumber())
|
.property("exchange_ec", codecForNumber())
|
||||||
.property("refund_amount", codecForAmountString())
|
.property("exchange_hc", codecForNumber())
|
||||||
.property("contract_terms", codecForContractTerms())
|
.property("refund_amount", codecForAmountString())
|
||||||
// FIXME: specify
|
.property("contract_terms", codecForContractTerms())
|
||||||
.property("wire_details", codecForAny())
|
// FIXME: specify
|
||||||
.property("wire_reports", codecForAny())
|
.property("wire_details", codecForAny())
|
||||||
.property("refund_details", codecForAny())
|
.property("wire_reports", codecForAny())
|
||||||
.build("CheckPaymentPaidResponse");
|
.property("refund_details", codecForAny())
|
||||||
|
.build("CheckPaymentPaidResponse");
|
||||||
|
|
||||||
export const codecForCheckPaymentUnpaidResponse = (): Codec<CheckPaymentUnpaidResponse> =>
|
export const codecForCheckPaymentUnpaidResponse =
|
||||||
buildCodecForObject<CheckPaymentUnpaidResponse>()
|
(): Codec<CheckPaymentUnpaidResponse> =>
|
||||||
.property("order_status", codecForConstString("unpaid"))
|
buildCodecForObject<CheckPaymentUnpaidResponse>()
|
||||||
.property("taler_pay_uri", codecForString())
|
.property("order_status", codecForConstString("unpaid"))
|
||||||
.property("order_status_url", codecForString())
|
.property("taler_pay_uri", codecForString())
|
||||||
.property("already_paid_order_id", codecOptional(codecForString()))
|
.property("order_status_url", codecForString())
|
||||||
.build("CheckPaymentPaidResponse");
|
.property("already_paid_order_id", codecOptional(codecForString()))
|
||||||
|
.build("CheckPaymentPaidResponse");
|
||||||
|
|
||||||
export const codecForCheckPaymentClaimedResponse = (): Codec<CheckPaymentClaimedResponse> =>
|
export const codecForCheckPaymentClaimedResponse =
|
||||||
buildCodecForObject<CheckPaymentClaimedResponse>()
|
(): Codec<CheckPaymentClaimedResponse> =>
|
||||||
.property("order_status", codecForConstString("claimed"))
|
buildCodecForObject<CheckPaymentClaimedResponse>()
|
||||||
.property("contract_terms", codecForContractTerms())
|
.property("order_status", codecForConstString("claimed"))
|
||||||
.build("CheckPaymentClaimedResponse");
|
.property("contract_terms", codecForContractTerms())
|
||||||
|
.build("CheckPaymentClaimedResponse");
|
||||||
|
|
||||||
export const codecForMerchantOrderPrivateStatusResponse = (): Codec<MerchantOrderPrivateStatusResponse> =>
|
export const codecForMerchantOrderPrivateStatusResponse =
|
||||||
buildCodecForUnion<MerchantOrderPrivateStatusResponse>()
|
(): Codec<MerchantOrderPrivateStatusResponse> =>
|
||||||
.discriminateOn("order_status")
|
buildCodecForUnion<MerchantOrderPrivateStatusResponse>()
|
||||||
.alternative("paid", codecForCheckPaymentPaidResponse())
|
.discriminateOn("order_status")
|
||||||
.alternative("unpaid", codecForCheckPaymentUnpaidResponse())
|
.alternative("paid", codecForCheckPaymentPaidResponse())
|
||||||
.alternative("claimed", codecForCheckPaymentClaimedResponse())
|
.alternative("unpaid", codecForCheckPaymentUnpaidResponse())
|
||||||
.build("MerchantOrderPrivateStatusResponse");
|
.alternative("claimed", codecForCheckPaymentClaimedResponse())
|
||||||
|
.build("MerchantOrderPrivateStatusResponse");
|
||||||
|
|
||||||
export type MerchantOrderPrivateStatusResponse =
|
export type MerchantOrderPrivateStatusResponse =
|
||||||
| CheckPaymentPaidResponse
|
| CheckPaymentPaidResponse
|
||||||
|
@ -53,12 +53,8 @@ export async function runClauseSchnorrTest(t: GlobalTestState) {
|
|||||||
name: "rsa_dummy",
|
name: "rsa_dummy",
|
||||||
});
|
});
|
||||||
|
|
||||||
const {
|
const { wallet, bank, exchange, merchant } =
|
||||||
wallet,
|
await createSimpleTestkudosEnvironment(t, coinConfig);
|
||||||
bank,
|
|
||||||
exchange,
|
|
||||||
merchant,
|
|
||||||
} = await createSimpleTestkudosEnvironment(t, coinConfig);
|
|
||||||
|
|
||||||
// Withdraw digital cash into the wallet.
|
// Withdraw digital cash into the wallet.
|
||||||
|
|
||||||
@ -98,3 +94,4 @@ export async function runClauseSchnorrTest(t: GlobalTestState) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
runClauseSchnorrTest.suites = ["wallet"];
|
runClauseSchnorrTest.suites = ["wallet"];
|
||||||
|
runClauseSchnorrTest.excludeByDefault = true;
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
import {
|
import {
|
||||||
AbsoluteTime,
|
AbsoluteTime,
|
||||||
ContractTerms,
|
ContractTerms,
|
||||||
|
Duration,
|
||||||
|
durationFromSpec,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import {
|
import {
|
||||||
WalletApiOperation,
|
WalletApiOperation,
|
||||||
@ -209,7 +211,9 @@ export async function createLibeufinTestEnvironment(
|
|||||||
id: "default",
|
id: "default",
|
||||||
name: "Default Instance",
|
name: "Default Instance",
|
||||||
paytoUris: [`payto://iban/${merchantIban}?receiver-name=Merchant`],
|
paytoUris: [`payto://iban/${merchantIban}?receiver-name=Merchant`],
|
||||||
defaultWireTransferDelay: { d_ms: 0 },
|
defaultWireTransferDelay: Duration.toTalerProtocolDuration(
|
||||||
|
Duration.getZero(),
|
||||||
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("setup done!");
|
console.log("setup done!");
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
/**
|
/**
|
||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
|
import { Duration } from "@gnu-taler/taler-util";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import {
|
import {
|
||||||
ExchangeService,
|
ExchangeService,
|
||||||
@ -24,7 +25,7 @@ import {
|
|||||||
MerchantApiClient,
|
MerchantApiClient,
|
||||||
MerchantService,
|
MerchantService,
|
||||||
setupDb,
|
setupDb,
|
||||||
getPayto
|
getPayto,
|
||||||
} from "../harness/harness.js";
|
} from "../harness/harness.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,9 +68,13 @@ export async function runMerchantInstancesUrlsTest(t: GlobalTestState) {
|
|||||||
address: {},
|
address: {},
|
||||||
default_max_deposit_fee: "TESTKUDOS:1",
|
default_max_deposit_fee: "TESTKUDOS:1",
|
||||||
default_max_wire_fee: "TESTKUDOS:1",
|
default_max_wire_fee: "TESTKUDOS:1",
|
||||||
default_pay_delay: { d_ms: 60000 },
|
default_pay_delay: Duration.toTalerProtocolDuration(
|
||||||
|
Duration.fromSpec({ seconds: 60 }),
|
||||||
|
),
|
||||||
default_wire_fee_amortization: 1,
|
default_wire_fee_amortization: 1,
|
||||||
default_wire_transfer_delay: { d_ms: 60000 },
|
default_wire_transfer_delay: Duration.toTalerProtocolDuration(
|
||||||
|
Duration.fromSpec({ seconds: 60 }),
|
||||||
|
),
|
||||||
jurisdiction: {},
|
jurisdiction: {},
|
||||||
name: "My Default Instance",
|
name: "My Default Instance",
|
||||||
payto_uris: [getPayto("bar")],
|
payto_uris: [getPayto("bar")],
|
||||||
@ -84,9 +89,13 @@ export async function runMerchantInstancesUrlsTest(t: GlobalTestState) {
|
|||||||
address: {},
|
address: {},
|
||||||
default_max_deposit_fee: "TESTKUDOS:1",
|
default_max_deposit_fee: "TESTKUDOS:1",
|
||||||
default_max_wire_fee: "TESTKUDOS:1",
|
default_max_wire_fee: "TESTKUDOS:1",
|
||||||
default_pay_delay: { d_ms: 60000 },
|
default_pay_delay: Duration.toTalerProtocolDuration(
|
||||||
|
Duration.fromSpec({ seconds: 60 }),
|
||||||
|
),
|
||||||
default_wire_fee_amortization: 1,
|
default_wire_fee_amortization: 1,
|
||||||
default_wire_transfer_delay: { d_ms: 60000 },
|
default_wire_transfer_delay: Duration.toTalerProtocolDuration(
|
||||||
|
Duration.fromSpec({ seconds: 60 }),
|
||||||
|
),
|
||||||
jurisdiction: {},
|
jurisdiction: {},
|
||||||
name: "My Second Instance",
|
name: "My Second Instance",
|
||||||
payto_uris: [getPayto("bar")],
|
payto_uris: [getPayto("bar")],
|
||||||
|
@ -32,6 +32,7 @@ import {
|
|||||||
URL,
|
URL,
|
||||||
durationFromSpec,
|
durationFromSpec,
|
||||||
PreparePayResultType,
|
PreparePayResultType,
|
||||||
|
Duration,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import {
|
import {
|
||||||
@ -57,7 +58,9 @@ async function testRefundApiWithFulfillmentUrl(
|
|||||||
amount: "TESTKUDOS:5",
|
amount: "TESTKUDOS:5",
|
||||||
fulfillment_url: "https://example.com/fulfillment",
|
fulfillment_url: "https://example.com/fulfillment",
|
||||||
},
|
},
|
||||||
refund_delay: durationFromSpec({ minutes: 5 }),
|
refund_delay: Duration.toTalerProtocolDuration(
|
||||||
|
durationFromSpec({ minutes: 5 }),
|
||||||
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
|
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
|
||||||
@ -171,7 +174,9 @@ async function testRefundApiWithFulfillmentMessage(
|
|||||||
amount: "TESTKUDOS:5",
|
amount: "TESTKUDOS:5",
|
||||||
fulfillment_message: "Thank you for buying foobar",
|
fulfillment_message: "Thank you for buying foobar",
|
||||||
},
|
},
|
||||||
refund_delay: durationFromSpec({ minutes: 5 }),
|
refund_delay: Duration.toTalerProtocolDuration(
|
||||||
|
durationFromSpec({ minutes: 5 }),
|
||||||
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
|
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
|
||||||
|
@ -22,7 +22,7 @@ import {
|
|||||||
createSimpleTestkudosEnvironment,
|
createSimpleTestkudosEnvironment,
|
||||||
withdrawViaBank,
|
withdrawViaBank,
|
||||||
} from "../harness/helpers.js";
|
} from "../harness/helpers.js";
|
||||||
import { durationFromSpec } from "@gnu-taler/taler-util";
|
import { Duration, durationFromSpec } from "@gnu-taler/taler-util";
|
||||||
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,7 +48,9 @@ export async function runRefundAutoTest(t: GlobalTestState) {
|
|||||||
d_us: 3000 * 1000,
|
d_us: 3000 * 1000,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
refund_delay: durationFromSpec({ minutes: 5 }),
|
refund_delay: Duration.toTalerProtocolDuration(
|
||||||
|
durationFromSpec({ minutes: 5 }),
|
||||||
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
|
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
|
||||||
|
@ -25,6 +25,7 @@ import {
|
|||||||
} from "../harness/helpers.js";
|
} from "../harness/helpers.js";
|
||||||
import {
|
import {
|
||||||
AbsoluteTime,
|
AbsoluteTime,
|
||||||
|
Duration,
|
||||||
durationFromSpec,
|
durationFromSpec,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
||||||
@ -35,12 +36,8 @@ import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
|||||||
export async function runRefundGoneTest(t: GlobalTestState) {
|
export async function runRefundGoneTest(t: GlobalTestState) {
|
||||||
// Set up test environment
|
// Set up test environment
|
||||||
|
|
||||||
const {
|
const { wallet, bank, exchange, merchant } =
|
||||||
wallet,
|
await createSimpleTestkudosEnvironment(t);
|
||||||
bank,
|
|
||||||
exchange,
|
|
||||||
merchant,
|
|
||||||
} = await createSimpleTestkudosEnvironment(t);
|
|
||||||
|
|
||||||
// Withdraw digital cash into the wallet.
|
// Withdraw digital cash into the wallet.
|
||||||
|
|
||||||
@ -62,7 +59,9 @@ export async function runRefundGoneTest(t: GlobalTestState) {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
refund_delay: durationFromSpec({ minutes: 1 }),
|
refund_delay: Duration.toTalerProtocolDuration(
|
||||||
|
durationFromSpec({ minutes: 1 }),
|
||||||
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
|
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
|
||||||
|
@ -17,12 +17,20 @@
|
|||||||
/**
|
/**
|
||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import { GlobalTestState, delayMs, MerchantPrivateApi } from "../harness/harness.js";
|
import {
|
||||||
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "../harness/helpers.js";
|
GlobalTestState,
|
||||||
|
delayMs,
|
||||||
|
MerchantPrivateApi,
|
||||||
|
} from "../harness/harness.js";
|
||||||
|
import {
|
||||||
|
createSimpleTestkudosEnvironment,
|
||||||
|
withdrawViaBank,
|
||||||
|
} from "../harness/helpers.js";
|
||||||
import {
|
import {
|
||||||
TransactionType,
|
TransactionType,
|
||||||
Amounts,
|
Amounts,
|
||||||
durationFromSpec,
|
durationFromSpec,
|
||||||
|
Duration,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
||||||
|
|
||||||
@ -32,12 +40,8 @@ import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
|||||||
export async function runRefundIncrementalTest(t: GlobalTestState) {
|
export async function runRefundIncrementalTest(t: GlobalTestState) {
|
||||||
// Set up test environment
|
// Set up test environment
|
||||||
|
|
||||||
const {
|
const { wallet, bank, exchange, merchant } =
|
||||||
wallet,
|
await createSimpleTestkudosEnvironment(t);
|
||||||
bank,
|
|
||||||
exchange,
|
|
||||||
merchant,
|
|
||||||
} = await createSimpleTestkudosEnvironment(t);
|
|
||||||
|
|
||||||
// Withdraw digital cash into the wallet.
|
// Withdraw digital cash into the wallet.
|
||||||
|
|
||||||
@ -51,7 +55,9 @@ export async function runRefundIncrementalTest(t: GlobalTestState) {
|
|||||||
amount: "TESTKUDOS:10",
|
amount: "TESTKUDOS:10",
|
||||||
fulfillment_url: "taler://fulfillment-success/thx",
|
fulfillment_url: "taler://fulfillment-success/thx",
|
||||||
},
|
},
|
||||||
refund_delay: durationFromSpec({ minutes: 5 }),
|
refund_delay: Duration.toTalerProtocolDuration(
|
||||||
|
durationFromSpec({ minutes: 5 }),
|
||||||
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
|
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
|
||||||
|
@ -17,10 +17,13 @@
|
|||||||
/**
|
/**
|
||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import { durationFromSpec } from "@gnu-taler/taler-util";
|
import { Duration, durationFromSpec } from "@gnu-taler/taler-util";
|
||||||
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
||||||
import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js";
|
import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js";
|
||||||
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "../harness/helpers.js";
|
import {
|
||||||
|
createSimpleTestkudosEnvironment,
|
||||||
|
withdrawViaBank,
|
||||||
|
} from "../harness/helpers.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run test for basic, bank-integrated withdrawal.
|
* Run test for basic, bank-integrated withdrawal.
|
||||||
@ -28,12 +31,8 @@ import { createSimpleTestkudosEnvironment, withdrawViaBank } from "../harness/he
|
|||||||
export async function runRefundTest(t: GlobalTestState) {
|
export async function runRefundTest(t: GlobalTestState) {
|
||||||
// Set up test environment
|
// Set up test environment
|
||||||
|
|
||||||
const {
|
const { wallet, bank, exchange, merchant } =
|
||||||
wallet,
|
await createSimpleTestkudosEnvironment(t);
|
||||||
bank,
|
|
||||||
exchange,
|
|
||||||
merchant,
|
|
||||||
} = await createSimpleTestkudosEnvironment(t);
|
|
||||||
|
|
||||||
// Withdraw digital cash into the wallet.
|
// Withdraw digital cash into the wallet.
|
||||||
|
|
||||||
@ -47,7 +46,9 @@ export async function runRefundTest(t: GlobalTestState) {
|
|||||||
amount: "TESTKUDOS:5",
|
amount: "TESTKUDOS:5",
|
||||||
fulfillment_url: "taler://fulfillment-success/thx",
|
fulfillment_url: "taler://fulfillment-success/thx",
|
||||||
},
|
},
|
||||||
refund_delay: durationFromSpec({ minutes: 5 }),
|
refund_delay: Duration.toTalerProtocolDuration(
|
||||||
|
durationFromSpec({ minutes: 5 }),
|
||||||
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
|
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
|
||||||
|
Loading…
Reference in New Issue
Block a user