commit d1ca613fc7a06d66d9c53277a30b15a16b5195b0
parent 599fb50d49c5e173118126196c7d0d58bacd0f96
Author: Florian Dold <florian@dold.me>
Date: Mon, 9 Dec 2024 19:15:59 +0100
harness: need to add exchange before initiating peer-pull payment
Diffstat:
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/packages/taler-harness/src/integrationtests/test-peer-to-peer-pull.ts b/packages/taler-harness/src/integrationtests/test-peer-to-peer-pull.ts
@@ -23,7 +23,6 @@ import {
Duration,
j2s,
NotificationType,
- ScopeType,
TalerCorebankApiClient,
TransactionMajorState,
TransactionMinorState,
@@ -105,6 +104,10 @@ async function checkNormalPeerPull(
),
);
+ await wallet1.call(WalletApiOperation.AddExchange, {
+ exchangeBaseUrl: exchange.baseUrl,
+ });
+
const checkPullCreditResp1 = await wallet1.client.call(
WalletApiOperation.CheckPeerPullCredit,
{
diff --git a/packages/taler-wallet-core/src/exchanges.ts b/packages/taler-wallet-core/src/exchanges.ts
@@ -3653,6 +3653,13 @@ export async function getPreferredExchangeForCurrency(
if (restrictScope) {
checkLogicInvariant(restrictScope.currency === currency);
}
+ if (logger.shouldLogTrace()) {
+ logger.trace(
+ `finding preferred exchange for currency ${currency}, scope ${j2s(
+ restrictScope,
+ )}`,
+ );
+ }
// Find an exchange with the matching currency.
// Prefer exchanges with the most recent withdrawal.
const url = await wex.db.runReadOnlyTx(
@@ -3666,15 +3673,18 @@ export async function getPreferredExchangeForCurrency(
},
async (tx) => {
const exchanges = await tx.exchanges.iter().toArray();
+ logger.trace(`have ${exchanges.length} exchanges`);
let candidate = undefined;
for (const e of exchanges) {
if (e.detailsPointer?.currency !== currency) {
+ logger.trace("no details pointer");
continue;
}
const inScope =
!restrictScope ||
(await checkExchangeInScopeTx(wex, tx, e.baseUrl, restrictScope));
if (!inScope) {
+ logger.trace("not in scope");
continue;
}
if (!candidate) {