mirror of
https://github.com/haveno-dex/haveno-ts.git
synced 2024-10-01 01:35:42 -04:00
add config to test payout confirmation and unlock
This commit is contained in:
parent
d2aa1768e1
commit
33d2f1e238
@ -177,7 +177,9 @@ const TestConfig = {
|
|||||||
maxTimePeerNoticeMs: 5000,
|
maxTimePeerNoticeMs: 5000,
|
||||||
maxConcurrency: 14, // max concurrency
|
maxConcurrency: 14, // max concurrency
|
||||||
maxConcurrencyCI: 14, // CI test max concurrency
|
maxConcurrencyCI: 14, // CI test max concurrency
|
||||||
stopOnFailure: true
|
stopOnFailure: true,
|
||||||
|
testPayoutConfirmed: true,
|
||||||
|
testPayoutUnlocked: true
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -262,7 +264,9 @@ interface TradeContext {
|
|||||||
stopOnFailure?: boolean,
|
stopOnFailure?: boolean,
|
||||||
buyerAppName?: string,
|
buyerAppName?: string,
|
||||||
sellerAppName?: string,
|
sellerAppName?: string,
|
||||||
usedPorts?: string[]
|
usedPorts?: string[],
|
||||||
|
testPayoutConfirmed?: boolean,
|
||||||
|
testPayoutUnlocked?: boolean,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum TradeRole {
|
enum TradeRole {
|
||||||
@ -1742,7 +1746,7 @@ test("Selects arbitrators which are online, registered, and least used", async (
|
|||||||
HavenoUtils.log(1, "Preparing for trades");
|
HavenoUtils.log(1, "Preparing for trades");
|
||||||
await prepareForTrading(4, user1, user2);
|
await prepareForTrading(4, user1, user2);
|
||||||
HavenoUtils.log(1, "Completing trades with main arbitrator");
|
HavenoUtils.log(1, "Completing trades with main arbitrator");
|
||||||
await executeTrades(getTradeContexts(2));
|
await executeTrades(getTradeContexts(2), {testPayoutConfirmed: false});
|
||||||
|
|
||||||
// start and register arbitrator2
|
// start and register arbitrator2
|
||||||
let arbitrator2 = await initHaveno();
|
let arbitrator2 = await initHaveno();
|
||||||
@ -2218,9 +2222,10 @@ async function executeTrade(ctx?: TradeContext): Promise<string> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function testTradePayoutUnlock(ctx: TradeContext) {
|
async function testTradePayoutUnlock(ctx: TradeContext) {
|
||||||
const height = await monerod.getHeight();
|
|
||||||
|
|
||||||
// test after payout confirmed
|
// test after payout confirmed
|
||||||
|
if (!ctx.testPayoutConfirmed) return;
|
||||||
|
const height = await monerod.getHeight();
|
||||||
const payoutTxId = (await ctx.arbitrator!.getTrade(ctx.offerId!)).getPayoutTxId();
|
const payoutTxId = (await ctx.arbitrator!.getTrade(ctx.offerId!)).getPayoutTxId();
|
||||||
let trade = await ctx.arbitrator!.getTrade(ctx.offerId!);
|
let trade = await ctx.arbitrator!.getTrade(ctx.offerId!);
|
||||||
if (trade.getPayoutState() !== "PAYOUT_CONFIRMED") await mineToHeight(height + 1);
|
if (trade.getPayoutState() !== "PAYOUT_CONFIRMED") await mineToHeight(height + 1);
|
||||||
@ -2232,6 +2237,7 @@ async function testTradePayoutUnlock(ctx: TradeContext) {
|
|||||||
expect(payoutTx?.getIsConfirmed());
|
expect(payoutTx?.getIsConfirmed());
|
||||||
|
|
||||||
// test after payout unlocked
|
// test after payout unlocked
|
||||||
|
if (!ctx.testPayoutUnlocked) return;
|
||||||
trade = await ctx.arbitrator!.getTrade(ctx.offerId!);
|
trade = await ctx.arbitrator!.getTrade(ctx.offerId!);
|
||||||
if (trade.getPayoutState() !== "PAYOUT_UNLOCKED") await mineToHeight(height + 10);
|
if (trade.getPayoutState() !== "PAYOUT_UNLOCKED") await mineToHeight(height + 10);
|
||||||
await wait(TestConfig.maxWalletStartupMs + ctx.walletSyncPeriodMs! * 2);
|
await wait(TestConfig.maxWalletStartupMs + ctx.walletSyncPeriodMs! * 2);
|
||||||
|
Loading…
Reference in New Issue
Block a user