harness,wallet-cli: allow in-memory DB
This commit is contained in:
parent
96101238af
commit
9d6613619e
@ -1906,33 +1906,42 @@ function tryUnixConnect(socketPath: string): Promise<void> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface WalletServiceOptions {
|
||||||
|
useInMemoryDb?: boolean;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
export class WalletService {
|
export class WalletService {
|
||||||
walletProc: ProcessWrapper | undefined;
|
walletProc: ProcessWrapper | undefined;
|
||||||
|
|
||||||
constructor(private globalState: GlobalTestState, private name: string) {}
|
constructor(
|
||||||
|
private globalState: GlobalTestState,
|
||||||
|
private opts: WalletServiceOptions,
|
||||||
|
) {}
|
||||||
|
|
||||||
get socketPath() {
|
get socketPath() {
|
||||||
const unixPath = path.join(this.globalState.testDir, `${this.name}.sock`);
|
const unixPath = path.join(
|
||||||
|
this.globalState.testDir,
|
||||||
|
`${this.opts.name}.sock`,
|
||||||
|
);
|
||||||
return unixPath;
|
return unixPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
async start(): Promise<void> {
|
async start(): Promise<void> {
|
||||||
const dbPath = path.join(
|
let dbPath: string;
|
||||||
|
if (this.opts.useInMemoryDb) {
|
||||||
|
dbPath = ":memory:";
|
||||||
|
} else {
|
||||||
|
dbPath = path.join(
|
||||||
this.globalState.testDir,
|
this.globalState.testDir,
|
||||||
`walletdb-${this.name}.json`,
|
`walletdb-${this.opts.name}.json`,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
const unixPath = this.socketPath;
|
const unixPath = this.socketPath;
|
||||||
this.globalState.spawnService(
|
this.globalState.spawnService(
|
||||||
"taler-wallet-cli",
|
"taler-wallet-cli",
|
||||||
[
|
["--wallet-db", dbPath, "advanced", "serve", "--unix-path", unixPath],
|
||||||
"--wallet-db",
|
`wallet-${this.opts.name}`,
|
||||||
dbPath,
|
|
||||||
"advanced",
|
|
||||||
"serve",
|
|
||||||
"--unix-path",
|
|
||||||
unixPath,
|
|
||||||
],
|
|
||||||
`wallet-${this.name}`,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,10 @@ export async function runWalletNotificationsTest(t: GlobalTestState) {
|
|||||||
|
|
||||||
console.log("setup done!");
|
console.log("setup done!");
|
||||||
|
|
||||||
const walletService = new WalletService(t, "wallet");
|
const walletService = new WalletService(t, {
|
||||||
|
name: "wallet",
|
||||||
|
useInMemoryDb: true,
|
||||||
|
});
|
||||||
await walletService.start();
|
await walletService.start();
|
||||||
await walletService.pingUntilAvailable();
|
await walletService.pingUntilAvailable();
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ async function createLocalWallet(
|
|||||||
myHttpLib.setThrottling(false);
|
myHttpLib.setThrottling(false);
|
||||||
}
|
}
|
||||||
const wallet = await getDefaultNodeWallet({
|
const wallet = await getDefaultNodeWallet({
|
||||||
persistentStoragePath: dbPath,
|
persistentStoragePath: dbPath !== ":memory:" ? dbPath : undefined,
|
||||||
httpLib: myHttpLib,
|
httpLib: myHttpLib,
|
||||||
notifyHandler: (n) => {
|
notifyHandler: (n) => {
|
||||||
logger.info(`wallet notification: ${j2s(n)}`);
|
logger.info(`wallet notification: ${j2s(n)}`);
|
||||||
|
Loading…
Reference in New Issue
Block a user