get basic test cases to work with new exchange

This commit is contained in:
Florian Dold 2021-01-05 17:59:50 +01:00
parent 981ef46267
commit c032931f22
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
4 changed files with 109 additions and 31 deletions

View File

@ -414,6 +414,7 @@ export interface BankConfig {
function setPaths(config: Configuration, home: string) { function setPaths(config: Configuration, home: string) {
config.setString("paths", "taler_home", home); config.setString("paths", "taler_home", home);
config.setString("paths", "taler_runtime_dir", "$TALER_HOME/taler-runtime/");
config.setString( config.setString(
"paths", "paths",
"taler_data_home", "taler_data_home",
@ -851,7 +852,7 @@ export class ExchangeService implements ExchangeServiceInterface {
config.setString("exchange", "max_keys_caching", "forever"); config.setString("exchange", "max_keys_caching", "forever");
config.setString("exchange", "db", "postgres"); config.setString("exchange", "db", "postgres");
config.setString( config.setString(
"exchange", "exchange-offline",
"master_priv_file", "master_priv_file",
"${TALER_DATA_HOME}/exchange/offline-keys/master.priv", "${TALER_DATA_HOME}/exchange/offline-keys/master.priv",
); );
@ -862,19 +863,6 @@ export class ExchangeService implements ExchangeServiceInterface {
config.setString("exchange", "lookahead_sign", "32 weeks 1 day"); config.setString("exchange", "lookahead_sign", "32 weeks 1 day");
config.setString("exchange", "lookahead_provide", "4 weeks 1 day"); config.setString("exchange", "lookahead_provide", "4 weeks 1 day");
for (let i = 2020; i < 2029; i++) {
config.setString(
"fees-x-taler-bank",
`wire-fee-${i}`,
`${e.currency}:0.01`,
);
config.setString(
"fees-x-taler-bank",
`closing-fee-${i}`,
`${e.currency}:0.01`,
);
}
config.setString("exchangedb-postgres", "config", e.database); config.setString("exchangedb-postgres", "config", e.database);
const exchangeMasterKey = createEddsaKeyPair(); const exchangeMasterKey = createEddsaKeyPair();
@ -886,7 +874,7 @@ export class ExchangeService implements ExchangeServiceInterface {
); );
const masterPrivFile = config const masterPrivFile = config
.getPath("exchange", "master_priv_file") .getPath("exchange-offline", "master_priv_file")
.required(); .required();
fs.mkdirSync(path.dirname(masterPrivFile), { recursive: true }); fs.mkdirSync(path.dirname(masterPrivFile), { recursive: true });
@ -963,6 +951,9 @@ export class ExchangeService implements ExchangeServiceInterface {
exchangeHttpProc: ProcessWrapper | undefined; exchangeHttpProc: ProcessWrapper | undefined;
exchangeWirewatchProc: ProcessWrapper | undefined; exchangeWirewatchProc: ProcessWrapper | undefined;
helperCryptoRsaProc: ProcessWrapper | undefined;
helperCryptoEddsaProc: ProcessWrapper | undefined;
constructor( constructor(
private globalState: GlobalTestState, private globalState: GlobalTestState,
private exchangeConfig: ExchangeConfig, private exchangeConfig: ExchangeConfig,
@ -995,14 +986,85 @@ export class ExchangeService implements ExchangeServiceInterface {
await httpd.wait(); await httpd.wait();
this.exchangeHttpProc = undefined; this.exchangeHttpProc = undefined;
} }
const cryptoRsa = this.helperCryptoRsaProc;
if (cryptoRsa) {
cryptoRsa.proc.kill("SIGTERM");
await cryptoRsa.wait();
this.helperCryptoRsaProc = undefined;
}
const cryptoEddsa = this.helperCryptoEddsaProc;
if (cryptoEddsa) {
cryptoEddsa.proc.kill("SIGTERM");
await cryptoEddsa.wait();
this.helperCryptoRsaProc = undefined;
}
} }
/**
* Update keys signing the keys generated by the security module
* with the offline signing key.
*/
async keyup(): Promise<void> { async keyup(): Promise<void> {
await sh( await runCommand(
this.globalState, this.globalState,
"exchange-keyup", "exchange-offline",
`taler-exchange-keyup ${this.timetravelArg} -c "${this.configFilename}"`, "taler-exchange-offline",
[
"-c",
this.configFilename,
...this.timetravelArgArr,
"download",
"sign",
"upload",
],
); );
const accounts: string[] = [];
const config = Configuration.load(this.configFilename);
for (const sectionName of config.getSectionNames()) {
if (sectionName.startsWith("exchange-account")) {
accounts.push(config.getString(sectionName, "payto_uri").required());
}
}
console.log("configuring bank accounts", accounts);
for (const acc of accounts) {
await runCommand(
this.globalState,
"exchange-offline",
"taler-exchange-offline",
[
"-c",
this.configFilename,
...this.timetravelArgArr,
"enable-account",
acc,
"upload",
],
);
}
const year = new Date().getFullYear();
for (let i = year; i < year+5; i++) {
await runCommand(
this.globalState,
"exchange-offline",
"taler-exchange-offline",
[
"-c",
this.configFilename,
...this.timetravelArgArr,
"wire-fee",
`${i}`,
"x-taler-bank",
`${this.exchangeConfig.currency}:0.01`,
`${this.exchangeConfig.currency}:0.01`,
"upload",
],
);
}
} }
async revokeDenomination(denomPubHash: string) { async revokeDenomination(denomPubHash: string) {
@ -1032,11 +1094,17 @@ export class ExchangeService implements ExchangeServiceInterface {
"exchange-dbinit", "exchange-dbinit",
`taler-exchange-dbinit -c "${this.configFilename}"`, `taler-exchange-dbinit -c "${this.configFilename}"`,
); );
await this.keyup();
await sh( this.helperCryptoEddsaProc = this.globalState.spawnService(
this.globalState, "taler-helper-crypto-eddsa",
"exchange-wire", ["-c", this.configFilename, ...this.timetravelArgArr],
`taler-exchange-wire ${this.timetravelArg} -c "${this.configFilename}"`, `exchange-crypto-eddsa-${this.name}`,
);
this.helperCryptoRsaProc = this.globalState.spawnService(
"taler-helper-crypto-rsa",
["-c", this.configFilename, ...this.timetravelArgArr],
`exchange-crypto-rsa-${this.name}`,
); );
this.exchangeWirewatchProc = this.globalState.spawnService( this.exchangeWirewatchProc = this.globalState.spawnService(
@ -1056,6 +1124,8 @@ export class ExchangeService implements ExchangeServiceInterface {
], ],
`exchange-httpd-${this.name}`, `exchange-httpd-${this.name}`,
); );
await this.keyup();
} }
async pingUntilAvailable(): Promise<void> { async pingUntilAvailable(): Promise<void> {

View File

@ -19,7 +19,7 @@
* *
* Uses libtool's current:revision:age versioning. * Uses libtool's current:revision:age versioning.
*/ */
export const WALLET_EXCHANGE_PROTOCOL_VERSION = "8:0:0"; export const WALLET_EXCHANGE_PROTOCOL_VERSION = "9:0:0";
/** /**
* Protocol version spoken with the merchant. * Protocol version spoken with the merchant.

View File

@ -1508,12 +1508,12 @@ class PurchasesStore extends Store<"purchases", PurchaseRecord> {
"fulfillmentUrlIndex", "fulfillmentUrlIndex",
string, string,
PurchaseRecord PurchaseRecord
>(this, "fulfillmentUrlIndex", "contractData.fulfillmentUrl"); >(this, "fulfillmentUrlIndex", "download.contractData.fulfillmentUrl");
orderIdIndex = new Index<"purchases", "orderIdIndex", string, PurchaseRecord>( orderIdIndex = new Index<"purchases", "orderIdIndex", string, PurchaseRecord>(
this, this,
"orderIdIndex", "orderIdIndex",
["contractData.merchantBaseUrl", "contractData.orderId"], ["download.contractData.merchantBaseUrl", "download.contractData.orderId"],
); );
} }
@ -1602,11 +1602,12 @@ class PlanchetsStore extends Store<"planchets", PlanchetRecord> {
PlanchetRecord PlanchetRecord
>(this, "withdrawalGroupIndex", "withdrawalGroupId"); >(this, "withdrawalGroupIndex", "withdrawalGroupId");
coinEvHashIndex = new Index<"planchets", "coinEvHashIndex", string, PlanchetRecord>( coinEvHashIndex = new Index<
this, "planchets",
"coinEvHashIndex", "coinEvHashIndex",
"coinEvHash", string,
); PlanchetRecord
>(this, "coinEvHashIndex", "coinEvHash");
} }
/** /**

View File

@ -213,6 +213,13 @@ export class Configuration {
sec[option.toUpperCase()] = value; sec[option.toUpperCase()] = value;
} }
/**
* Get lower-cased section names.
*/
getSectionNames(): string[] {
return Object.keys(this.sectionMap).map((x) => x.toLowerCase());
}
getString(section: string, option: string): ConfigValue<string> { getString(section: string, option: string): ConfigValue<string> {
const secNorm = section.toUpperCase(); const secNorm = section.toUpperCase();
const optNorm = option.toUpperCase(); const optNorm = option.toUpperCase();