spill extra functionality from wallet-cli into taler-harness
We want to keep taler-wallet-cli smaller and have fewer dependencies.
This commit is contained in:
parent
d98711cb51
commit
083c4cf5d9
@ -47,7 +47,7 @@
|
|||||||
"@types/chai": "^4.3.0",
|
"@types/chai": "^4.3.0",
|
||||||
"@types/history": "^4.7.8",
|
"@types/history": "^4.7.8",
|
||||||
"@types/mocha": "^10.0.1",
|
"@types/mocha": "^10.0.1",
|
||||||
"@types/node": "^18.11.14",
|
"@types/node": "^18.11.17",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.41.0",
|
"@typescript-eslint/eslint-plugin": "^5.41.0",
|
||||||
"@typescript-eslint/parser": "^5.41.0",
|
"@typescript-eslint/parser": "^5.41.0",
|
||||||
"async_hooks": "^1.0.0",
|
"async_hooks": "^1.0.0",
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^18.8.5",
|
"@types/node": "^18.11.17",
|
||||||
"ava": "^4.3.3",
|
"ava": "^4.3.3",
|
||||||
"esm": "^3.2.25",
|
"esm": "^3.2.25",
|
||||||
"prettier": "^2.5.1",
|
"prettier": "^2.5.1",
|
||||||
|
@ -425,6 +425,11 @@ export function structuredRevive(val: any): any {
|
|||||||
* Structured clone for IndexedDB.
|
* Structured clone for IndexedDB.
|
||||||
*/
|
*/
|
||||||
export function structuredClone(val: any): any {
|
export function structuredClone(val: any): any {
|
||||||
|
// @ts-ignore
|
||||||
|
if (globalThis._tart?.structuredClone) {
|
||||||
|
// @ts-ignore
|
||||||
|
return globalThis._tart?.structuredClone(val);
|
||||||
|
}
|
||||||
return mkDeepClone()(val);
|
return mkDeepClone()(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -432,5 +437,11 @@ export function structuredClone(val: any): any {
|
|||||||
* Structured clone for IndexedDB.
|
* Structured clone for IndexedDB.
|
||||||
*/
|
*/
|
||||||
export function checkStructuredCloneOrThrow(val: any): void {
|
export function checkStructuredCloneOrThrow(val: any): void {
|
||||||
return mkDeepCloneCheckOnly()(val);
|
// @ts-ignore
|
||||||
|
if (globalThis._tart?.structuredClone) {
|
||||||
|
// @ts-ignore
|
||||||
|
globalThis._tart?.structuredClone(val);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mkDeepCloneCheckOnly()(val);
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
"@types/history": "^4.7.8",
|
"@types/history": "^4.7.8",
|
||||||
"@types/jest": "^26.0.23",
|
"@types/jest": "^26.0.23",
|
||||||
"@types/mocha": "^8.2.3",
|
"@types/mocha": "^8.2.3",
|
||||||
"@types/node": "^18.8.5",
|
"@types/node": "^18.11.17",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.22.0",
|
"@typescript-eslint/eslint-plugin": "^4.22.0",
|
||||||
"@typescript-eslint/parser": "^4.22.0",
|
"@typescript-eslint/parser": "^4.22.0",
|
||||||
"base64-inline-loader": "^1.1.1",
|
"base64-inline-loader": "^1.1.1",
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
"typescript": "^4.8.4"
|
"typescript": "^4.8.4"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/node": "^18.8.5",
|
"@types/node": "^18.11.17",
|
||||||
"glob": "^7.2.0"
|
"glob": "^7.2.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
30
packages/taler-harness/Makefile
Normal file
30
packages/taler-harness/Makefile
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# This Makefile has been placed in the public domain.
|
||||||
|
|
||||||
|
-include ../../.config.mk
|
||||||
|
include .config.mk
|
||||||
|
|
||||||
|
$(info prefix is $(prefix))
|
||||||
|
|
||||||
|
all:
|
||||||
|
@echo use 'make install' to build and install taler-harness
|
||||||
|
|
||||||
|
ifndef prefix
|
||||||
|
.PHONY: warn-noprefix install
|
||||||
|
warn-noprefix:
|
||||||
|
@echo "no prefix configured, did you run ./configure?"
|
||||||
|
install: warn-noprefix
|
||||||
|
else
|
||||||
|
install_target = $(prefix)/lib/taler-harness
|
||||||
|
.PHONY: install install-nodeps
|
||||||
|
install:
|
||||||
|
pnpm install --frozen-lockfile --filter @gnu-taler/taler-harness...
|
||||||
|
install -d $(prefix)/bin
|
||||||
|
install -d $(install_target)/bin
|
||||||
|
install -d $(install_target)/node_modules/taler-harness
|
||||||
|
install -d $(install_target)/node_modules/taler-harness/bin
|
||||||
|
install -d $(install_target)/node_modules/taler-harness/dist
|
||||||
|
install ./dist/taler-harness-bundled.cjs $(install_target)/node_modules/taler-harness/dist/
|
||||||
|
install ./dist/taler-harness-bundled.cjs.map $(install_target)/node_modules/taler-harness/dist/
|
||||||
|
install ./bin/taler-harness.mjs $(install_target)/node_modules/taler-harness/bin/
|
||||||
|
ln -sf $(install_target)/node_modules/taler-harness/bin/taler-harness.mjs $(prefix)/bin/taler-harness
|
||||||
|
endif
|
19
packages/taler-harness/bin/taler-harness.mjs
Executable file
19
packages/taler-harness/bin/taler-harness.mjs
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
/*
|
||||||
|
This file is part of GNU Taler
|
||||||
|
(C) 2022 Taler Systems SA
|
||||||
|
|
||||||
|
TALER is free software; you can redistribute it and/or modify it under the
|
||||||
|
terms of the GNU General Public License as published by the Free Software
|
||||||
|
Foundation; either version 3, or (at your option) any later version.
|
||||||
|
|
||||||
|
TALER is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along with
|
||||||
|
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { main } from '../dist/taler-harness-bundled.cjs';
|
||||||
|
main();
|
70
packages/taler-harness/build.mjs
Executable file
70
packages/taler-harness/build.mjs
Executable file
@ -0,0 +1,70 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
/*
|
||||||
|
This file is part of GNU Taler
|
||||||
|
(C) 2022 Taler Systems S.A.
|
||||||
|
|
||||||
|
GNU Taler is free software; you can redistribute it and/or modify it under the
|
||||||
|
terms of the GNU General Public License as published by the Free Software
|
||||||
|
Foundation; either version 3, or (at your option) any later version.
|
||||||
|
|
||||||
|
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along with
|
||||||
|
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
|
||||||
|
import esbuild from 'esbuild'
|
||||||
|
import path from "path"
|
||||||
|
import fs from "fs"
|
||||||
|
|
||||||
|
const BASE = process.cwd()
|
||||||
|
|
||||||
|
let GIT_ROOT = BASE
|
||||||
|
while (!fs.existsSync(path.join(GIT_ROOT, '.git')) && GIT_ROOT !== '/') {
|
||||||
|
GIT_ROOT = path.join(GIT_ROOT, '../')
|
||||||
|
}
|
||||||
|
if (GIT_ROOT === '/') {
|
||||||
|
console.log("not found")
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
const GIT_HASH = GIT_ROOT === '/' ? undefined : git_hash()
|
||||||
|
|
||||||
|
|
||||||
|
let _package = JSON.parse(fs.readFileSync(path.join(BASE, 'package.json')));
|
||||||
|
|
||||||
|
function git_hash() {
|
||||||
|
const rev = fs.readFileSync(path.join(GIT_ROOT, '.git', 'HEAD')).toString().trim().split(/.*[: ]/).slice(-1)[0];
|
||||||
|
if (rev.indexOf('/') === -1) {
|
||||||
|
return rev;
|
||||||
|
} else {
|
||||||
|
return fs.readFileSync(path.join(GIT_ROOT, '.git', rev)).toString().trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Still commonjs, because axios doesn't work properly under mjs
|
||||||
|
export const buildConfig = {
|
||||||
|
entryPoints: ["src/index.ts"],
|
||||||
|
outfile: "dist/taler-harness-bundled.cjs",
|
||||||
|
bundle: true,
|
||||||
|
minify: false,
|
||||||
|
target: [
|
||||||
|
'es2020'
|
||||||
|
],
|
||||||
|
format: 'cjs',
|
||||||
|
platform: 'node',
|
||||||
|
sourcemap: true,
|
||||||
|
define: {
|
||||||
|
'__VERSION__': `"${_package.version}"`,
|
||||||
|
'__GIT_HASH__': `"${GIT_HASH}"`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
esbuild
|
||||||
|
.build(buildConfig)
|
||||||
|
.catch((e) => {
|
||||||
|
console.log(e)
|
||||||
|
process.exit(1)
|
||||||
|
});
|
||||||
|
|
44
packages/taler-harness/package.json
Normal file
44
packages/taler-harness/package.json
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
{
|
||||||
|
"name": "@gnu-taler/taler-harness",
|
||||||
|
"version": "0.9.0-dev.2",
|
||||||
|
"description": "",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.12.0"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git://git.taler.net/wallet-core.git"
|
||||||
|
},
|
||||||
|
"author": "Florian Dold",
|
||||||
|
"license": "GPL-3.0",
|
||||||
|
"bin": {
|
||||||
|
"taler-harness": "./bin/taler-harness.mjs"
|
||||||
|
},
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"compile": "./build.mjs",
|
||||||
|
"check": "tsc",
|
||||||
|
"clean": "rimraf lib dist tsconfig.tsbuildinfo",
|
||||||
|
"pretty": "prettier --write src"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"AUTHORS",
|
||||||
|
"README",
|
||||||
|
"COPYING",
|
||||||
|
"bin/",
|
||||||
|
"dist/node",
|
||||||
|
"src/"
|
||||||
|
],
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "^18.11.17",
|
||||||
|
"prettier": "^2.5.1",
|
||||||
|
"rimraf": "^3.0.2",
|
||||||
|
"typescript": "^4.8.4"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@gnu-taler/taler-util": "workspace:*",
|
||||||
|
"@gnu-taler/taler-wallet-core": "workspace:*",
|
||||||
|
"axios": "^0.27.2",
|
||||||
|
"tslib": "^2.4.0"
|
||||||
|
}
|
||||||
|
}
|
338
packages/taler-harness/src/index.ts
Normal file
338
packages/taler-harness/src/index.ts
Normal file
@ -0,0 +1,338 @@
|
|||||||
|
/*
|
||||||
|
This file is part of GNU Taler
|
||||||
|
(C) 2019 Taler Systems S.A.
|
||||||
|
|
||||||
|
GNU Taler is free software; you can redistribute it and/or modify it under the
|
||||||
|
terms of the GNU General Public License as published by the Free Software
|
||||||
|
Foundation; either version 3, or (at your option) any later version.
|
||||||
|
|
||||||
|
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along with
|
||||||
|
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Imports.
|
||||||
|
*/
|
||||||
|
import { deepStrictEqual } from "assert";
|
||||||
|
import fs from "fs";
|
||||||
|
import os from "os";
|
||||||
|
import path from "path";
|
||||||
|
import {
|
||||||
|
Amounts,
|
||||||
|
clk,
|
||||||
|
Configuration,
|
||||||
|
decodeCrock,
|
||||||
|
Logger,
|
||||||
|
rsaBlind,
|
||||||
|
setGlobalLogLevelFromString,
|
||||||
|
} from "@gnu-taler/taler-util";
|
||||||
|
import { runBench1 } from "./bench1.js";
|
||||||
|
import { runBench2 } from "./bench2.js";
|
||||||
|
import { runBench3 } from "./bench3.js";
|
||||||
|
import { runEnv1 } from "./env1.js";
|
||||||
|
import { GlobalTestState, runTestWithState } from "./harness/harness.js";
|
||||||
|
import { getTestInfo, runTests } from "./integrationtests/testrunner.js";
|
||||||
|
import { lintExchangeDeployment } from "./lint.js";
|
||||||
|
import { runEnvFull } from "./env-full.js";
|
||||||
|
|
||||||
|
const logger = new Logger("taler-harness:index.ts");
|
||||||
|
|
||||||
|
process.on("unhandledRejection", (error: any) => {
|
||||||
|
logger.error("unhandledRejection", error.message);
|
||||||
|
logger.error("stack", error.stack);
|
||||||
|
process.exit(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
declare const __VERSION__: string;
|
||||||
|
function printVersion(): void {
|
||||||
|
console.log(__VERSION__);
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
export const testingCli = clk
|
||||||
|
.program("testing", {
|
||||||
|
help: "Command line interface for the GNU Taler test/deployment harness.",
|
||||||
|
})
|
||||||
|
.maybeOption("log", ["-L", "--log"], clk.STRING, {
|
||||||
|
help: "configure log level (NONE, ..., TRACE)",
|
||||||
|
onPresentHandler: (x) => {
|
||||||
|
setGlobalLogLevelFromString(x);
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.flag("version", ["-v", "--version"], {
|
||||||
|
onPresentHandler: printVersion,
|
||||||
|
})
|
||||||
|
.flag("verbose", ["-V", "--verbose"], {
|
||||||
|
help: "Enable verbose output.",
|
||||||
|
});
|
||||||
|
|
||||||
|
const advancedCli = testingCli.subcommand("advancedArgs", "advanced", {
|
||||||
|
help: "Subcommands for advanced operations (only use if you know what you're doing!).",
|
||||||
|
});
|
||||||
|
|
||||||
|
advancedCli
|
||||||
|
.subcommand("bench1", "bench1", {
|
||||||
|
help: "Run the 'bench1' benchmark",
|
||||||
|
})
|
||||||
|
.requiredOption("configJson", ["--config-json"], clk.STRING)
|
||||||
|
.action(async (args) => {
|
||||||
|
let config: any;
|
||||||
|
try {
|
||||||
|
config = JSON.parse(args.bench1.configJson);
|
||||||
|
} catch (e) {
|
||||||
|
console.log("Could not parse config JSON");
|
||||||
|
}
|
||||||
|
await runBench1(config);
|
||||||
|
});
|
||||||
|
|
||||||
|
advancedCli
|
||||||
|
.subcommand("bench2", "bench2", {
|
||||||
|
help: "Run the 'bench2' benchmark",
|
||||||
|
})
|
||||||
|
.requiredOption("configJson", ["--config-json"], clk.STRING)
|
||||||
|
.action(async (args) => {
|
||||||
|
let config: any;
|
||||||
|
try {
|
||||||
|
config = JSON.parse(args.bench2.configJson);
|
||||||
|
} catch (e) {
|
||||||
|
console.log("Could not parse config JSON");
|
||||||
|
}
|
||||||
|
await runBench2(config);
|
||||||
|
});
|
||||||
|
|
||||||
|
advancedCli
|
||||||
|
.subcommand("bench3", "bench3", {
|
||||||
|
help: "Run the 'bench3' benchmark",
|
||||||
|
})
|
||||||
|
.requiredOption("configJson", ["--config-json"], clk.STRING)
|
||||||
|
.action(async (args) => {
|
||||||
|
let config: any;
|
||||||
|
try {
|
||||||
|
config = JSON.parse(args.bench3.configJson);
|
||||||
|
} catch (e) {
|
||||||
|
console.log("Could not parse config JSON");
|
||||||
|
}
|
||||||
|
await runBench3(config);
|
||||||
|
});
|
||||||
|
|
||||||
|
advancedCli
|
||||||
|
.subcommand("envFull", "env-full", {
|
||||||
|
help: "Run a test environment for bench1",
|
||||||
|
})
|
||||||
|
.action(async (args) => {
|
||||||
|
const testDir = fs.mkdtempSync(path.join(os.tmpdir(), "taler-env-full-"));
|
||||||
|
const testState = new GlobalTestState({
|
||||||
|
testDir,
|
||||||
|
});
|
||||||
|
await runTestWithState(testState, runEnvFull, "env-full", true);
|
||||||
|
});
|
||||||
|
|
||||||
|
advancedCli
|
||||||
|
.subcommand("env1", "env1", {
|
||||||
|
help: "Run a test environment for bench1",
|
||||||
|
})
|
||||||
|
.action(async (args) => {
|
||||||
|
const testDir = fs.mkdtempSync(path.join(os.tmpdir(), "taler-env1-"));
|
||||||
|
const testState = new GlobalTestState({
|
||||||
|
testDir,
|
||||||
|
});
|
||||||
|
await runTestWithState(testState, runEnv1, "env1", true);
|
||||||
|
});
|
||||||
|
|
||||||
|
const deploymentCli = testingCli.subcommand("deploymentArgs", "deployment", {
|
||||||
|
help: "Subcommands for handling GNU Taler deployments.",
|
||||||
|
});
|
||||||
|
|
||||||
|
deploymentCli
|
||||||
|
.subcommand("lintExchange", "lint-exchange", {
|
||||||
|
help: "Run checks on the exchange deployment.",
|
||||||
|
})
|
||||||
|
.flag("cont", ["--continue"], {
|
||||||
|
help: "Continue after errors if possible",
|
||||||
|
})
|
||||||
|
.flag("debug", ["--debug"], {
|
||||||
|
help: "Output extra debug info",
|
||||||
|
})
|
||||||
|
.action(async (args) => {
|
||||||
|
await lintExchangeDeployment(
|
||||||
|
args.lintExchange.debug,
|
||||||
|
args.lintExchange.cont,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
deploymentCli
|
||||||
|
.subcommand("coincfg", "gen-coin-config", {
|
||||||
|
help: "Generate a coin/denomination configuration for the exchange.",
|
||||||
|
})
|
||||||
|
.requiredOption("minAmount", ["--min-amount"], clk.STRING, {
|
||||||
|
help: "Smallest denomination",
|
||||||
|
})
|
||||||
|
.requiredOption("maxAmount", ["--max-amount"], clk.STRING, {
|
||||||
|
help: "Largest denomination",
|
||||||
|
})
|
||||||
|
.action(async (args) => {
|
||||||
|
let out = "";
|
||||||
|
|
||||||
|
const stamp = Math.floor(new Date().getTime() / 1000);
|
||||||
|
|
||||||
|
const min = Amounts.parseOrThrow(args.coincfg.minAmount);
|
||||||
|
const max = Amounts.parseOrThrow(args.coincfg.maxAmount);
|
||||||
|
if (min.currency != max.currency) {
|
||||||
|
console.error("currency mismatch");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
const currency = min.currency;
|
||||||
|
let x = min;
|
||||||
|
let n = 1;
|
||||||
|
|
||||||
|
out += "# Coin configuration for the exchange.\n";
|
||||||
|
out += '# Should be placed in "/etc/taler/conf.d/exchange-coins.conf".\n';
|
||||||
|
out += "\n";
|
||||||
|
|
||||||
|
while (Amounts.cmp(x, max) < 0) {
|
||||||
|
out += `[COIN-${currency}-n${n}-t${stamp}]\n`;
|
||||||
|
out += `VALUE = ${Amounts.stringify(x)}\n`;
|
||||||
|
out += `DURATION_WITHDRAW = 7 days\n`;
|
||||||
|
out += `DURATION_SPEND = 2 years\n`;
|
||||||
|
out += `DURATION_LEGAL = 6 years\n`;
|
||||||
|
out += `FEE_WITHDRAW = ${currency}:0\n`;
|
||||||
|
out += `FEE_DEPOSIT = ${Amounts.stringify(min)}\n`;
|
||||||
|
out += `FEE_REFRESH = ${currency}:0\n`;
|
||||||
|
out += `FEE_REFUND = ${currency}:0\n`;
|
||||||
|
out += `RSA_KEYSIZE = 2048\n`;
|
||||||
|
out += "\n";
|
||||||
|
x = Amounts.add(x, x).amount;
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(out);
|
||||||
|
});
|
||||||
|
|
||||||
|
const deploymentConfigCli = deploymentCli.subcommand("configArgs", "config", {
|
||||||
|
help: "Subcommands the Taler configuration.",
|
||||||
|
});
|
||||||
|
|
||||||
|
deploymentConfigCli
|
||||||
|
.subcommand("show", "show")
|
||||||
|
.flag("diagnostics", ["-d", "--diagnostics"])
|
||||||
|
.maybeArgument("cfgfile", clk.STRING, {})
|
||||||
|
.action(async (args) => {
|
||||||
|
const cfg = Configuration.load(args.show.cfgfile);
|
||||||
|
console.log(
|
||||||
|
cfg.stringify({
|
||||||
|
diagnostics: args.show.diagnostics,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
testingCli.subcommand("logtest", "logtest").action(async (args) => {
|
||||||
|
logger.trace("This is a trace message.");
|
||||||
|
logger.info("This is an info message.");
|
||||||
|
logger.warn("This is an warning message.");
|
||||||
|
logger.error("This is an error message.");
|
||||||
|
});
|
||||||
|
|
||||||
|
testingCli
|
||||||
|
.subcommand("listIntegrationtests", "list-integrationtests")
|
||||||
|
.action(async (args) => {
|
||||||
|
for (const t of getTestInfo()) {
|
||||||
|
let s = t.name;
|
||||||
|
if (t.suites.length > 0) {
|
||||||
|
s += ` (suites: ${t.suites.join(",")})`;
|
||||||
|
}
|
||||||
|
if (t.excludeByDefault) {
|
||||||
|
s += ` [excluded by default]`;
|
||||||
|
}
|
||||||
|
console.log(s);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
testingCli
|
||||||
|
.subcommand("runIntegrationtests", "run-integrationtests")
|
||||||
|
.maybeArgument("pattern", clk.STRING, {
|
||||||
|
help: "Glob pattern to select which tests to run",
|
||||||
|
})
|
||||||
|
.maybeOption("suites", ["--suites"], clk.STRING, {
|
||||||
|
help: "Only run selected suites (comma-separated list)",
|
||||||
|
})
|
||||||
|
.flag("dryRun", ["--dry"], {
|
||||||
|
help: "Only print tests that will be selected to run.",
|
||||||
|
})
|
||||||
|
.flag("quiet", ["--quiet"], {
|
||||||
|
help: "Produce less output.",
|
||||||
|
})
|
||||||
|
.action(async (args) => {
|
||||||
|
await runTests({
|
||||||
|
includePattern: args.runIntegrationtests.pattern,
|
||||||
|
suiteSpec: args.runIntegrationtests.suites,
|
||||||
|
dryRun: args.runIntegrationtests.dryRun,
|
||||||
|
verbosity: args.runIntegrationtests.quiet ? 0 : 1,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
async function read(stream: NodeJS.ReadStream) {
|
||||||
|
const chunks = [];
|
||||||
|
for await (const chunk of stream) chunks.push(chunk);
|
||||||
|
return Buffer.concat(chunks).toString("utf8");
|
||||||
|
}
|
||||||
|
|
||||||
|
testingCli.subcommand("tvgcheck", "tvgcheck").action(async (args) => {
|
||||||
|
const data = await read(process.stdin);
|
||||||
|
|
||||||
|
const lines = data.match(/[^\r\n]+/g);
|
||||||
|
|
||||||
|
if (!lines) {
|
||||||
|
throw Error("can't split lines");
|
||||||
|
}
|
||||||
|
|
||||||
|
const vals: Record<string, string> = {};
|
||||||
|
|
||||||
|
let inBlindSigningSection = false;
|
||||||
|
|
||||||
|
for (const line of lines) {
|
||||||
|
if (line === "blind signing:") {
|
||||||
|
inBlindSigningSection = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (line[0] !== " ") {
|
||||||
|
inBlindSigningSection = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (inBlindSigningSection) {
|
||||||
|
const m = line.match(/ (\w+) (\w+)/);
|
||||||
|
if (!m) {
|
||||||
|
console.log("bad format");
|
||||||
|
process.exit(2);
|
||||||
|
}
|
||||||
|
vals[m[1]] = m[2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(vals);
|
||||||
|
|
||||||
|
const req = (k: string) => {
|
||||||
|
if (!vals[k]) {
|
||||||
|
throw Error(`no value for ${k}`);
|
||||||
|
}
|
||||||
|
return decodeCrock(vals[k]);
|
||||||
|
};
|
||||||
|
|
||||||
|
const myBm = rsaBlind(
|
||||||
|
req("message_hash"),
|
||||||
|
req("blinding_key_secret"),
|
||||||
|
req("rsa_public_key"),
|
||||||
|
);
|
||||||
|
|
||||||
|
deepStrictEqual(req("blinded_message"), myBm);
|
||||||
|
|
||||||
|
console.log("check passed!");
|
||||||
|
});
|
||||||
|
|
||||||
|
export function main() {
|
||||||
|
testingCli.run();
|
||||||
|
}
|
33
packages/taler-harness/tsconfig.json
Normal file
33
packages/taler-harness/tsconfig.json
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"compileOnSave": true,
|
||||||
|
"compilerOptions": {
|
||||||
|
"composite": true,
|
||||||
|
"target": "ES2018",
|
||||||
|
"module": "ESNext",
|
||||||
|
"moduleResolution": "Node16",
|
||||||
|
"sourceMap": true,
|
||||||
|
"lib": ["es6"],
|
||||||
|
"noImplicitReturns": true,
|
||||||
|
"noFallthroughCasesInSwitch": true,
|
||||||
|
"strict": true,
|
||||||
|
"strictPropertyInitialization": false,
|
||||||
|
"outDir": "lib",
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"noImplicitThis": true,
|
||||||
|
"incremental": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"importHelpers": true,
|
||||||
|
"rootDir": "src",
|
||||||
|
"baseUrl": "./src",
|
||||||
|
"typeRoots": ["./node_modules/@types"]
|
||||||
|
},
|
||||||
|
"include": ["src/**/*"],
|
||||||
|
"references": [
|
||||||
|
{
|
||||||
|
"path": "../taler-wallet-core/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "../taler-util/"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -53,17 +53,15 @@ function git_hash() {
|
|||||||
|
|
||||||
export const buildConfig = {
|
export const buildConfig = {
|
||||||
entryPoints: ["src/index.ts"],
|
entryPoints: ["src/index.ts"],
|
||||||
outfile: "dist/taler-wallet-cli.cjs",
|
outfile: "dist/taler-wallet-cli.mjs",
|
||||||
bundle: true,
|
bundle: true,
|
||||||
minify: false,
|
minify: false,
|
||||||
target: [
|
target: [
|
||||||
'es6'
|
'es2020'
|
||||||
],
|
],
|
||||||
format: 'cjs',
|
format: 'esm',
|
||||||
platform: 'node',
|
platform: 'neutral',
|
||||||
sourcemap: true,
|
sourcemap: true,
|
||||||
jsxFactory: 'h',
|
|
||||||
jsxFragment: 'Fragment',
|
|
||||||
define: {
|
define: {
|
||||||
'__VERSION__': `"${_package.version}"`,
|
'__VERSION__': `"${_package.version}"`,
|
||||||
'__GIT_HASH__': `"${GIT_HASH}"`,
|
'__GIT_HASH__': `"${GIT_HASH}"`,
|
||||||
@ -76,4 +74,3 @@ esbuild
|
|||||||
console.log(e)
|
console.log(e)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user