Skip to content

Commit

Permalink
test: Ensure distribution and logs tests are passing.
Browse files Browse the repository at this point in the history
  • Loading branch information
maxencerb committed May 22, 2024
1 parent a9acd22 commit aaddab6
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lib/kandel/distribution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ describe('distribution', () => {
],
})

expect(distrib.asks.length).toEqual(fromChain.asks.length)
expect(distrib.bids.length).toEqual(fromChain.bids.length)

for (let i = 0; i < distrib.asks.length; i++) {
expect(distrib.asks[i].gives).toEqual(fromChain.asks[i].gives)
expect(distrib.asks[i].tick).toEqual(fromChain.asks[i].tick)
Expand Down
32 changes: 32 additions & 0 deletions src/lib/kandel/logs.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { inject, describe, it, expect } from 'vitest'
import { simulateSow } from '~mgv/actions/kandel/sow.js'
import { getClient } from '~test/src/client.js'
import { getKandelsFromLogs } from './logs.js'
import { hash } from '../ol-key.js'
import { isAddress } from 'viem'

const { smartKandelSeeder } = inject('kandel')
const { wethUSDC } = inject('markets')
const client = getClient()

describe('Kandel logs', () => {
it('get smart kandel from logs', async () => {
const { request } = await simulateSow(client, wethUSDC, smartKandelSeeder)
const tx = await client.writeContract(request)
const receipt = await client.waitForTransactionReceipt({
hash: tx,
})
const result = getKandelsFromLogs(receipt.logs)
expect(result.length).toEqual(1)
expect(result[0].type).toEqual('SmartKandel')
expect(result[0].owner).toAddressEqual(client.account.address)
expect(result[0].baseQuoteOlKeyHash).toEqual(
hash({
outbound_tkn: wethUSDC.base.address,
inbound_tkn: wethUSDC.quote.address,
tickSpacing: wethUSDC.tickSpacing,
}),
)
expect(isAddress(result[0].address))
})
})

0 comments on commit aaddab6

Please sign in to comment.