integration tests: make test-wallet-cryptoworker pass

This commit is contained in:
Florian Dold 2022-10-05 16:01:59 +02:00
parent 70d37e4ed3
commit 99ace8b7d2
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
4 changed files with 17 additions and 8 deletions

View File

@ -182,7 +182,7 @@ export const walletCli = clk
},
})
.maybeOption("cryptoWorker", ["--crypto-worker"], clk.STRING, {
help: "Override crypto worker implementation type."
help: "Override crypto worker implementation type.",
})
.maybeOption("log", ["-L", "--log"], clk.STRING, {
help: "configure log level (NONE, ..., TRACE)",
@ -729,6 +729,14 @@ const advancedCli = walletCli.subcommand("advancedArgs", "advanced", {
help: "Subcommands for advanced operations (only use if you know what you're doing!).",
});
advancedCli
.subcommand("init", "init", {
help: "Initialize the wallet (with DB) and exit."
})
.action(async (args) => {
await withWallet(args, async () => {});
});
advancedCli
.subcommand("bench1", "bench1", {
help: "Run the 'bench1' benchmark",

View File

@ -43,13 +43,13 @@ export async function runWalletCryptoWorkerTest(t: GlobalTestState) {
cryptoWorkerType: "sync",
});
await wallet1.client.call(WalletApiOperation.CryptoTest, {});
await wallet1.client.call(WalletApiOperation.TestCrypto, {});
const wallet2 = new WalletCli(t, "w2", {
cryptoWorkerType: "node-worker-thread",
});
await wallet2.client.call(WalletApiOperation.CryptoTest, {});
await wallet2.client.call(WalletApiOperation.TestCrypto, {});
}
runWalletCryptoWorkerTest.suites = ["wallet"];

View File

@ -37,6 +37,7 @@ export async function processRequestWithImpl(
reqMsg: CryptoWorkerRequestMessage,
impl: TalerCryptoInterfaceR,
): Promise<CryptoWorkerResponseMessage> {
logger.info(`processing crypto request ${j2s(reqMsg)}`);
if (typeof reqMsg !== "object") {
logger.error("request must be an object");
return {
@ -85,7 +86,7 @@ export async function processRequestWithImpl(
let responseMsg: CryptoWorkerResponseMessage;
try {
const result = await (impl as any)[operation](impl, reqMsg);
const result = await (impl as any)[operation](impl, reqMsg.req);
responseMsg = { type: "success", result, id };
} catch (e: any) {
logger.error(`error during operation: ${e.stack ?? e.toString()}`);

View File

@ -92,7 +92,7 @@ export enum WalletApiOperation {
WithdrawTestBalance = "withdrawTestBalance",
PreparePayForUri = "preparePayForUri",
RunIntegrationTest = "runIntegrationTest",
CryptoTest = "cryptoTest",
TestCrypto = "testCrypto",
TestPay = "testPay",
AddExchange = "addExchange",
GetTransactions = "getTransactions",
@ -528,8 +528,8 @@ export type RunIntegrationTestOp = {
/**
* Test crypto worker.
*/
export type CryptoTestOp = {
op: WalletApiOperation.CryptoTest;
export type TestCryptoOp = {
op: WalletApiOperation.TestCrypto;
request: {};
response: any;
};
@ -649,7 +649,7 @@ export type WalletOperations = {
[WalletApiOperation.AddBackupProvider]: AddBackupProviderOp;
[WalletApiOperation.GetBackupInfo]: GetBackupInfoOp;
[WalletApiOperation.RunIntegrationTest]: RunIntegrationTestOp;
[WalletApiOperation.CryptoTest]: CryptoTestOp;
[WalletApiOperation.TestCrypto]: TestCryptoOp;
[WalletApiOperation.WithdrawTestBalance]: WithdrawTestBalanceOp;
[WalletApiOperation.TestPay]: TestPayOp;
[WalletApiOperation.ExportDb]: ExportDbOp;