libeufin tutorial test: check sandbox step

This commit is contained in:
MS 2021-02-03 14:34:31 +01:00
parent d8c4b2734e
commit a3b84dca53
No known key found for this signature in database
GPG Key ID: 8D526861953F4C0F
3 changed files with 39 additions and 4 deletions

View File

@ -136,6 +136,7 @@ export async function sh(
t: GlobalTestState, t: GlobalTestState,
logName: string, logName: string,
command: string, command: string,
env: { [index: string]: string | undefined } = process.env,
): Promise<string> { ): Promise<string> {
console.log("runing command", command); console.log("runing command", command);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -143,6 +144,7 @@ export async function sh(
const proc = spawn(command, { const proc = spawn(command, {
stdio: ["inherit", "pipe", "pipe"], stdio: ["inherit", "pipe", "pipe"],
shell: true, shell: true,
env: env,
}); });
proc.stdout.on("data", (x) => { proc.stdout.on("data", (x) => {
if (x instanceof Buffer) { if (x instanceof Buffer) {

View File

@ -25,6 +25,7 @@ import {
ProcessWrapper, ProcessWrapper,
runCommand, runCommand,
extendEnv, extendEnv,
sh,
} from "./harness"; } from "./harness";
export interface LibeufinSandboxServiceInterface { export interface LibeufinSandboxServiceInterface {
@ -45,6 +46,13 @@ export interface LibeufinNexusConfig {
databaseJdbcUri: string; databaseJdbcUri: string;
} }
export interface LibeufinCliDetails {
nexusUrl: string;
sandboxUrl: string;
nexusDatabaseUri: string;
sandboxDatabaseUri: string;
}
export class LibeufinSandboxService implements LibeufinSandboxServiceInterface { export class LibeufinSandboxService implements LibeufinSandboxServiceInterface {
static async create( static async create(
gc: GlobalTestState, gc: GlobalTestState,
@ -171,6 +179,25 @@ export interface SimulateIncomingTransactionRequest {
currency: string; currency: string;
} }
export class LibeufinCli {
cliDetails: LibeufinCliDetails;
globalTestState: GlobalTestState;
constructor(gc: GlobalTestState, cd: LibeufinCliDetails) {
this.globalTestState = gc;
this.cliDetails = cd;
}
async checkSandbox(): Promise<void> {
await sh(
this.globalTestState,
"libeufin-cli-checksandbox",
"libeufin-cli sandbox check",
extendEnv({ LIBEUFIN_SANDBOX_URL: this.cliDetails.sandboxUrl }),
);
}
}
export namespace LibeufinSandboxApi { export namespace LibeufinSandboxApi {
export async function createEbicsHost( export async function createEbicsHost(
libeufinSandboxService: LibeufinSandboxServiceInterface, libeufinSandboxService: LibeufinSandboxServiceInterface,

View File

@ -19,17 +19,15 @@
*/ */
import { CoreApiResponse } from "@gnu-taler/taler-wallet-core"; import { CoreApiResponse } from "@gnu-taler/taler-wallet-core";
import { CoinConfig, defaultCoinConfig } from "./denomStructures"; import { CoinConfig, defaultCoinConfig } from "./denomStructures";
import { import { GlobalTestState } from "./harness";
GlobalTestState,
} from "./harness";
import { import {
LibeufinNexusApi, LibeufinNexusApi,
LibeufinNexusService, LibeufinNexusService,
LibeufinSandboxApi, LibeufinSandboxApi,
LibeufinSandboxService, LibeufinSandboxService,
LibeufinCli,
} from "./libeufin"; } from "./libeufin";
/** /**
* Run basic test with LibEuFin. * Run basic test with LibEuFin.
*/ */
@ -52,4 +50,12 @@ export async function runLibeufinTutorialTest(t: GlobalTestState) {
await libeufinNexus.start(); await libeufinNexus.start();
await libeufinNexus.pingUntilAvailable(); await libeufinNexus.pingUntilAvailable();
const libeufinCli = new LibeufinCli(t, {
sandboxUrl: libeufinSandbox.baseUrl,
nexusUrl: libeufinNexus.baseUrl,
sandboxDatabaseUri: `jdbc:sqlite:${t.testDir}/libeufin-sandbox.sqlite3`,
nexusDatabaseUri: `jdbc:sqlite:${t.testDir}/libeufin-nexus.sqlite3`,
});
await libeufinCli.checkSandbox();
} }