From d9433a2116541160ed82f6780116c1c70afe4e2f Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 11 May 2020 18:19:43 +0530 Subject: logging --- src/headless/integrationtest.ts | 7 +------ src/operations/refresh.ts | 4 ---- src/operations/withdraw.ts | 6 ------ src/util/query.ts | 3 --- src/wallet.ts | 31 +++++++++---------------------- 5 files changed, 10 insertions(+), 41 deletions(-) diff --git a/src/headless/integrationtest.ts b/src/headless/integrationtest.ts index 24ceb9ce0..5beb7b793 100644 --- a/src/headless/integrationtest.ts +++ b/src/headless/integrationtest.ts @@ -77,9 +77,8 @@ async function makePayment( paymentStatus = await merchant.checkPayment(orderResp.orderId); - console.log("payment status after wallet payment:", paymentStatus); - if (!paymentStatus.paid) { + console.log("payment status:", paymentStatus); throw Error("payment did not succeed"); } @@ -112,10 +111,6 @@ export async function runIntegrationTest(args: IntegrationTestArgs): Promise { + let done = false; const p = new Promise((resolve, reject) => { // Run this asynchronously this.addNotificationListener((n) => { + if (done) { + return; + } if ( n.type === NotificationType.WaitingForRetry && n.numGivingLiveness == 0 ) { - logger.trace("no liveness-giving operations left, returning"); + done = true; + logger.trace("no liveness-giving operations left"); resolve(); } }); @@ -277,23 +282,9 @@ export class Wallet { * returns without resolving to an exception. */ public async runUntilDoneAndStop(): Promise { - const p = new Promise((resolve, reject) => { - // Run this asynchronously - this.addNotificationListener((n) => { - if ( - n.type === NotificationType.WaitingForRetry && - n.numGivingLiveness == 0 - ) { - logger.trace("no liveness-giving operations left, stopping"); - this.stop(); - } - }); - this.runRetryLoop().catch((e) => { - console.log("exception in wallet retry loop"); - reject(e); - }); - }); - await p; + await this.runUntilDone(); + logger.trace("stopping after liveness-giving operations done"); + this.stop(); } /** @@ -314,9 +305,7 @@ export class Wallet { private async runRetryLoopImpl(): Promise { while (!this.stopped) { - console.log("running wallet retry loop iteration"); const pending = await this.getPendingOperations({ onlyDue: true }); - console.log("pending ops", JSON.stringify(pending, undefined, 2)); if (pending.pendingOperations.length === 0) { const allPending = await this.getPendingOperations({ onlyDue: false }); let numPending = 0; @@ -346,12 +335,10 @@ export class Wallet { await Promise.race([timeout, this.latch.wait()]); console.log("timeout done"); } else { - logger.trace("running pending operations that are due"); // FIXME: maybe be a bit smarter about executing these // operations in parallel? for (const p of pending.pendingOperations) { try { - console.log("running", p); await this.processOnePendingOperation(p); } catch (e) { console.error(e); -- cgit v1.2.3