Skip to content

Commit

Permalink
test that peer sees offer added and removed
Browse files Browse the repository at this point in the history
  • Loading branch information
woodser committed Jul 11, 2024
1 parent 84f2895 commit 530fee6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/HavenoClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1414,6 +1414,10 @@ test("Can post and remove an offer (CI, sanity check)", async () => {
// offer is removed from my offers
if (getOffer(await user1.getMyOffers(assetCode, OfferDirection.BUY), offer.getId())) throw new Error("Offer " + offer.getId() + " was found in my offers after removal");

// peer does not see offer
await wait(TestConfig.trade.maxTimePeerNoticeMs);
if (getOffer(await user2.getOffers(assetCode, TestConfig.trade.direction), offer.getId())) throw new Error("Offer " + offer.getId() + " was found in peer's offers after removed");

// reserved balance released
expect(BigInt((await user1.getBalances()).getAvailableBalance())).toEqual(availableBalanceBefore);

Expand All @@ -1430,6 +1434,10 @@ test("Can post and remove an offer (CI, sanity check)", async () => {
offer = await user1.getMyOffer(offer.getId());
assert.equal(offer.getState(), "AVAILABLE");

// peer sees offer
await wait(TestConfig.trade.maxTimePeerNoticeMs);
if (!getOffer(await user2.getOffers(assetCode, TestConfig.trade.direction), offer.getId())) throw new Error("Offer " + offer.getId() + " was not found in peer's offers after posted");

// cancel offer
await user1.removeOffer(offer.getId());

Expand All @@ -1438,6 +1446,10 @@ test("Can post and remove an offer (CI, sanity check)", async () => {

// reserved balance released
expect(BigInt((await user1.getBalances()).getAvailableBalance())).toEqual(availableBalanceBefore);

// peer does not see offer
await wait(TestConfig.trade.maxTimePeerNoticeMs);
if (getOffer(await user2.getOffers(assetCode, TestConfig.trade.direction), offer.getId())) throw new Error("Offer " + offer.getId() + " was found in peer's offers after removed");
});

// TODO: provide number of confirmations in offer status
Expand Down

0 comments on commit 530fee6

Please sign in to comment.