delay in test for debugging
This commit is contained in:
parent
a90565f263
commit
c30bcc5e7e
@ -27,7 +27,6 @@
|
|||||||
import * as util from "util";
|
import * as util from "util";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import * as os from "os";
|
|
||||||
import * as http from "http";
|
import * as http from "http";
|
||||||
import { deepStrictEqual } from "assert";
|
import { deepStrictEqual } from "assert";
|
||||||
import { ChildProcess, spawn } from "child_process";
|
import { ChildProcess, spawn } from "child_process";
|
||||||
@ -817,6 +816,12 @@ export class ExchangeService implements ExchangeServiceInterface {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
changeConfig(f: (config: Configuration) => void) {
|
||||||
|
const config = Configuration.load(this.configFilename);
|
||||||
|
f(config);
|
||||||
|
config.write(this.configFilename);
|
||||||
|
}
|
||||||
|
|
||||||
static create(gc: GlobalTestState, e: ExchangeConfig) {
|
static create(gc: GlobalTestState, e: ExchangeConfig) {
|
||||||
const config = new Configuration();
|
const config = new Configuration();
|
||||||
config.setString("taler", "currency", e.currency);
|
config.setString("taler", "currency", e.currency);
|
||||||
@ -846,10 +851,6 @@ export class ExchangeService implements ExchangeServiceInterface {
|
|||||||
);
|
);
|
||||||
config.setString("exchange", "serve", "tcp");
|
config.setString("exchange", "serve", "tcp");
|
||||||
config.setString("exchange", "port", `${e.httpPort}`);
|
config.setString("exchange", "port", `${e.httpPort}`);
|
||||||
config.setString("exchange", "signkey_duration", "4 weeks");
|
|
||||||
config.setString("exchange", "legal_duraction", "2 years");
|
|
||||||
config.setString("exchange", "lookahead_sign", "32 weeks 1 day");
|
|
||||||
config.setString("exchange", "lookahead_provide", "4 weeks 1 day");
|
|
||||||
|
|
||||||
config.setString("exchangedb-postgres", "config", e.database);
|
config.setString("exchangedb-postgres", "config", e.database);
|
||||||
|
|
||||||
|
@ -23,11 +23,14 @@ import {
|
|||||||
ExchangeService,
|
ExchangeService,
|
||||||
MerchantService,
|
MerchantService,
|
||||||
WalletCli,
|
WalletCli,
|
||||||
|
setupDb,
|
||||||
|
BankService,
|
||||||
|
delayMs,
|
||||||
} from "./harness";
|
} from "./harness";
|
||||||
import {
|
import {
|
||||||
createSimpleTestkudosEnvironment,
|
|
||||||
withdrawViaBank,
|
withdrawViaBank,
|
||||||
makeTestPayment,
|
makeTestPayment,
|
||||||
|
SimpleTestEnvironment,
|
||||||
} from "./helpers";
|
} from "./helpers";
|
||||||
|
|
||||||
async function revokeAllWalletCoins(req: {
|
async function revokeAllWalletCoins(req: {
|
||||||
@ -45,21 +48,58 @@ async function revokeAllWalletCoins(req: {
|
|||||||
for (const x of usedDenomHashes.values()) {
|
for (const x of usedDenomHashes.values()) {
|
||||||
await exchange.revokeDenomination(x);
|
await exchange.revokeDenomination(x);
|
||||||
}
|
}
|
||||||
await exchange.stop();
|
console.log("waiting 30 seconds after revocation");
|
||||||
await exchange.start();
|
await delayMs(30000);
|
||||||
await exchange.pingUntilAvailable();
|
|
||||||
await exchange.keyup();
|
await exchange.keyup();
|
||||||
await exchange.pingUntilAvailable();
|
console.log("waiting 30 seconds after keyup");
|
||||||
|
await delayMs(30000);
|
||||||
await merchant.stop();
|
await merchant.stop();
|
||||||
await merchant.start();
|
await merchant.start();
|
||||||
await merchant.pingUntilAvailable();
|
await merchant.pingUntilAvailable();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
async function createTestEnvironment(
|
||||||
* Basic time travel test.
|
t: GlobalTestState,
|
||||||
*/
|
): Promise<SimpleTestEnvironment> {
|
||||||
export async function runRevocationTest(t: GlobalTestState) {
|
const db = await setupDb(t);
|
||||||
// Set up test environment
|
|
||||||
|
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,
|
||||||
|
});
|
||||||
|
|
||||||
|
exchange.changeConfig((config) => {
|
||||||
|
config.setString("taler-helper-crypto-eddsa", "lookahead_sign", "20 s");
|
||||||
|
config.setString("taler-helper-crypto-rsa", "lookahead_sign", "20 s");
|
||||||
|
});
|
||||||
|
|
||||||
|
const exchangeBankAccount = await bank.createExchangeAccount(
|
||||||
|
"MyExchange",
|
||||||
|
"x",
|
||||||
|
);
|
||||||
|
exchange.addBankAccount("1", exchangeBankAccount);
|
||||||
|
|
||||||
|
bank.setSuggestedExchange(exchange, exchangeBankAccount.accountPaytoUri);
|
||||||
|
|
||||||
|
await bank.start();
|
||||||
|
|
||||||
|
await bank.pingUntilAvailable();
|
||||||
|
|
||||||
const coin_u1: CoinConfig = {
|
const coin_u1: CoinConfig = {
|
||||||
durationLegal: "3 years",
|
durationLegal: "3 years",
|
||||||
@ -74,17 +114,55 @@ export async function runRevocationTest(t: GlobalTestState) {
|
|||||||
feeWithdraw: `TESTKUDOS:0`,
|
feeWithdraw: `TESTKUDOS:0`,
|
||||||
};
|
};
|
||||||
|
|
||||||
const {
|
exchange.addCoinConfigList([coin_u1]);
|
||||||
wallet,
|
|
||||||
bank,
|
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);
|
||||||
|
|
||||||
|
return {
|
||||||
|
commonDb: db,
|
||||||
exchange,
|
exchange,
|
||||||
merchant,
|
merchant,
|
||||||
} = await createSimpleTestkudosEnvironment(t, [coin_u1]);
|
wallet,
|
||||||
|
bank,
|
||||||
|
exchangeBankAccount,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Basic time travel test.
|
||||||
|
*/
|
||||||
|
export async function runRevocationTest(t: GlobalTestState) {
|
||||||
|
// Set up test environment
|
||||||
|
|
||||||
|
const { wallet, bank, exchange, merchant } = await createTestEnvironment(t);
|
||||||
|
|
||||||
// Withdraw digital cash into the wallet.
|
// Withdraw digital cash into the wallet.
|
||||||
|
|
||||||
await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:15" });
|
await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:15" });
|
||||||
|
|
||||||
|
console.log("revoking first time");
|
||||||
await revokeAllWalletCoins({ wallet, exchange, merchant });
|
await revokeAllWalletCoins({ wallet, exchange, merchant });
|
||||||
|
|
||||||
// FIXME: this shouldn't be necessary once https://bugs.taler.net/n/6565
|
// FIXME: this shouldn't be necessary once https://bugs.taler.net/n/6565
|
||||||
@ -114,6 +192,7 @@ export async function runRevocationTest(t: GlobalTestState) {
|
|||||||
});
|
});
|
||||||
await wallet.runUntilDone();
|
await wallet.runUntilDone();
|
||||||
|
|
||||||
|
console.log("revoking second time");
|
||||||
await revokeAllWalletCoins({ wallet, exchange, merchant });
|
await revokeAllWalletCoins({ wallet, exchange, merchant });
|
||||||
|
|
||||||
// FIXME: this shouldn't be necessary once https://bugs.taler.net/n/6565
|
// FIXME: this shouldn't be necessary once https://bugs.taler.net/n/6565
|
||||||
|
Loading…
Reference in New Issue
Block a user