use cheaper denom structure for auto-refresh test
This commit is contained in:
parent
e964367d0a
commit
855b7028c6
@ -948,8 +948,11 @@ export default class BTree<K = any, V = any>
|
||||
|
||||
/** Ensures mutations are allowed, reversing the effect of freeze(). */
|
||||
unfreeze() {
|
||||
// @ts-ignore
|
||||
delete this.clear;
|
||||
// @ts-ignore
|
||||
delete this.set;
|
||||
// @ts-ignore
|
||||
delete this.editRange;
|
||||
}
|
||||
|
||||
|
@ -91,6 +91,7 @@ import {
|
||||
} from "./merchantApiTypes";
|
||||
import { ApplyRefundResponse } from "taler-wallet-core";
|
||||
import { PendingOperationsResponse } from "taler-wallet-core";
|
||||
import { CoinConfig } from "./denomStructures";
|
||||
|
||||
const exec = util.promisify(require("child_process").exec);
|
||||
|
||||
@ -221,96 +222,6 @@ export class ProcessWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
interface CoinConfig {
|
||||
name: string;
|
||||
value: string;
|
||||
durationWithdraw: string;
|
||||
durationSpend: string;
|
||||
durationLegal: string;
|
||||
feeWithdraw: string;
|
||||
feeDeposit: string;
|
||||
feeRefresh: string;
|
||||
feeRefund: string;
|
||||
rsaKeySize: number;
|
||||
}
|
||||
|
||||
const coinCommon = {
|
||||
durationLegal: "3 years",
|
||||
durationSpend: "2 years",
|
||||
durationWithdraw: "7 days",
|
||||
rsaKeySize: 1024,
|
||||
};
|
||||
|
||||
export const coin_ct1 = (curr: string): CoinConfig => ({
|
||||
...coinCommon,
|
||||
name: `${curr}_ct1`,
|
||||
value: `${curr}:0.01`,
|
||||
feeDeposit: `${curr}:0.00`,
|
||||
feeRefresh: `${curr}:0.01`,
|
||||
feeRefund: `${curr}:0.00`,
|
||||
feeWithdraw: `${curr}:0.01`,
|
||||
});
|
||||
|
||||
export const coin_ct10 = (curr: string): CoinConfig => ({
|
||||
...coinCommon,
|
||||
name: `${curr}_ct10`,
|
||||
value: `${curr}:0.10`,
|
||||
feeDeposit: `${curr}:0.01`,
|
||||
feeRefresh: `${curr}:0.01`,
|
||||
feeRefund: `${curr}:0.00`,
|
||||
feeWithdraw: `${curr}:0.01`,
|
||||
});
|
||||
|
||||
export const coin_u1 = (curr: string): CoinConfig => ({
|
||||
...coinCommon,
|
||||
name: `${curr}_u1`,
|
||||
value: `${curr}:1`,
|
||||
feeDeposit: `${curr}:0.02`,
|
||||
feeRefresh: `${curr}:0.02`,
|
||||
feeRefund: `${curr}:0.02`,
|
||||
feeWithdraw: `${curr}:0.02`,
|
||||
});
|
||||
|
||||
export const coin_u2 = (curr: string): CoinConfig => ({
|
||||
...coinCommon,
|
||||
name: `${curr}_u2`,
|
||||
value: `${curr}:2`,
|
||||
feeDeposit: `${curr}:0.02`,
|
||||
feeRefresh: `${curr}:0.02`,
|
||||
feeRefund: `${curr}:0.02`,
|
||||
feeWithdraw: `${curr}:0.02`,
|
||||
});
|
||||
|
||||
export const coin_u4 = (curr: string): CoinConfig => ({
|
||||
...coinCommon,
|
||||
name: `${curr}_u4`,
|
||||
value: `${curr}:4`,
|
||||
feeDeposit: `${curr}:0.02`,
|
||||
feeRefresh: `${curr}:0.02`,
|
||||
feeRefund: `${curr}:0.02`,
|
||||
feeWithdraw: `${curr}:0.02`,
|
||||
});
|
||||
|
||||
export const coin_u8 = (curr: string): CoinConfig => ({
|
||||
...coinCommon,
|
||||
name: `${curr}_u8`,
|
||||
value: `${curr}:8`,
|
||||
feeDeposit: `${curr}:0.16`,
|
||||
feeRefresh: `${curr}:0.16`,
|
||||
feeRefund: `${curr}:0.16`,
|
||||
feeWithdraw: `${curr}:0.16`,
|
||||
});
|
||||
|
||||
const coin_u10 = (curr: string): CoinConfig => ({
|
||||
...coinCommon,
|
||||
name: `${curr}_u10`,
|
||||
value: `${curr}:10`,
|
||||
feeDeposit: `${curr}:0.2`,
|
||||
feeRefresh: `${curr}:0.2`,
|
||||
feeRefund: `${curr}:0.2`,
|
||||
feeWithdraw: `${curr}:0.2`,
|
||||
});
|
||||
|
||||
export class GlobalTestParams {
|
||||
testDir: string;
|
||||
}
|
||||
@ -832,16 +743,6 @@ const codecForWithdrawalOperationInfo = (): Codec<WithdrawalOperationInfo> =>
|
||||
.property("taler_withdraw_uri", codecForString())
|
||||
.build("WithdrawalOperationInfo");
|
||||
|
||||
export const defaultCoinConfig = [
|
||||
coin_ct1,
|
||||
coin_ct10,
|
||||
coin_u1,
|
||||
coin_u10,
|
||||
coin_u2,
|
||||
coin_u4,
|
||||
coin_u8,
|
||||
];
|
||||
|
||||
export interface ExchangeConfig {
|
||||
name: string;
|
||||
currency: string;
|
||||
@ -1003,6 +904,14 @@ export class ExchangeService implements ExchangeServiceInterface {
|
||||
config.write(this.configFilename);
|
||||
}
|
||||
|
||||
addCoinConfigList(ccs: CoinConfig[]) {
|
||||
const config = Configuration.load(this.configFilename);
|
||||
ccs.forEach((cc) =>
|
||||
setCoin(config, cc),
|
||||
);
|
||||
config.write(this.configFilename);
|
||||
}
|
||||
|
||||
get masterPub() {
|
||||
return encodeCrock(this.keyPair.eddsaPub);
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ import {
|
||||
MerchantService,
|
||||
setupDb,
|
||||
BankService,
|
||||
defaultCoinConfig,
|
||||
ExchangeBankAccount,
|
||||
MerchantServiceInterface,
|
||||
BankApi,
|
||||
@ -46,6 +45,7 @@ import {
|
||||
ContractTerms,
|
||||
} from "taler-wallet-core";
|
||||
import { FaultInjectedMerchantService } from "./faultInjection";
|
||||
import { defaultCoinConfig } from "./denomStructures";
|
||||
|
||||
export interface SimpleTestEnvironment {
|
||||
commonDb: DbInfo;
|
||||
|
@ -20,20 +20,17 @@
|
||||
import {
|
||||
runTest,
|
||||
GlobalTestState,
|
||||
MerchantPrivateApi,
|
||||
WalletCli,
|
||||
defaultCoinConfig,
|
||||
ExchangeService,
|
||||
setupDb,
|
||||
BankService,
|
||||
MerchantService,
|
||||
BankApi,
|
||||
BankUser,
|
||||
BankAccessApi,
|
||||
CreditDebitIndicator,
|
||||
} from "./harness";
|
||||
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers";
|
||||
import { createEddsaKeyPair, encodeCrock } from "taler-wallet-core";
|
||||
import { defaultCoinConfig } from "./denomStructures";
|
||||
|
||||
/**
|
||||
* Run test for basic, bank-integrated withdrawal.
|
||||
|
@ -25,11 +25,9 @@ import {
|
||||
BankService,
|
||||
ExchangeService,
|
||||
MerchantService,
|
||||
defaultCoinConfig,
|
||||
BankApi,
|
||||
BankAccessApi,
|
||||
} from "./harness";
|
||||
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers";
|
||||
import {
|
||||
PreparePayResultType,
|
||||
ExchangesListRespose,
|
||||
@ -40,6 +38,7 @@ import {
|
||||
FaultInjectedExchangeService,
|
||||
FaultInjectionResponseContext,
|
||||
} from "./faultInjection";
|
||||
import { defaultCoinConfig } from "./denomStructures";
|
||||
|
||||
/**
|
||||
* Test if the wallet handles outdated exchange versions correct.y
|
||||
|
@ -29,7 +29,6 @@ import {
|
||||
setupDb,
|
||||
BankService,
|
||||
WalletCli,
|
||||
defaultCoinConfig,
|
||||
MerchantPrivateApi,
|
||||
BankApi,
|
||||
BankAccessApi,
|
||||
@ -40,6 +39,7 @@ import {
|
||||
FaultInjectionResponseContext,
|
||||
} from "./faultInjection";
|
||||
import { CoreApiResponse } from "taler-wallet-core";
|
||||
import { defaultCoinConfig } from "./denomStructures";
|
||||
|
||||
/**
|
||||
* Run test for basic, bank-integrated withdrawal.
|
||||
|
@ -25,11 +25,11 @@ import {
|
||||
ExchangeService,
|
||||
MerchantService,
|
||||
WalletCli,
|
||||
coin_ct10,
|
||||
coin_u1,
|
||||
|
||||
MerchantPrivateApi,
|
||||
} from "./harness";
|
||||
import { withdrawViaBank } from "./helpers";
|
||||
import { coin_ct10, coin_u1 } from "./denomStructures";
|
||||
|
||||
async function setupTest(
|
||||
t: GlobalTestState,
|
||||
|
@ -24,6 +24,8 @@ import {
|
||||
ExchangeService,
|
||||
MerchantService,
|
||||
WalletCli,
|
||||
setupDb,
|
||||
BankService,
|
||||
} from "./harness";
|
||||
import {
|
||||
createSimpleTestkudosEnvironment,
|
||||
@ -37,6 +39,7 @@ import {
|
||||
ConfirmPayResultType,
|
||||
} from "taler-wallet-core";
|
||||
import { PendingOperationsResponse } from "taler-wallet-core/lib/types/pending";
|
||||
import { defaultCoinConfig, makeNoFeeCoinConfig } from "./denomStructures";
|
||||
|
||||
async function applyTimeTravel(
|
||||
timetravelDuration: Duration,
|
||||
@ -71,12 +74,66 @@ async function applyTimeTravel(
|
||||
runTest(async (t: GlobalTestState) => {
|
||||
// Set up test environment
|
||||
|
||||
const {
|
||||
wallet,
|
||||
bank,
|
||||
exchange,
|
||||
merchant,
|
||||
} = await createSimpleTestkudosEnvironment(t);
|
||||
const db = await setupDb(t);
|
||||
|
||||
const bank = await BankService.create(t, {
|
||||
allowRegistrations: true,
|
||||
currency: "TESTKUDOS",
|
||||
database: db.connStr,
|
||||
httpPort: 8082,
|
||||
});
|
||||
|
||||
const exchange = ExchangeService.create(t, {
|
||||
name: "testexchange-1",
|
||||
currency: "TESTKUDOS",
|
||||
httpPort: 8081,
|
||||
database: db.connStr,
|
||||
});
|
||||
|
||||
const merchant = await MerchantService.create(t, {
|
||||
name: "testmerchant-1",
|
||||
currency: "TESTKUDOS",
|
||||
httpPort: 8083,
|
||||
database: db.connStr,
|
||||
});
|
||||
|
||||
const exchangeBankAccount = await bank.createExchangeAccount(
|
||||
"MyExchange",
|
||||
"x",
|
||||
);
|
||||
exchange.addBankAccount("1", exchangeBankAccount);
|
||||
|
||||
bank.setSuggestedExchange(exchange, exchangeBankAccount.accountPaytoUri);
|
||||
|
||||
await bank.start();
|
||||
|
||||
await bank.pingUntilAvailable();
|
||||
|
||||
exchange.addCoinConfigList(makeNoFeeCoinConfig("TESTKUDOS"));
|
||||
|
||||
await exchange.start();
|
||||
await exchange.pingUntilAvailable();
|
||||
|
||||
merchant.addExchange(exchange);
|
||||
|
||||
await merchant.start();
|
||||
await merchant.pingUntilAvailable();
|
||||
|
||||
await merchant.addInstance({
|
||||
id: "minst1",
|
||||
name: "minst1",
|
||||
paytoUris: ["payto://x-taler-bank/minst1"],
|
||||
});
|
||||
|
||||
await merchant.addInstance({
|
||||
id: "default",
|
||||
name: "Default Instance",
|
||||
paytoUris: [`payto://x-taler-bank/merchant-default`],
|
||||
});
|
||||
|
||||
console.log("setup done!");
|
||||
|
||||
const wallet = new WalletCli(t);
|
||||
|
||||
// Withdraw digital cash into the wallet.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user