auto-format

This commit is contained in:
Florian Dold 2020-09-01 19:07:14 +05:30
parent 8c33e05bf0
commit bb369f2e2a
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
32 changed files with 129 additions and 77 deletions

View File

@ -257,7 +257,6 @@ export async function startWithdrawViaBank(
t.assertTrue(r2.type === "response"); t.assertTrue(r2.type === "response");
} }
/** /**
* Withdraw balance. * Withdraw balance.
*/ */
@ -270,7 +269,6 @@ export async function withdrawViaBank(
amount: AmountString; amount: AmountString;
}, },
): Promise<void> { ): Promise<void> {
const { wallet } = p; const { wallet } = p;
await startWithdrawViaBank(t, p); await startWithdrawViaBank(t, p);
@ -282,4 +280,3 @@ export async function withdrawViaBank(
const balApiResp = await wallet.apiRequest("getBalances", {}); const balApiResp = await wallet.apiRequest("getBalances", {});
t.assertTrue(balApiResp.type === "response"); t.assertTrue(balApiResp.type === "response");
} }

View File

@ -17,7 +17,21 @@
/** /**
* Imports. * Imports.
*/ */
import { runTest, GlobalTestState, MerchantPrivateApi, WalletCli, defaultCoinConfig, ExchangeService, setupDb, BankService, MerchantService, BankApi, BankUser, BankAccessApi, CreditDebitIndicator } from "./harness"; import {
runTest,
GlobalTestState,
MerchantPrivateApi,
WalletCli,
defaultCoinConfig,
ExchangeService,
setupDb,
BankService,
MerchantService,
BankApi,
BankUser,
BankAccessApi,
CreditDebitIndicator,
} from "./harness";
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers"; import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers";
import { createEddsaKeyPair, encodeCrock } from "taler-wallet-core"; import { createEddsaKeyPair, encodeCrock } from "taler-wallet-core";

View File

@ -234,7 +234,11 @@ runTest(async (t: GlobalTestState) => {
// Create withdrawal operation // Create withdrawal operation
const user = await BankApi.createRandomBankUser(bank); const user = await BankApi.createRandomBankUser(bank);
const wop = await BankAccessApi.createWithdrawalOperation(bank, user, "TESTKUDOS:10"); const wop = await BankAccessApi.createWithdrawalOperation(
bank,
user,
"TESTKUDOS:10",
);
// Hand it to the wallet // Hand it to the wallet

View File

@ -18,7 +18,11 @@
* Imports. * Imports.
*/ */
import { runTest, GlobalTestState, MerchantPrivateApi } from "./harness"; import { runTest, GlobalTestState, MerchantPrivateApi } from "./harness";
import { createSimpleTestkudosEnvironment, withdrawViaBank, createFaultInjectedMerchantTestkudosEnvironment } from "./helpers"; import {
createSimpleTestkudosEnvironment,
withdrawViaBank,
createFaultInjectedMerchantTestkudosEnvironment,
} from "./helpers";
import { import {
PreparePayResultType, PreparePayResultType,
codecForMerchantOrderStatusUnpaid, codecForMerchantOrderStatusUnpaid,
@ -64,7 +68,6 @@ runTest(async (t: GlobalTestState) => {
}, },
}); });
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
orderId: orderResp.order_id, orderId: orderResp.order_id,
sessionId: "mysession-one", sessionId: "mysession-one",
@ -159,7 +162,7 @@ runTest(async (t: GlobalTestState) => {
} else if (url.pathname.endsWith("/paid")) { } else if (url.pathname.endsWith("/paid")) {
numPaidRequested++; numPaidRequested++;
} }
} },
}); });
// Pay with new taler://pay URI, which should // Pay with new taler://pay URI, which should
@ -175,5 +178,4 @@ runTest(async (t: GlobalTestState) => {
// Make sure the wallet is actually doing the replay properly. // Make sure the wallet is actually doing the replay properly.
t.assertTrue(numPaidRequested == 1); t.assertTrue(numPaidRequested == 1);
t.assertTrue(numPayRequested == 0); t.assertTrue(numPayRequested == 0);
}); });

View File

@ -102,8 +102,7 @@ runTest(async (t: GlobalTestState) => {
}); });
t.assertTrue( t.assertTrue(
err.operationError.code === err.operationError.code === TalerErrorCode.WALLET_ORDER_ALREADY_CLAIMED,
TalerErrorCode.WALLET_ORDER_ALREADY_CLAIMED,
); );
await t.shutdown(); await t.shutdown();

View File

@ -117,7 +117,11 @@ runTest(async (t: GlobalTestState) => {
// Create withdrawal operation // Create withdrawal operation
const user = await BankApi.createRandomBankUser(bank); const user = await BankApi.createRandomBankUser(bank);
const wop = await BankAccessApi.createWithdrawalOperation(bank, user, "TESTKUDOS:20"); const wop = await BankAccessApi.createWithdrawalOperation(
bank,
user,
"TESTKUDOS:20",
);
// Hand it to the wallet // Hand it to the wallet

View File

@ -94,7 +94,9 @@ runTest(async (t: GlobalTestState) => {
talerPayUri, talerPayUri,
}); });
t.assertTrue(preparePayResultAfter.status === PreparePayResultType.AlreadyConfirmed); t.assertTrue(
preparePayResultAfter.status === PreparePayResultType.AlreadyConfirmed,
);
t.assertTrue(preparePayResultAfter.paid === true); t.assertTrue(preparePayResultAfter.paid === true);
await t.shutdown(); await t.shutdown();

View File

@ -17,7 +17,12 @@
/** /**
* Imports. * Imports.
*/ */
import { runTest, GlobalTestState, MerchantPrivateApi, WalletCli } from "./harness"; import {
runTest,
GlobalTestState,
MerchantPrivateApi,
WalletCli,
} from "./harness";
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers"; import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers";
import { PreparePayResultType } from "taler-wallet-core"; import { PreparePayResultType } from "taler-wallet-core";
@ -60,7 +65,9 @@ runTest(async (t: GlobalTestState) => {
talerPayUri: orderStatus.taler_pay_uri, talerPayUri: orderStatus.taler_pay_uri,
}); });
t.assertTrue(preparePayResult.status === PreparePayResultType.PaymentPossible); t.assertTrue(
preparePayResult.status === PreparePayResultType.PaymentPossible,
);
const r2 = await wallet.apiRequest("confirmPay", { const r2 = await wallet.apiRequest("confirmPay", {
// FIXME: should be validated, don't cast! // FIXME: should be validated, don't cast!

View File

@ -220,9 +220,7 @@ runTest(async (t: GlobalTestState) => {
}); });
if (publicOrderStatusResp.status != 402) { if (publicOrderStatusResp.status != 402) {
throw Error( throw Error(`expected status 402, but got ${publicOrderStatusResp.status}`);
`expected status 402, but got ${publicOrderStatusResp.status}`,
);
} }
pubUnpaidStatus = codecForMerchantOrderStatusUnpaid().decode( pubUnpaidStatus = codecForMerchantOrderStatusUnpaid().decode(

View File

@ -46,7 +46,7 @@ runTest(async (t: GlobalTestState) => {
fulfillment_url: "taler://fulfillment-success/thx", fulfillment_url: "taler://fulfillment-success/thx",
auto_refund: { auto_refund: {
d_ms: 3000, d_ms: 3000,
} },
}, },
}); });
@ -89,7 +89,7 @@ runTest(async (t: GlobalTestState) => {
// The wallet should now automatically pick up the refund. // The wallet should now automatically pick up the refund.
await wallet.runUntilDone(); await wallet.runUntilDone();
const transactions = await wallet.getTransactions() const transactions = await wallet.getTransactions();
console.log(JSON.stringify(transactions, undefined, 2)); console.log(JSON.stringify(transactions, undefined, 2));
const transactionTypes = transactions.transactions.map((x) => x.type); const transactionTypes = transactions.transactions.map((x) => x.type);

View File

@ -17,7 +17,12 @@
/** /**
* Imports. * Imports.
*/ */
import { runTest, GlobalTestState, delayMs, MerchantPrivateApi } from "./harness"; import {
runTest,
GlobalTestState,
delayMs,
MerchantPrivateApi,
} from "./harness";
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers"; import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers";
/** /**

View File

@ -17,18 +17,13 @@
/** /**
* Imports. * Imports.
*/ */
import { import { runTest, GlobalTestState } from "./harness";
runTest,
GlobalTestState,
MerchantPrivateApi,
WalletCli,
} from "./harness";
import { import {
createSimpleTestkudosEnvironment, createSimpleTestkudosEnvironment,
withdrawViaBank, withdrawViaBank,
startWithdrawViaBank, startWithdrawViaBank,
} from "./helpers"; } from "./helpers";
import { PreparePayResultType, durationMin, Duration, TransactionType } from "taler-wallet-core"; import { Duration, TransactionType } from "taler-wallet-core";
/** /**
* Basic time travel test. * Basic time travel test.

View File

@ -81,10 +81,7 @@ runTest(async (t: GlobalTestState) => {
console.log(JSON.stringify(txns, undefined, 2)); console.log(JSON.stringify(txns, undefined, 2));
txTypes = txns.transactions.map((x) => x.type); txTypes = txns.transactions.map((x) => x.type);
t.assertDeepEqual(txTypes, [ t.assertDeepEqual(txTypes, ["withdrawal", "payment"]);
"withdrawal",
"payment",
]);
await t.shutdown(); await t.shutdown();
}); });

View File

@ -32,7 +32,11 @@ runTest(async (t: GlobalTestState) => {
// Create a withdrawal operation // Create a withdrawal operation
const user = await BankApi.createRandomBankUser(bank); const user = await BankApi.createRandomBankUser(bank);
const wop = await BankAccessApi.createWithdrawalOperation(bank, user, "TESTKUDOS:10"); const wop = await BankAccessApi.createWithdrawalOperation(
bank,
user,
"TESTKUDOS:10",
);
// Hand it to the wallet // Hand it to the wallet

View File

@ -22,8 +22,6 @@
*/ */
export enum TalerErrorCode { export enum TalerErrorCode {
/** /**
* Special code to indicate no error (or no "code" present). * Special code to indicate no error (or no "code" present).
* Returned with an HTTP status code of #MHD_HTTP_UNINITIALIZED (0). * Returned with an HTTP status code of #MHD_HTTP_UNINITIALIZED (0).
@ -3278,5 +3276,4 @@ export enum TalerErrorCode {
* (A value of 0 indicates that the error is generated client-side). * (A value of 0 indicates that the error is generated client-side).
*/ */
END = 9999, END = 9999,
} }

View File

@ -203,10 +203,7 @@ export class CryptoApi {
handleWorkerError(ws: WorkerState, e: any): void { handleWorkerError(ws: WorkerState, e: any): void {
if (ws.currentWorkItem) { if (ws.currentWorkItem) {
logger.error( logger.error(`error in worker during ${ws.currentWorkItem.operation}`, e);
`error in worker during ${ws.currentWorkItem.operation}`,
e,
);
} else { } else {
logger.error("error in worker", e); logger.error("error in worker", e);
} }

View File

@ -63,7 +63,8 @@ export class NodeHttpLib implements HttpRequestLibrary {
requestMethod: method, requestMethod: method,
requestUrl: url, requestUrl: url,
throttleStats: this.throttle.getThrottleStats(url), throttleStats: this.throttle.getThrottleStats(url),
}); },
);
} }
let timeout: number | undefined; let timeout: number | undefined;
if (typeof opt?.timeout?.d_ms === "number") { if (typeof opt?.timeout?.d_ms === "number") {

View File

@ -85,6 +85,9 @@ export function str(stringSeq: TemplateStringsArray, ...values: any[]): string {
* from a JSON object. Fall back to the default language of the JSON object * from a JSON object. Fall back to the default language of the JSON object
* if no match exists. * if no match exists.
*/ */
export function getJsonI18n<K extends string>(obj: Record<K, string>, key: K): string { export function getJsonI18n<K extends string>(
obj: Record<K, string>,
key: K,
): string {
return obj[key]; return obj[key];
} }

View File

@ -63,4 +63,4 @@ export * from "./util/time";
export * from "./types/talerTypes"; export * from "./types/talerTypes";
export * from "./types/walletTypes"; export * from "./types/walletTypes";
export * from "./types/notifications"; export * from "./types/notifications";
export * from "./types/transactions" export * from "./types/transactions";

View File

@ -260,7 +260,12 @@ async function acceptRefunds(
const refreshCoinsPubs = Object.values(refreshCoinsMap); const refreshCoinsPubs = Object.values(refreshCoinsMap);
if (refreshCoinsPubs.length > 0) { if (refreshCoinsPubs.length > 0) {
await createRefreshGroup(ws, tx, refreshCoinsPubs, RefreshReason.Refund); await createRefreshGroup(
ws,
tx,
refreshCoinsPubs,
RefreshReason.Refund,
);
} }
// Are we done with querying yet, or do we need to do another round // Are we done with querying yet, or do we need to do another round

View File

@ -33,7 +33,11 @@ import { Wallet } from "../wallet";
import { Amounts } from "../util/amounts"; import { Amounts } from "../util/amounts";
import { NodeHttpLib } from "../headless/NodeHttpLib"; import { NodeHttpLib } from "../headless/NodeHttpLib";
import { getDefaultNodeWallet } from "../headless/helpers"; import { getDefaultNodeWallet } from "../headless/helpers";
import { TestPayArgs, PreparePayResultType, IntegrationTestArgs } from "../types/walletTypes"; import {
TestPayArgs,
PreparePayResultType,
IntegrationTestArgs,
} from "../types/walletTypes";
const logger = new Logger("operations/testing.ts"); const logger = new Logger("operations/testing.ts");
@ -410,7 +414,10 @@ export async function testPay(
args: TestPayArgs, args: TestPayArgs,
) { ) {
logger.trace("creating order"); logger.trace("creating order");
const merchant = { apikey: args.merchantApiKey, baseUrl: args.merchantBaseUrl }; const merchant = {
apikey: args.merchantApiKey,
baseUrl: args.merchantBaseUrl,
};
const orderResp = await createOrder( const orderResp = await createOrder(
http, http,
merchant, merchant,

View File

@ -48,7 +48,11 @@ import { updateExchangeFromUrl, getExchangeTrust } from "./exchanges";
import { WALLET_EXCHANGE_PROTOCOL_VERSION } from "./versions"; import { WALLET_EXCHANGE_PROTOCOL_VERSION } from "./versions";
import * as LibtoolVersion from "../util/libtoolVersion"; import * as LibtoolVersion from "../util/libtoolVersion";
import { guardOperationException, makeErrorDetails, OperationFailedError } from "./errors"; import {
guardOperationException,
makeErrorDetails,
OperationFailedError,
} from "./errors";
import { NotificationType } from "../types/notifications"; import { NotificationType } from "../types/notifications";
import { import {
getTimestampNow, getTimestampNow,

View File

@ -963,7 +963,9 @@ export interface WithdrawUriInfoResponse {
possibleExchanges: ExchangeListItem[]; possibleExchanges: ExchangeListItem[];
} }
export const codecForWithdrawUriInfoResponse = (): Codec<WithdrawUriInfoResponse> => export const codecForWithdrawUriInfoResponse = (): Codec<
WithdrawUriInfoResponse
> =>
buildCodecForObject<WithdrawUriInfoResponse>() buildCodecForObject<WithdrawUriInfoResponse>()
.property("amount", codecForAmountString()) .property("amount", codecForAmountString())
.property("defaultExchangeBaseUrl", codecOptional(codecForString())) .property("defaultExchangeBaseUrl", codecOptional(codecForString()))
@ -1046,14 +1048,18 @@ export const codecForTax = (): Codec<Tax> =>
.property("tax", codecForString()) .property("tax", codecForString())
.build("Tax"); .build("Tax");
export const codecForInternationalizedString = (): Codec<InternationalizedString> => export const codecForInternationalizedString = (): Codec<
codecForMap(codecForString()); InternationalizedString
> => codecForMap(codecForString());
export const codecForProduct = (): Codec<Product> => export const codecForProduct = (): Codec<Product> =>
buildCodecForObject<Product>() buildCodecForObject<Product>()
.property("product_id", codecOptional(codecForString())) .property("product_id", codecOptional(codecForString()))
.property("description", codecForString()) .property("description", codecForString())
.property("description_i18n", codecOptional(codecForInternationalizedString())) .property(
"description_i18n",
codecOptional(codecForInternationalizedString()),
)
.property("quantity", codecOptional(codecForNumber())) .property("quantity", codecOptional(codecForNumber()))
.property("unit", codecOptional(codecForString())) .property("unit", codecOptional(codecForString()))
.property("price", codecOptional(codecForString())) .property("price", codecOptional(codecForString()))
@ -1066,7 +1072,10 @@ export const codecForContractTerms = (): Codec<ContractTerms> =>
.property("order_id", codecForString()) .property("order_id", codecForString())
.property("fulfillment_url", codecOptional(codecForString())) .property("fulfillment_url", codecOptional(codecForString()))
.property("fulfillment_message", codecOptional(codecForString())) .property("fulfillment_message", codecOptional(codecForString()))
.property("fulfillment_message_i18n", codecOptional(codecForInternationalizedString())) .property(
"fulfillment_message_i18n",
codecOptional(codecForInternationalizedString()),
)
.property("merchant_base_url", codecForString()) .property("merchant_base_url", codecForString())
.property("h_wire", codecForString()) .property("h_wire", codecForString())
.property("auto_refund", codecOptional(codecForDuration)) .property("auto_refund", codecOptional(codecForDuration))
@ -1086,10 +1095,7 @@ export const codecForContractTerms = (): Codec<ContractTerms> =>
.property("merchant", codecForMerchantInfo()) .property("merchant", codecForMerchantInfo())
.property("merchant_pub", codecForString()) .property("merchant_pub", codecForString())
.property("exchanges", codecForList(codecForExchangeHandle())) .property("exchanges", codecForList(codecForExchangeHandle()))
.property( .property("products", codecOptional(codecForList(codecForProduct())))
"products",
codecOptional(codecForList(codecForProduct())),
)
.property("extra", codecForAny()) .property("extra", codecForAny())
.build("ContractTerms"); .build("ContractTerms");

View File

@ -50,7 +50,11 @@ import {
codecForAny, codecForAny,
buildCodecForUnion, buildCodecForUnion,
} from "../util/codec"; } from "../util/codec";
import { AmountString, codecForContractTerms, ContractTerms } from "./talerTypes"; import {
AmountString,
codecForContractTerms,
ContractTerms,
} from "./talerTypes";
/** /**
* Response for the create reserve request to the wallet. * Response for the create reserve request to the wallet.
@ -831,7 +835,9 @@ export const withdrawTestBalanceDefaults = {
exchangeBaseUrl: "https://exchange.test.taler.net/", exchangeBaseUrl: "https://exchange.test.taler.net/",
}; };
export const codecForWithdrawTestBalance = (): Codec<WithdrawTestBalanceRequest> => export const codecForWithdrawTestBalance = (): Codec<
WithdrawTestBalanceRequest
> =>
buildCodecForObject<WithdrawTestBalanceRequest>() buildCodecForObject<WithdrawTestBalanceRequest>()
.property("amount", codecForString()) .property("amount", codecForString())
.property("bankBaseUrl", codecForString()) .property("bankBaseUrl", codecForString())

View File

@ -146,6 +146,6 @@ export class RequestThrottler {
maxTokensHour: MAX_PER_HOUR, maxTokensHour: MAX_PER_HOUR,
maxTokensMinute: MAX_PER_MINUTE, maxTokensMinute: MAX_PER_MINUTE,
maxTokensSecond: MAX_PER_SECOND, maxTokensSecond: MAX_PER_SECOND,
} };
} }
} }

View File

@ -44,7 +44,7 @@ export interface HttpResponse {
export interface HttpRequestOptions { export interface HttpRequestOptions {
headers?: { [name: string]: string }; headers?: { [name: string]: string };
timeout?: Duration, timeout?: Duration;
} }
export enum HttpResponseStatus { export enum HttpResponseStatus {

View File

@ -37,7 +37,6 @@ import {
} from "idb-bridge"; } from "idb-bridge";
import { Logger } from "./logging"; import { Logger } from "./logging";
const logger = new Logger("query.ts"); const logger = new Logger("query.ts");
/** /**

View File

@ -351,7 +351,6 @@ export class Wallet {
await p; await p;
} }
/** /**
* Process pending operations and wait for scheduled operations in * Process pending operations and wait for scheduled operations in
* a loop until the wallet is stopped explicitly. * a loop until the wallet is stopped explicitly.