commit 13abacc44f7c73b0dd69bc8a4b507276c957c3e1
parent 2f93030ca246e0cb6fd06463988267d6a956c2be
Author: Florian Dold <florian@dold.me>
Date: Wed, 11 Dec 2024 18:53:57 +0100
harness: tweak tests
Diffstat:
5 files changed, 148 insertions(+), 103 deletions(-)
diff --git a/packages/taler-harness/src/index.ts b/packages/taler-harness/src/index.ts
@@ -81,6 +81,7 @@ import {
WalletClient,
delayMs,
runTestWithState,
+ waitMs,
} from "./harness/harness.js";
import { getTestInfo, runTests } from "./integrationtests/testrunner.js";
import { lintExchangeDeployment } from "./lint.js";
@@ -1463,8 +1464,12 @@ const allAmlPrograms: TalerKycAml.AmlProgramDefinition[] = [
{
name: "hang",
logic: async (_input, _config) => {
+ console.log("going to wait ...");
// Wait forever
- await new Promise<void>(() => {});
+ while (1) {
+ await waitMs(1000);
+ console.log("still waiting");
+ }
throw Error("not reached");
},
requiredAttributes: [],
@@ -1521,7 +1526,7 @@ amlProgramCli
logger.info(`got input: ${j2s(progInput)}`);
- const outcome = found.logic(progInput, args.run.config);
+ const outcome = await found.logic(progInput, args.run.config);
console.log(j2s(outcome));
});
diff --git a/packages/taler-harness/src/integrationtests/test-kyc-amp-failure.ts b/packages/taler-harness/src/integrationtests/test-kyc-amp-failure.ts
@@ -0,0 +1,114 @@
+/*
+ This file is part of GNU Taler
+ (C) 2024 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 {
+ Configuration,
+ j2s,
+ TransactionIdStr,
+ TransactionMajorState,
+ TransactionMinorState,
+} from "@gnu-taler/taler-util";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
+import {
+ createKycTestkudosEnvironment,
+ withdrawViaBankV3,
+} from "../harness/environments.js";
+import { GlobalTestState } from "../harness/harness.js";
+
+function adjustExchangeConfig(config: Configuration) {
+ config.setString("exchange", "enable_kyc", "yes");
+
+ config.setString("exchangedb", "MAX_AML_PROGRAM_RUNTIME", "3s");
+
+ config.setString("KYC-RULE-R1", "operation_type", "withdraw");
+ config.setString("KYC-RULE-R1", "enabled", "yes");
+ config.setString("KYC-RULE-R1", "exposed", "yes");
+ config.setString("KYC-RULE-R1", "is_and_combinator", "no");
+ config.setString("KYC-RULE-R1", "threshold", "TESTKUDOS:10");
+ config.setString("KYC-RULE-R1", "timeframe", "1d");
+ config.setString("KYC-RULE-R1", "next_measures", "M1");
+
+ //config.setString("KYC-MEASURE-M1", "check_name", "skip");
+ config.setString("KYC-MEASURE-M1", "context", "{}");
+ config.setString("KYC-MEASURE-M1", "program", "P1");
+
+ config.setString("KYC-MEASURE-M2", "program", "NONE");
+ config.setString("KYC-MEASURE-M2", "check_name", "C2");
+ config.setString("KYC-MEASURE-M2", "context", "{}");
+
+ config.setString("KYC-CHECK-C2", "type", "INFO");
+ config.setString("KYC-CHECK-C2", "description", "my check!");
+ config.setString("KYC-CHECK-C2", "fallback", "M2");
+
+ config.setString("AML-PROGRAM-P1", "enabled", "true");
+ config.setString("AML-PROGRAM-P1", "description", "hang");
+ config.setString("AML-PROGRAM-P1", "description_i18n", "{}");
+ config.setString("AML-PROGRAM-P1", "fallback", "M2");
+ config.setString(
+ "AML-PROGRAM-P1",
+ "command",
+ "taler-harness aml-program run-program --name fail",
+ );
+
+ config.setString("AML-PROGRAM-NONE", "enabled", "true");
+ config.setString("AML-PROGRAM-NONE", "description", "nothing");
+ config.setString("AML-PROGRAM-NONE", "description_i18n", "{}");
+ config.setString("AML-PROGRAM-NONE", "fallback", "M2");
+ config.setString("AML-PROGRAM-NONE", "command", "/bin/true");
+
+ config.setString;
+}
+
+/**
+ * Tests for making AML decisions.
+ * - Test making decisions on unknown accounts.
+ * - Test making decisions with default rules.
+ */
+export async function runKycAmpFailureTest(t: GlobalTestState) {
+ // Set up test environment
+
+ // FIXME: Reduced test environment without merchant suffices
+ const { walletClient, bankClient, exchange, amlKeypair } =
+ await createKycTestkudosEnvironment(t, { adjustExchangeConfig });
+
+ const wres = await withdrawViaBankV3(t, {
+ walletClient,
+ exchange,
+ bankClient,
+ amount: "TESTKUDOS:20",
+ });
+
+ await walletClient.call(WalletApiOperation.TestingWaitTransactionState, {
+ transactionId: wres.transactionId as TransactionIdStr,
+ txState: {
+ major: TransactionMajorState.Pending,
+ minor: TransactionMinorState.KycRequired,
+ },
+ });
+
+ const txDet = await walletClient.call(WalletApiOperation.GetTransactionById, {
+ transactionId: wres.transactionId as TransactionIdStr,
+ });
+
+ console.log(j2s(txDet));
+
+ await wres.withdrawalFinishedCond;
+}
+
+runKycAmpFailureTest.suites = ["wallet"];
diff --git a/packages/taler-harness/src/integrationtests/test-kyc-amp-timeout-failure.ts b/packages/taler-harness/src/integrationtests/test-kyc-amp-timeout-failure.ts
@@ -1,93 +0,0 @@
-/*
- This file is part of GNU Taler
- (C) 2024 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 { Configuration } from "@gnu-taler/taler-util";
-import {
- createKycTestkudosEnvironment,
- withdrawViaBankV3,
-} from "../harness/environments.js";
-import { GlobalTestState } from "../harness/harness.js";
-
-function adjustExchangeConfig(config: Configuration) {
- config.setString("exchange", "enable_kyc", "yes");
-
- config.setString("exchangedb", "MAX_AML_PROGRAM_RUNTIME", "3s");
-
- config.setString("KYC-RULE-R1", "operation_type", "withdraw");
- config.setString("KYC-RULE-R1", "enabled", "yes");
- config.setString("KYC-RULE-R1", "exposed", "yes");
- config.setString("KYC-RULE-R1", "is_and_combinator", "no");
- config.setString("KYC-RULE-R1", "threshold", "TESTKUDOS:10");
- config.setString("KYC-RULE-R1", "timeframe", "1d");
- config.setString("KYC-RULE-R1", "next_measures", "M1");
-
- //config.setString("KYC-MEASURE-M1", "check_name", "skip");
- config.setString("KYC-MEASURE-M1", "context", "{}");
- config.setString("KYC-MEASURE-M1", "program", "P1");
-
- config.setString("KYC-MEASURE-M2", "program", "NONE");
- config.setString("KYC-MEASURE-M2", "check_name", "C2");
- config.setString("KYC-MEASURE-M2", "context", "{}");
-
- config.setString("KYC-CHECK-C2", "type", "INFO");
- config.setString("KYC-CHECK-C2", "description", "my check!");
- config.setString("KYC-CHECK-C2", "fallback", "M2");
-
- config.setString("AML-PROGRAM-P1", "enabled", "true");
- config.setString("AML-PROGRAM-P1", "description", "hang");
- config.setString("AML-PROGRAM-P1", "description_i18n", "{}");
- config.setString("AML-PROGRAM-P1", "fallback", "M2");
- config.setString(
- "AML-PROGRAM-P1",
- "command",
- "taler-harness aml-program run-program --name fail",
- );
-
- config.setString("AML-PROGRAM-NONE", "enabled", "true");
- config.setString("AML-PROGRAM-NONE", "description", "nothing");
- config.setString("AML-PROGRAM-NONE", "description_i18n", "{}");
- config.setString("AML-PROGRAM-NONE", "fallback", "M2");
- config.setString("AML-PROGRAM-NONE", "command", "/bin/true");
-
- config.setString;
-}
-
-/**
- * Tests for making AML decisions.
- * - Test making decisions on unknown accounts.
- * - Test making decisions with default rules.
- */
-export async function runKycAmpFailureTest(t: GlobalTestState) {
- // Set up test environment
-
- // FIXME: Reduced test environment without merchant suffices
- const { walletClient, bankClient, exchange, amlKeypair } =
- await createKycTestkudosEnvironment(t, { adjustExchangeConfig });
-
- const wres = await withdrawViaBankV3(t, {
- walletClient,
- exchange,
- bankClient,
- amount: "TESTKUDOS:20",
- });
-
- await wres.withdrawalFinishedCond;
-}
-
-runKycAmpFailureTest.suites = ["wallet"];
diff --git a/packages/taler-harness/src/integrationtests/test-kyc-amp-timeout.ts b/packages/taler-harness/src/integrationtests/test-kyc-amp-timeout.ts
@@ -17,7 +17,14 @@
/**
* Imports.
*/
-import { Configuration } from "@gnu-taler/taler-util";
+import {
+ Configuration,
+ j2s,
+ TransactionIdStr,
+ TransactionMajorState,
+ TransactionMinorState,
+} from "@gnu-taler/taler-util";
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import {
createKycTestkudosEnvironment,
withdrawViaBankV3,
@@ -63,11 +70,7 @@ function adjustExchangeConfig(config: Configuration) {
config.setString("AML-PROGRAM-NONE", "description", "nothing");
config.setString("AML-PROGRAM-NONE", "description_i18n", "{}");
config.setString("AML-PROGRAM-NONE", "fallback", "M2");
- config.setString(
- "AML-PROGRAM-NONE",
- "command",
- "/bin/true",
- );
+ config.setString("AML-PROGRAM-NONE", "command", "/bin/true");
config.setString;
}
@@ -91,7 +94,23 @@ export async function runKycAmpTimeoutTest(t: GlobalTestState) {
amount: "TESTKUDOS:20",
});
- await wres.withdrawalFinishedCond;
+ await walletClient.call(WalletApiOperation.TestingWaitTransactionState, {
+ transactionId: wres.transactionId as TransactionIdStr,
+ txState: {
+ major: TransactionMajorState.Pending,
+ minor: TransactionMinorState.KycRequired,
+ },
+ });
+
+ const txDet = await walletClient.call(WalletApiOperation.GetTransactionById, {
+ transactionId: wres.transactionId as TransactionIdStr,
+ });
+
+ console.log(j2s(txDet));
+
+ // FIXME: Test incomplete. Check that fallback rules have been applied.
+
+ //await wres.withdrawalFinishedCond;
}
runKycAmpTimeoutTest.suites = ["wallet"];
diff --git a/packages/taler-harness/src/integrationtests/testrunner.ts b/packages/taler-harness/src/integrationtests/testrunner.ts
@@ -49,7 +49,7 @@ import { runExchangeTimetravelTest } from "./test-exchange-timetravel.js";
import { runFeeRegressionTest } from "./test-fee-regression.js";
import { runForcedSelectionTest } from "./test-forced-selection.js";
import { runKnownAccountsTest } from "./test-known-accounts.js";
-import { runKycAmpFailureTest } from "./test-kyc-amp-timeout-failure.js";
+import { runKycAmpFailureTest } from "./test-kyc-amp-failure.js";
import { runKycAmpTimeoutTest } from "./test-kyc-amp-timeout.js";
import { runKycBalanceWithdrawalTest } from "./test-kyc-balance-withdrawal.js";
import { runKycDecisionsTest } from "./test-kyc-decisions.js";