testing c52/c53 coordination,
and allow passing query parameters to the "fetch transactions" API from Nexus.
This commit is contained in:
parent
4e9d59e6f6
commit
311f89c8ba
@ -1 +1 @@
|
||||
Subproject commit c76fb9b3af6ec43f2d2a83e6b4f523dcc5ac6a54
|
||||
Subproject commit 38c168b11eeeab93562ffa74b3e2aff4b596c77a
|
@ -245,7 +245,7 @@ export class LibeufinSandboxService implements LibeufinSandboxServiceInterface {
|
||||
async makeTransaction(
|
||||
debit: string,
|
||||
credit: string,
|
||||
amount: string,
|
||||
amount: string, // $currency:x.y
|
||||
subject: string,): Promise<string> {
|
||||
const stdout = await sh(
|
||||
this.globalTestState,
|
||||
@ -1237,9 +1237,11 @@ export namespace LibeufinNexusApi {
|
||||
return response;
|
||||
}
|
||||
|
||||
export async function fetchAllTransactions(
|
||||
export async function fetchTransactions(
|
||||
libeufinNexusService: LibeufinNexusService,
|
||||
accountName: string,
|
||||
rangeType: string = "all",
|
||||
level: string = "report",
|
||||
username: string = "admin",
|
||||
password: string = "test",
|
||||
): Promise<any> {
|
||||
@ -1251,8 +1253,8 @@ export namespace LibeufinNexusApi {
|
||||
return await axios.post(
|
||||
url.href,
|
||||
{
|
||||
rangeType: "all",
|
||||
level: "report",
|
||||
rangeType: rangeType,
|
||||
level: level,
|
||||
},
|
||||
{
|
||||
auth: {
|
||||
|
@ -99,7 +99,7 @@ export async function runLibeufinApiBankaccountTest(t: GlobalTestState) {
|
||||
subject: "mock subject",
|
||||
}
|
||||
);
|
||||
await LibeufinNexusApi.fetchAllTransactions(nexus, "local-mock");
|
||||
await LibeufinNexusApi.fetchTransactions(nexus, "local-mock");
|
||||
let transactions = await LibeufinNexusApi.getAccountTransactions(
|
||||
nexus,
|
||||
"local-mock",
|
||||
|
@ -264,7 +264,7 @@ export async function runLibeufinBasicTest(t: GlobalTestState) {
|
||||
},
|
||||
);
|
||||
|
||||
await LibeufinNexusApi.fetchAllTransactions(libeufinNexus, "myacct");
|
||||
await LibeufinNexusApi.fetchTransactions(libeufinNexus, "myacct");
|
||||
|
||||
await exchange.runWirewatchOnce();
|
||||
|
||||
|
@ -0,0 +1,137 @@
|
||||
/*
|
||||
This file is part of GNU Taler
|
||||
(C) 2020 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 { GlobalTestState, delayMs } from "./harness";
|
||||
import {
|
||||
SandboxUserBundle,
|
||||
NexusUserBundle,
|
||||
launchLibeufinServices,
|
||||
LibeufinSandboxApi,
|
||||
LibeufinNexusApi,
|
||||
} from "./libeufin";
|
||||
|
||||
/**
|
||||
* This test checks how the C52 and C53 coordinate. It'll test
|
||||
* whether fresh transactions stop showing as C52 after they get
|
||||
* included in a bank statement.
|
||||
*/
|
||||
export async function runLibeufinC5xTest(t: GlobalTestState) {
|
||||
/**
|
||||
* User saltetd "01"
|
||||
*/
|
||||
const user01nexus = new NexusUserBundle(
|
||||
"01",
|
||||
"http://localhost:5010/ebicsweb",
|
||||
);
|
||||
const user01sandbox = new SandboxUserBundle("01");
|
||||
|
||||
/**
|
||||
* User saltetd "02".
|
||||
*/
|
||||
const user02nexus = new NexusUserBundle(
|
||||
"02",
|
||||
"http://localhost:5010/ebicsweb",
|
||||
);
|
||||
const user02sandbox = new SandboxUserBundle("02");
|
||||
|
||||
/**
|
||||
* Launch Sandbox and Nexus.
|
||||
*/
|
||||
const libeufinServices = await launchLibeufinServices(
|
||||
t,
|
||||
[user01nexus, user02nexus],
|
||||
[user01sandbox, user02sandbox],
|
||||
["twg"],
|
||||
);
|
||||
|
||||
// Check that C52 and C53 have zero entries.
|
||||
|
||||
// C52
|
||||
await LibeufinNexusApi.fetchTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
"all", // range
|
||||
"report", // level
|
||||
);
|
||||
// C53
|
||||
await LibeufinNexusApi.fetchTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
"all", // range
|
||||
"statement", // level
|
||||
);
|
||||
const nexusTxs = await LibeufinNexusApi.getAccountTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
);
|
||||
t.assertTrue(nexusTxs.data["transactions"].length == 0);
|
||||
|
||||
// Addressing one payment to user 01
|
||||
await libeufinServices.libeufinSandbox.makeTransaction(
|
||||
user02sandbox.ebicsBankAccount.label, // debit
|
||||
user01sandbox.ebicsBankAccount.label, // credit
|
||||
"EUR:10",
|
||||
"first payment",
|
||||
);
|
||||
|
||||
// Checking that C52 has one and C53 has zero.
|
||||
|
||||
let expectOne = await LibeufinNexusApi.fetchTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
"all", // range
|
||||
"report", // C52
|
||||
);
|
||||
t.assertTrue(expectOne.data.newTransactions == 1);
|
||||
t.assertTrue(expectOne.data.downloadedTransactions == 1);
|
||||
let expectZero = await LibeufinNexusApi.fetchTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
"all", // range
|
||||
"statement", // C53
|
||||
);
|
||||
t.assertTrue(expectZero.data.newTransactions == 0);
|
||||
t.assertTrue(expectZero.data.downloadedTransactions == 0);
|
||||
|
||||
// Ticking now: the one payment should be downloaded
|
||||
// in a C53 but not in a C52. In any case, the payment
|
||||
// is not new anymore, because it was already ingested
|
||||
// when it was downloaded for the first time along the
|
||||
// c52 above.
|
||||
await libeufinServices.libeufinSandbox.c53tick();
|
||||
|
||||
expectOne = await LibeufinNexusApi.fetchTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
"all", // range
|
||||
"statement", // C53
|
||||
);
|
||||
t.assertTrue(expectOne.data.downloadedTransactions == 1);
|
||||
t.assertTrue(expectOne.data.newTransactions == 0);
|
||||
|
||||
expectZero = await LibeufinNexusApi.fetchTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
"all", // range
|
||||
"report", // C52
|
||||
);
|
||||
t.assertTrue(expectZero.data.downloadedTransactions == 0);
|
||||
t.assertTrue(expectZero.data.newTransactions == 0);
|
||||
}
|
||||
runLibeufinC5xTest.suites = ["libeufin"];
|
@ -58,7 +58,7 @@ export async function runLibeufinAnastasisFacadeTest(t: GlobalTestState) {
|
||||
t.assertTrue(anastasisBaseUrl.startsWith("http://"));
|
||||
t.assertTrue(anastasisBaseUrl.endsWith("/"));
|
||||
|
||||
await LibeufinNexusApi.fetchAllTransactions(
|
||||
await LibeufinNexusApi.fetchTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
);
|
||||
@ -107,7 +107,7 @@ export async function runLibeufinAnastasisFacadeTest(t: GlobalTestState) {
|
||||
},
|
||||
)
|
||||
|
||||
await LibeufinNexusApi.fetchAllTransactions(
|
||||
await LibeufinNexusApi.fetchTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
);
|
||||
@ -140,7 +140,7 @@ export async function runLibeufinAnastasisFacadeTest(t: GlobalTestState) {
|
||||
},
|
||||
)
|
||||
|
||||
await LibeufinNexusApi.fetchAllTransactions(
|
||||
await LibeufinNexusApi.fetchTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
);
|
||||
|
@ -46,7 +46,7 @@ export async function runLibeufinKeyrotationTest(t: GlobalTestState) {
|
||||
t, [user01nexus], [user01sandbox],
|
||||
);
|
||||
|
||||
await LibeufinNexusApi.fetchAllTransactions(
|
||||
await LibeufinNexusApi.fetchTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
);
|
||||
@ -57,7 +57,7 @@ export async function runLibeufinKeyrotationTest(t: GlobalTestState) {
|
||||
user01sandbox.ebicsBankAccount.subscriber.hostID,
|
||||
);
|
||||
|
||||
const resp = await LibeufinNexusApi.fetchAllTransactions(
|
||||
const resp = await LibeufinNexusApi.fetchTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
);
|
||||
|
@ -77,7 +77,7 @@ export async function runLibeufinRefundMultipleUsersTest(t: GlobalTestState) {
|
||||
);
|
||||
|
||||
// user 01 fetches the payments
|
||||
await LibeufinNexusApi.fetchAllTransactions(
|
||||
await LibeufinNexusApi.fetchTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
);
|
||||
|
@ -68,7 +68,7 @@ export async function runLibeufinRefundTest(t: GlobalTestState) {
|
||||
|
||||
// The bad payment should be now ingested and prepared as
|
||||
// a reimbursement.
|
||||
await LibeufinNexusApi.fetchAllTransactions(
|
||||
await LibeufinNexusApi.fetchTransactions(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.localAccountName,
|
||||
);
|
||||
|
@ -57,6 +57,7 @@ import { runWithdrawalAbortBankTest } from "./test-withdrawal-abort-bank";
|
||||
import { runWithdrawalBankIntegratedTest } from "./test-withdrawal-bank-integrated";
|
||||
import { runMerchantExchangeConfusionTest } from "./test-merchant-exchange-confusion";
|
||||
import { runLibeufinBasicTest } from "./test-libeufin-basic";
|
||||
import { runLibeufinC5xTest } from "./test-libeufin-c5x";
|
||||
import { runLibeufinKeyrotationTest } from "./test-libeufin-keyrotation";
|
||||
import { runLibeufinRefundTest } from "./test-libeufin-refund";
|
||||
import { runLibeufinRefundMultipleUsersTest } from "./test-libeufin-refund-multiple-users";
|
||||
@ -111,6 +112,7 @@ const allTests: TestMainFunction[] = [
|
||||
runLibeufinKeyrotationTest,
|
||||
runLibeufinTutorialTest,
|
||||
runLibeufinRefundTest,
|
||||
runLibeufinC5xTest,
|
||||
runLibeufinRefundMultipleUsersTest,
|
||||
runLibeufinApiPermissionsTest,
|
||||
runLibeufinApiFacadeTest,
|
||||
|
Loading…
Reference in New Issue
Block a user