diff options
author | Florian Dold <florian@dold.me> | 2022-03-18 15:32:41 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2022-03-21 19:20:48 +0100 |
commit | f8d12f7b0d4af1b1769b89e80c87f9c169678564 (patch) | |
tree | 2478696c7bc1efc6d090b93aa340de542a7dccd9 /packages/taler-wallet-cli | |
parent | 32cd54e11d80bde0274b3c0238f8f5bd00ff83cb (diff) |
wallet: t_s/d_us migration
Diffstat (limited to 'packages/taler-wallet-cli')
8 files changed, 49 insertions, 41 deletions
diff --git a/packages/taler-wallet-cli/src/harness/harness.ts b/packages/taler-wallet-cli/src/harness/harness.ts index 1500d7743..63bb17fcc 100644 --- a/packages/taler-wallet-cli/src/harness/harness.ts +++ b/packages/taler-wallet-cli/src/harness/harness.ts @@ -478,7 +478,7 @@ class BankServiceBase { protected globalTestState: GlobalTestState, protected bankConfig: BankConfig, protected configFile: string, - ) { } + ) {} } /** @@ -920,7 +920,7 @@ export class FakeBankService { private globalTestState: GlobalTestState, private bankConfig: FakeBankConfig, private configFile: string, - ) { } + ) {} async start(): Promise<void> { this.proc = this.globalTestState.spawnService( @@ -1175,7 +1175,7 @@ export class ExchangeService implements ExchangeServiceInterface { private exchangeConfig: ExchangeConfig, private configFilename: string, private keyPair: EddsaKeyPair, - ) { } + ) {} get name() { return this.exchangeConfig.name; @@ -1276,7 +1276,7 @@ export class ExchangeService implements ExchangeServiceInterface { accTargetType, `${this.exchangeConfig.currency}:0.01`, `${this.exchangeConfig.currency}:0.01`, - // `${this.exchangeConfig.currency}:0.01`, + `${this.exchangeConfig.currency}:0.01`, "upload", ], ); @@ -1398,7 +1398,7 @@ export class MerchantApiClient { constructor( private baseUrl: string, public readonly auth: MerchantAuthConfiguration, - ) { } + ) {} async changeAuth(auth: MerchantAuthConfiguration): Promise<void> { const url = new URL("private/auth", this.baseUrl); @@ -1591,7 +1591,7 @@ export class MerchantService implements MerchantServiceInterface { private globalState: GlobalTestState, private merchantConfig: MerchantConfig, private configFilename: string, - ) { } + ) {} private currentTimetravel: Duration | undefined; @@ -1888,8 +1888,10 @@ export class WalletCli { const resp = await sh( self.globalTestState, `wallet-${self.name}`, - `taler-wallet-cli ${self.timetravelArg ?? "" - } --no-throttle -LTRACE --wallet-db '${self.dbfile + `taler-wallet-cli ${ + self.timetravelArg ?? "" + } --no-throttle -LTRACE --wallet-db '${ + self.dbfile }' api '${op}' ${shellWrap(JSON.stringify(payload))}`, ); console.log("--- wallet core response ---"); diff --git a/packages/taler-wallet-cli/src/harness/merchantApiTypes.ts b/packages/taler-wallet-cli/src/harness/merchantApiTypes.ts index a93a0ed25..dcb1a2b42 100644 --- a/packages/taler-wallet-cli/src/harness/merchantApiTypes.ts +++ b/packages/taler-wallet-cli/src/harness/merchantApiTypes.ts @@ -38,7 +38,7 @@ import { codecForAny, buildCodecForUnion, AmountString, - Timestamp, + AbsoluteTime, CoinPublicKeyString, EddsaPublicKeyString, codecForAmountString, @@ -195,7 +195,7 @@ export interface RefundDetails { reason: string; // when was the refund approved - timestamp: Timestamp; + timestamp: AbsoluteTime; // Total amount that was refunded (minus a refund fee). amount: AmountString; @@ -209,7 +209,7 @@ export interface TransactionWireTransfer { wtid: string; // execution time of the wire transfer - execution_time: Timestamp; + execution_time: AbsoluteTime; // Total amount that has been wire transferred // to the merchant @@ -247,10 +247,10 @@ export interface ReserveStatusEntry { reserve_pub: string; // Timestamp when it was established - creation_time: Timestamp; + creation_time: AbsoluteTime; // Timestamp when it expires - expiration_time: Timestamp; + expiration_time: AbsoluteTime; // Initial amount as per reserve creation call merchant_initial_amount: AmountString; @@ -281,7 +281,7 @@ export interface TipCreateConfirmation { tip_status_url: string; // when does the tip expire - tip_expiration: Timestamp; + tip_expiration: AbsoluteTime; } export interface TipCreateRequest { diff --git a/packages/taler-wallet-cli/src/integrationtests/test-bank-api.ts b/packages/taler-wallet-cli/src/integrationtests/test-bank-api.ts index 8e4109752..8a11b79c6 100644 --- a/packages/taler-wallet-cli/src/integrationtests/test-bank-api.ts +++ b/packages/taler-wallet-cli/src/integrationtests/test-bank-api.ts @@ -32,6 +32,7 @@ import { BankApi, BankAccessApi, CreditDebitIndicator, + OperationFailedError, } from "@gnu-taler/taler-wallet-core"; /** @@ -106,8 +107,7 @@ export async function runBankApiTest(t: GlobalTestState) { const e = await t.assertThrowsAsync(async () => { await BankApi.registerAccount(bank, "user1", "pw1"); }); - t.assertAxiosError(e); - t.assertTrue(e.response?.status === 409); + t.assertTrue(e.details.httpStatusCode === 409); } let balResp = await BankAccessApi.getAccountBalance(bank, bankUser); diff --git a/packages/taler-wallet-cli/src/integrationtests/test-exchange-timetravel.ts b/packages/taler-wallet-cli/src/integrationtests/test-exchange-timetravel.ts index ed07114eb..e2b81ee6a 100644 --- a/packages/taler-wallet-cli/src/integrationtests/test-exchange-timetravel.ts +++ b/packages/taler-wallet-cli/src/integrationtests/test-exchange-timetravel.ts @@ -18,11 +18,11 @@ * Imports. */ import { + AbsoluteTime, codecForExchangeKeysJson, DenominationPubKey, Duration, durationFromSpec, - stringifyTimestamp, } from "@gnu-taler/taler-util"; import { NodeHttpLib, @@ -174,27 +174,37 @@ export async function runExchangeTimetravelTest(t: GlobalTestState) { const denomPubs1 = keys1.denoms.map((x) => { return { denomPub: x.denom_pub, - expireDeposit: stringifyTimestamp(x.stamp_expire_deposit), + expireDeposit: AbsoluteTime.stringify( + AbsoluteTime.fromTimestamp(x.stamp_expire_deposit), + ), }; }); const denomPubs2 = keys2.denoms.map((x) => { return { denomPub: x.denom_pub, - expireDeposit: stringifyTimestamp(x.stamp_expire_deposit), + expireDeposit: AbsoluteTime.stringify( + AbsoluteTime.fromTimestamp(x.stamp_expire_deposit), + ), }; }); const dps2 = new Set(denomPubs2.map((x) => x.denomPub)); console.log("=== KEYS RESPONSE 1 ==="); - console.log("list issue date", stringifyTimestamp(keys1.list_issue_date)); + console.log( + "list issue date", + AbsoluteTime.stringify(AbsoluteTime.fromTimestamp(keys1.list_issue_date)), + ); console.log("num denoms", keys1.denoms.length); console.log("denoms", JSON.stringify(denomPubs1, undefined, 2)); console.log("=== KEYS RESPONSE 2 ==="); - console.log("list issue date", stringifyTimestamp(keys2.list_issue_date)); + console.log( + "list issue date", + AbsoluteTime.stringify(AbsoluteTime.fromTimestamp(keys2.list_issue_date)), + ); console.log("num denoms", keys2.denoms.length); console.log("denoms", JSON.stringify(denomPubs2, undefined, 2)); @@ -214,8 +224,8 @@ export async function runExchangeTimetravelTest(t: GlobalTestState) { `denomination with public key ${da.denomPub} is not present in new /keys response`, ); console.log( - `the new /keys response was issued ${stringifyTimestamp( - keys2.list_issue_date, + `the new /keys response was issued ${AbsoluteTime.stringify( + AbsoluteTime.fromTimestamp(keys2.list_issue_date), )}`, ); console.log( diff --git a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-basic.ts b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-basic.ts index 33aad80d2..8f7d77712 100644 --- a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-basic.ts +++ b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-basic.ts @@ -18,9 +18,8 @@ * Imports. */ import { + AbsoluteTime, ContractTerms, - getTimestampNow, - timestampTruncateToSecond, } from "@gnu-taler/taler-util"; import { WalletApiOperation, @@ -277,7 +276,7 @@ export async function runLibeufinBasicTest(t: GlobalTestState) { summary: "Buy me!", amount: "EUR:5", fulfillment_url: "taler://fulfillment-success/thx", - wire_transfer_deadline: timestampTruncateToSecond(getTimestampNow()), + wire_transfer_deadline: AbsoluteTime.toTimestamp(AbsoluteTime.now()), }; await makeTestPayment(t, { wallet, merchant, order }); diff --git a/packages/taler-wallet-cli/src/integrationtests/test-merchant-instances-delete.ts b/packages/taler-wallet-cli/src/integrationtests/test-merchant-instances-delete.ts index ef926c4af..2bef87b20 100644 --- a/packages/taler-wallet-cli/src/integrationtests/test-merchant-instances-delete.ts +++ b/packages/taler-wallet-cli/src/integrationtests/test-merchant-instances-delete.ts @@ -25,7 +25,7 @@ import { MerchantApiClient, MerchantService, setupDb, - getPayto + getPayto, } from "../harness/harness.js"; /** diff --git a/packages/taler-wallet-cli/src/integrationtests/test-refund-auto.ts b/packages/taler-wallet-cli/src/integrationtests/test-refund-auto.ts index 230fc942d..574177c8c 100644 --- a/packages/taler-wallet-cli/src/integrationtests/test-refund-auto.ts +++ b/packages/taler-wallet-cli/src/integrationtests/test-refund-auto.ts @@ -18,7 +18,10 @@ * Imports. */ import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js"; -import { createSimpleTestkudosEnvironment, withdrawViaBank } from "../harness/helpers.js"; +import { + createSimpleTestkudosEnvironment, + withdrawViaBank, +} from "../harness/helpers.js"; import { durationFromSpec } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; @@ -28,12 +31,8 @@ import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; export async function runRefundAutoTest(t: GlobalTestState) { // Set up test environment - const { - wallet, - bank, - exchange, - merchant, - } = await createSimpleTestkudosEnvironment(t); + const { wallet, bank, exchange, merchant } = + await createSimpleTestkudosEnvironment(t); // Withdraw digital cash into the wallet. @@ -46,7 +45,7 @@ export async function runRefundAutoTest(t: GlobalTestState) { amount: "TESTKUDOS:5", fulfillment_url: "taler://fulfillment-success/thx", auto_refund: { - d_ms: 3000, + d_us: 3000 * 1000, }, }, refund_delay: durationFromSpec({ minutes: 5 }), diff --git a/packages/taler-wallet-cli/src/integrationtests/test-refund-gone.ts b/packages/taler-wallet-cli/src/integrationtests/test-refund-gone.ts index c6442a240..24600384b 100644 --- a/packages/taler-wallet-cli/src/integrationtests/test-refund-gone.ts +++ b/packages/taler-wallet-cli/src/integrationtests/test-refund-gone.ts @@ -24,10 +24,8 @@ import { applyTimeTravel, } from "../harness/helpers.js"; import { + AbsoluteTime, durationFromSpec, - timestampAddDuration, - getTimestampNow, - timestampTruncateToSecond, } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; @@ -55,9 +53,9 @@ export async function runRefundGoneTest(t: GlobalTestState) { summary: "Buy me!", amount: "TESTKUDOS:5", fulfillment_url: "taler://fulfillment-success/thx", - pay_deadline: timestampTruncateToSecond( - timestampAddDuration( - getTimestampNow(), + pay_deadline: AbsoluteTime.toTimestamp( + AbsoluteTime.addDuration( + AbsoluteTime.now(), durationFromSpec({ minutes: 10, }), |