From 1cc4dd5c3d72b4b6676ecd118e874b02b5846d0b Mon Sep 17 00:00:00 2001 From: woodser <13068859+woodser@users.noreply.github.com> Date: Tue, 3 Jun 2025 21:52:11 -0400 Subject: [PATCH] fix clone offer test after stricter validation --- src/HavenoClient.test.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/HavenoClient.test.ts b/src/HavenoClient.test.ts index a7a87875..8b94bc07 100644 --- a/src/HavenoClient.test.ts +++ b/src/HavenoClient.test.ts @@ -1564,8 +1564,8 @@ test("Can clone offers (Test, CI, sanity check)", async () => { // post offer let assetCode = "BCH"; - let ctx: Partial = {maker: {havenod: user1}, isPrivateOffer: true, buyerAsTakerWithoutDeposit: true, assetCode: assetCode, extraInfo: "My extra info"}; - let offer: OfferInfo = await makeOffer(ctx);; + let ctx: Partial = {maker: {havenod: user1}, direction: OfferDirection.SELL, isPrivateOffer: true, buyerAsTakerWithoutDeposit: true, assetCode: assetCode, extraInfo: "My extra info"}; + let offer: OfferInfo = await makeOffer(ctx); assert.equal(offer.getState(), "AVAILABLE"); // clone offer @@ -2962,6 +2962,14 @@ async function makeOffer(ctxP?: Partial): Promise { ctx.taker.balancesBeforeOffer = await ctx.taker.havenod?.getBalances(); } + // transfer context from clone source + if (ctx.sourceOfferId) { + const sourceOffer = await ctx.maker.havenod!.getMyOffer(ctx.sourceOfferId); + ctx.isPrivateOffer = sourceOffer.getIsPrivateOffer(); + ctx.direction = sourceOffer.getDirection() == "BUY" ? OfferDirection.BUY : OfferDirection.SELL; + ctx.buyerAsTakerWithoutDeposit = ctx.isPrivateOffer && ctx.direction === OfferDirection.SELL && sourceOffer.getBuyerSecurityDepositPct() === 0; + } + // post or clone offer const offer: OfferInfo = await ctx.maker.havenod!.postOffer({ direction: ctx.direction, @@ -2980,11 +2988,6 @@ async function makeOffer(ctxP?: Partial): Promise { sourceOfferId: ctx.sourceOfferId }); - // transfer context from clone source - if (ctx.sourceOfferId) { - const sourceOffer = await ctx.maker.havenod!.getMyOffer(ctx.sourceOfferId); - ctx.isPrivateOffer = sourceOffer.getIsPrivateOffer(); - } // test offer testOffer(offer, ctx, true);