-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test the role field of Trades #297
Conversation
Instead of adding a new test for this specific scenario, better to call getTrades() after the offer is taken in |
A problem happens, because |
src/HavenoClient.test.ts
Outdated
@@ -2816,6 +2821,7 @@ async function takeOffer(ctxP: Partial<TradeContext>): Promise<TradeInfo> { | |||
} | |||
|
|||
// test trade model | |||
HavenoUtils.log(0, "TradeInfo received from havenod.takeOffer: " + trade.getShortId() + " role: " + trade.getRole()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for comment.
src/HavenoClient.test.ts
Outdated
@@ -2877,6 +2883,13 @@ async function testTrade(trade: TradeInfo, ctx: TradeContext) { | |||
expect(BigInt(trade.getBuyerSecurityDeposit())).toEqual(expectedSecurityDeposit - ctx.getBuyer().depositTxFee); | |||
expect(BigInt(trade.getSellerSecurityDeposit())).toEqual(expectedSecurityDeposit - ctx.getSeller().depositTxFee); | |||
|
|||
HavenoUtils.log(0, "Trade: " + trade.getShortId() + " role: " + trade.getRole()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for comment.
src/HavenoClient.test.ts
Outdated
@@ -2600,6 +2600,11 @@ async function executeTrade(ctxP: Partial<TradeContext>): Promise<string> { | |||
ctx.taker.balancesAfterPayout = await ctx.taker.havenod?.getBalances(); | |||
} | |||
|
|||
const trades = (await user1.getTrades()).concat(await user2.getTrades()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove this here, and here in takeOffer:
- Get user1 trades, assert the trade is contained by id, and call testTrade() on each.
- Get user2 trades, assert the trade is contained by id, and call testTrade() on each.
Sorry I missed this. Sounds like the returned |
#301 opened as an alternative and I added you as a co-author. This API addition and test refactoring was a little tricker than expected. |
Ref: Missing trade role from getTrades() API haveno-dex/haveno#1146
Ref: Apply trade role to getTrades result haveno-dex/haveno#1147
Test with/without fix: