Fix libeufin refund test.

The ingestion needed a delay to take place.
This commit is contained in:
ms 2021-07-30 10:53:26 +02:00
parent 2ccfa3c2f2
commit 263b1e7751
No known key found for this signature in database
GPG Key ID: 8D526861953F4C0F

View File

@ -17,7 +17,7 @@
/** /**
* Imports. * Imports.
*/ */
import { GlobalTestState } from "./harness"; import { GlobalTestState, delayMs } from "./harness";
import { import {
SandboxUserBundle, SandboxUserBundle,
NexusUserBundle, NexusUserBundle,
@ -71,15 +71,37 @@ export async function runLibeufinRefundTest(t: GlobalTestState) {
"EUR", "EUR",
); );
// check payment shows up in the Sandbox' history.
// NOTE: the debitor account has no entry so far, because
// the call above is a mere test method that books only one
// CRDT transaction.
const txsCredit = await LibeufinSandboxApi.getAccountTransactions(
libeufinServices.libeufinSandbox,
user02sandbox.ebicsBankAccount["label"]);
t.assertTrue(txsCredit["payments"].length == 1);
// Gets the faulty payment in the (ingested) history.
await LibeufinNexusApi.fetchAllTransactions( await LibeufinNexusApi.fetchAllTransactions(
libeufinServices.libeufinNexus, libeufinServices.libeufinNexus,
user02nexus.localAccountName, user02nexus.localAccountName,
); );
// Give time to ingest.
delayMs(2000);
// Check payment shows up in Nexus history.
const nexusTxs = await LibeufinNexusApi.getAccountTransactions(
libeufinServices.libeufinNexus,
user02nexus.localAccountName,
);
t.assertTrue(nexusTxs.data["transactions"].length == 1);
// This should pay the faulty payment back.
await LibeufinNexusApi.submitInitiatedPayment( await LibeufinNexusApi.submitInitiatedPayment(
libeufinServices.libeufinNexus, libeufinServices.libeufinNexus,
user02nexus.localAccountName, user02nexus.localAccountName,
"1", // so far the only one that can exist. // The initiated payment ID below got set by the Taler
// facade; at this point only one can / must exist.
"1",
); );
// Counterpart checks whether the reimbursement shows up. // Counterpart checks whether the reimbursement shows up.
@ -87,7 +109,6 @@ export async function runLibeufinRefundTest(t: GlobalTestState) {
libeufinServices.libeufinSandbox, libeufinServices.libeufinSandbox,
user01sandbox.ebicsBankAccount["label"], user01sandbox.ebicsBankAccount["label"],
); );
t.assertTrue(history["payments"].length == 1); t.assertTrue(history["payments"].length == 1);
} }
runLibeufinRefundTest.suites = ["libeufin"]; runLibeufinRefundTest.suites = ["libeufin"];