From 1372fc74efb671a447c6842e0d5a5e29872894f4 Mon Sep 17 00:00:00 2001 From: Ashwin Phatak Date: Tue, 10 Aug 2021 17:31:50 +0530 Subject: [PATCH] Test for entities after CollectEvent. (#202) Co-authored-by: prathamesh0 --- packages/uni-info-watcher/src/smoke.test.ts | 49 +++++++++++++++++++++ packages/uni-watcher/src/smoke.test.ts | 2 +- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/packages/uni-info-watcher/src/smoke.test.ts b/packages/uni-info-watcher/src/smoke.test.ts index 82cfbb3e..ceb6b97f 100644 --- a/packages/uni-info-watcher/src/smoke.test.ts +++ b/packages/uni-info-watcher/src/smoke.test.ts @@ -1022,4 +1022,53 @@ describe('uni-info-watcher', () => { expect(position.liquidity).to.be.equal(expectedLiquidity.toString()); }); }); + + xdescribe('CollectEvent', () => { + // Checked entities: Transaction. + // Unchecked entities: Position. + + let eventType: string; + + const tokenId = 1; + const amount0Max = 15; + const amount1Max = 15; + + it('should trigger CollectEvent', async () => { + // Position manger collect and wait for BurnEvent. + const transaction = nfpm.collect({ + tokenId, + recipient, + amount0Max, + amount1Max + }); + + eventType = 'BurnEvent'; + await Promise.all([ + transaction, + watchEvent(uniClient, eventType) + ]); + + // Wait for CollectEvent. + eventType = 'CollectEvent'; + await watchEvent(uniClient, eventType); + + // Sleeping for 10 sec for the events to be processed. + await wait(10000); + }); + + it('should create a Transaction entity', async () => { + // Checked values: mints, burns, swaps. + + const transaction: any = await fetchTransaction(endpoint); + + const expectedTxTimestamp = transaction.timestamp; + + expect(transaction.mints).to.be.empty; + expect(transaction.burns).to.not.be.empty; + expect(transaction.swaps).to.be.empty; + + const timestamp = transaction.burns[0].timestamp; + expect(timestamp).to.be.equal(expectedTxTimestamp); + }); + }); }); diff --git a/packages/uni-watcher/src/smoke.test.ts b/packages/uni-watcher/src/smoke.test.ts index a6f154a0..1d9bfb82 100644 --- a/packages/uni-watcher/src/smoke.test.ts +++ b/packages/uni-watcher/src/smoke.test.ts @@ -461,7 +461,7 @@ describe('uni-watcher', () => { } }); - // Position manger increase liquidity. + // Position manger collect. const transaction: ContractTransaction = await nfpm.collect({ tokenId, recipient,