From 33d2f1e23856a976045ca686580a6661beb12ef0 Mon Sep 17 00:00:00 2001 From: woodser Date: Thu, 11 May 2023 08:56:59 -0400 Subject: [PATCH] add config to test payout confirmation and unlock --- src/HavenoClient.test.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/HavenoClient.test.ts b/src/HavenoClient.test.ts index 33317885..3018cf58 100644 --- a/src/HavenoClient.test.ts +++ b/src/HavenoClient.test.ts @@ -177,7 +177,9 @@ const TestConfig = { maxTimePeerNoticeMs: 5000, maxConcurrency: 14, // max concurrency maxConcurrencyCI: 14, // CI test max concurrency - stopOnFailure: true + stopOnFailure: true, + testPayoutConfirmed: true, + testPayoutUnlocked: true } }; @@ -262,7 +264,9 @@ interface TradeContext { stopOnFailure?: boolean, buyerAppName?: string, sellerAppName?: string, - usedPorts?: string[] + usedPorts?: string[], + testPayoutConfirmed?: boolean, + testPayoutUnlocked?: boolean, } enum TradeRole { @@ -1742,7 +1746,7 @@ test("Selects arbitrators which are online, registered, and least used", async ( HavenoUtils.log(1, "Preparing for trades"); await prepareForTrading(4, user1, user2); HavenoUtils.log(1, "Completing trades with main arbitrator"); - await executeTrades(getTradeContexts(2)); + await executeTrades(getTradeContexts(2), {testPayoutConfirmed: false}); // start and register arbitrator2 let arbitrator2 = await initHaveno(); @@ -2218,9 +2222,10 @@ async function executeTrade(ctx?: TradeContext): Promise { } async function testTradePayoutUnlock(ctx: TradeContext) { - const height = await monerod.getHeight(); // test after payout confirmed + if (!ctx.testPayoutConfirmed) return; + const height = await monerod.getHeight(); const payoutTxId = (await ctx.arbitrator!.getTrade(ctx.offerId!)).getPayoutTxId(); let trade = await ctx.arbitrator!.getTrade(ctx.offerId!); if (trade.getPayoutState() !== "PAYOUT_CONFIRMED") await mineToHeight(height + 1); @@ -2232,6 +2237,7 @@ async function testTradePayoutUnlock(ctx: TradeContext) { expect(payoutTx?.getIsConfirmed()); // test after payout unlocked + if (!ctx.testPayoutUnlocked) return; trade = await ctx.arbitrator!.getTrade(ctx.offerId!); if (trade.getPayoutState() !== "PAYOUT_UNLOCKED") await mineToHeight(height + 10); await wait(TestConfig.maxWalletStartupMs + ctx.walletSyncPeriodMs! * 2);