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(). */
|
/** Ensures mutations are allowed, reversing the effect of freeze(). */
|
||||||
unfreeze() {
|
unfreeze() {
|
||||||
|
// @ts-ignore
|
||||||
delete this.clear;
|
delete this.clear;
|
||||||
|
// @ts-ignore
|
||||||
delete this.set;
|
delete this.set;
|
||||||
|
// @ts-ignore
|
||||||
delete this.editRange;
|
delete this.editRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,6 +91,7 @@ import {
|
|||||||
} from "./merchantApiTypes";
|
} from "./merchantApiTypes";
|
||||||
import { ApplyRefundResponse } from "taler-wallet-core";
|
import { ApplyRefundResponse } from "taler-wallet-core";
|
||||||
import { PendingOperationsResponse } from "taler-wallet-core";
|
import { PendingOperationsResponse } from "taler-wallet-core";
|
||||||
|
import { CoinConfig } from "./denomStructures";
|
||||||
|
|
||||||
const exec = util.promisify(require("child_process").exec);
|
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 {
|
export class GlobalTestParams {
|
||||||
testDir: string;
|
testDir: string;
|
||||||
}
|
}
|
||||||
@ -832,16 +743,6 @@ const codecForWithdrawalOperationInfo = (): Codec<WithdrawalOperationInfo> =>
|
|||||||
.property("taler_withdraw_uri", codecForString())
|
.property("taler_withdraw_uri", codecForString())
|
||||||
.build("WithdrawalOperationInfo");
|
.build("WithdrawalOperationInfo");
|
||||||
|
|
||||||
export const defaultCoinConfig = [
|
|
||||||
coin_ct1,
|
|
||||||
coin_ct10,
|
|
||||||
coin_u1,
|
|
||||||
coin_u10,
|
|
||||||
coin_u2,
|
|
||||||
coin_u4,
|
|
||||||
coin_u8,
|
|
||||||
];
|
|
||||||
|
|
||||||
export interface ExchangeConfig {
|
export interface ExchangeConfig {
|
||||||
name: string;
|
name: string;
|
||||||
currency: string;
|
currency: string;
|
||||||
@ -1003,6 +904,14 @@ export class ExchangeService implements ExchangeServiceInterface {
|
|||||||
config.write(this.configFilename);
|
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() {
|
get masterPub() {
|
||||||
return encodeCrock(this.keyPair.eddsaPub);
|
return encodeCrock(this.keyPair.eddsaPub);
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,6 @@ import {
|
|||||||
MerchantService,
|
MerchantService,
|
||||||
setupDb,
|
setupDb,
|
||||||
BankService,
|
BankService,
|
||||||
defaultCoinConfig,
|
|
||||||
ExchangeBankAccount,
|
ExchangeBankAccount,
|
||||||
MerchantServiceInterface,
|
MerchantServiceInterface,
|
||||||
BankApi,
|
BankApi,
|
||||||
@ -46,6 +45,7 @@ import {
|
|||||||
ContractTerms,
|
ContractTerms,
|
||||||
} from "taler-wallet-core";
|
} from "taler-wallet-core";
|
||||||
import { FaultInjectedMerchantService } from "./faultInjection";
|
import { FaultInjectedMerchantService } from "./faultInjection";
|
||||||
|
import { defaultCoinConfig } from "./denomStructures";
|
||||||
|
|
||||||
export interface SimpleTestEnvironment {
|
export interface SimpleTestEnvironment {
|
||||||
commonDb: DbInfo;
|
commonDb: DbInfo;
|
||||||
|
@ -20,20 +20,17 @@
|
|||||||
import {
|
import {
|
||||||
runTest,
|
runTest,
|
||||||
GlobalTestState,
|
GlobalTestState,
|
||||||
MerchantPrivateApi,
|
|
||||||
WalletCli,
|
WalletCli,
|
||||||
defaultCoinConfig,
|
|
||||||
ExchangeService,
|
ExchangeService,
|
||||||
setupDb,
|
setupDb,
|
||||||
BankService,
|
BankService,
|
||||||
MerchantService,
|
MerchantService,
|
||||||
BankApi,
|
BankApi,
|
||||||
BankUser,
|
|
||||||
BankAccessApi,
|
BankAccessApi,
|
||||||
CreditDebitIndicator,
|
CreditDebitIndicator,
|
||||||
} from "./harness";
|
} from "./harness";
|
||||||
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers";
|
|
||||||
import { createEddsaKeyPair, encodeCrock } from "taler-wallet-core";
|
import { createEddsaKeyPair, encodeCrock } from "taler-wallet-core";
|
||||||
|
import { defaultCoinConfig } from "./denomStructures";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run test for basic, bank-integrated withdrawal.
|
* Run test for basic, bank-integrated withdrawal.
|
||||||
|
@ -25,11 +25,9 @@ import {
|
|||||||
BankService,
|
BankService,
|
||||||
ExchangeService,
|
ExchangeService,
|
||||||
MerchantService,
|
MerchantService,
|
||||||
defaultCoinConfig,
|
|
||||||
BankApi,
|
BankApi,
|
||||||
BankAccessApi,
|
BankAccessApi,
|
||||||
} from "./harness";
|
} from "./harness";
|
||||||
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers";
|
|
||||||
import {
|
import {
|
||||||
PreparePayResultType,
|
PreparePayResultType,
|
||||||
ExchangesListRespose,
|
ExchangesListRespose,
|
||||||
@ -40,6 +38,7 @@ import {
|
|||||||
FaultInjectedExchangeService,
|
FaultInjectedExchangeService,
|
||||||
FaultInjectionResponseContext,
|
FaultInjectionResponseContext,
|
||||||
} from "./faultInjection";
|
} from "./faultInjection";
|
||||||
|
import { defaultCoinConfig } from "./denomStructures";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test if the wallet handles outdated exchange versions correct.y
|
* Test if the wallet handles outdated exchange versions correct.y
|
||||||
|
@ -29,7 +29,6 @@ import {
|
|||||||
setupDb,
|
setupDb,
|
||||||
BankService,
|
BankService,
|
||||||
WalletCli,
|
WalletCli,
|
||||||
defaultCoinConfig,
|
|
||||||
MerchantPrivateApi,
|
MerchantPrivateApi,
|
||||||
BankApi,
|
BankApi,
|
||||||
BankAccessApi,
|
BankAccessApi,
|
||||||
@ -40,6 +39,7 @@ import {
|
|||||||
FaultInjectionResponseContext,
|
FaultInjectionResponseContext,
|
||||||
} from "./faultInjection";
|
} from "./faultInjection";
|
||||||
import { CoreApiResponse } from "taler-wallet-core";
|
import { CoreApiResponse } from "taler-wallet-core";
|
||||||
|
import { defaultCoinConfig } from "./denomStructures";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run test for basic, bank-integrated withdrawal.
|
* Run test for basic, bank-integrated withdrawal.
|
||||||
|
@ -25,11 +25,11 @@ import {
|
|||||||
ExchangeService,
|
ExchangeService,
|
||||||
MerchantService,
|
MerchantService,
|
||||||
WalletCli,
|
WalletCli,
|
||||||
coin_ct10,
|
|
||||||
coin_u1,
|
|
||||||
MerchantPrivateApi,
|
MerchantPrivateApi,
|
||||||
} from "./harness";
|
} from "./harness";
|
||||||
import { withdrawViaBank } from "./helpers";
|
import { withdrawViaBank } from "./helpers";
|
||||||
|
import { coin_ct10, coin_u1 } from "./denomStructures";
|
||||||
|
|
||||||
async function setupTest(
|
async function setupTest(
|
||||||
t: GlobalTestState,
|
t: GlobalTestState,
|
||||||
|
@ -24,6 +24,8 @@ import {
|
|||||||
ExchangeService,
|
ExchangeService,
|
||||||
MerchantService,
|
MerchantService,
|
||||||
WalletCli,
|
WalletCli,
|
||||||
|
setupDb,
|
||||||
|
BankService,
|
||||||
} from "./harness";
|
} from "./harness";
|
||||||
import {
|
import {
|
||||||
createSimpleTestkudosEnvironment,
|
createSimpleTestkudosEnvironment,
|
||||||
@ -37,6 +39,7 @@ import {
|
|||||||
ConfirmPayResultType,
|
ConfirmPayResultType,
|
||||||
} from "taler-wallet-core";
|
} from "taler-wallet-core";
|
||||||
import { PendingOperationsResponse } from "taler-wallet-core/lib/types/pending";
|
import { PendingOperationsResponse } from "taler-wallet-core/lib/types/pending";
|
||||||
|
import { defaultCoinConfig, makeNoFeeCoinConfig } from "./denomStructures";
|
||||||
|
|
||||||
async function applyTimeTravel(
|
async function applyTimeTravel(
|
||||||
timetravelDuration: Duration,
|
timetravelDuration: Duration,
|
||||||
@ -71,12 +74,66 @@ async function applyTimeTravel(
|
|||||||
runTest(async (t: GlobalTestState) => {
|
runTest(async (t: GlobalTestState) => {
|
||||||
// Set up test environment
|
// Set up test environment
|
||||||
|
|
||||||
const {
|
const db = await setupDb(t);
|
||||||
wallet,
|
|
||||||
bank,
|
const bank = await BankService.create(t, {
|
||||||
exchange,
|
allowRegistrations: true,
|
||||||
merchant,
|
currency: "TESTKUDOS",
|
||||||
} = await createSimpleTestkudosEnvironment(t);
|
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.
|
// Withdraw digital cash into the wallet.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user