Skip to content

Commit

Permalink
fix test (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
onnovisser authored Dec 3, 2024
1 parent 6a31f46 commit 47ae92c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
9 changes: 0 additions & 9 deletions src/Vault.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { expect } from 'chai'
import { firstValueFrom, lastValueFrom, skip, skipWhile, tap, toArray } from 'rxjs'
import sinon from 'sinon'
import { ABI } from './abi/index.js'
import { Pool } from './Pool.js'
import { PoolNetwork } from './PoolNetwork.js'
Expand Down Expand Up @@ -32,17 +31,9 @@ describe('Vault', () => {
vault = new Vault(centrifuge, poolNetwork, trancheId, asset, vaultAddress)
})

afterEach(() => {
sinon.restore()
})

it('get investment details for an investor', async () => {
const fetchSpy = sinon.spy(globalThis, 'fetch')
const investment = await vault.investment(investorA)
expect(investment.isAllowedToInvest).to.equal(true)
// Calls should get batched
// TODO @Onno
expect(fetchSpy.getCalls().length).to.equal(6)
})

it("should throw when placing an invest order larger than the users's balance", async () => {
Expand Down
11 changes: 11 additions & 0 deletions src/tests/Centrifuge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe('Centrifuge', () => {

afterEach(() => {
clock.restore()
sinon.restore()
})

it('should be connected to sepolia', async () => {
Expand Down Expand Up @@ -213,6 +214,16 @@ describe('Centrifuge', () => {
expect(lastValue).to.equal('2-A')
subscription1.unsubscribe()
})

it('should batch calls', async () => {
const fetchSpy = sinon.spy(globalThis, 'fetch')
const centrifuge = new Centrifuge({ environment: 'demo' })
const tUSD = '0x8503b4452Bf6238cC76CdbEE223b46d7196b1c93'
const user = '0x423420Ae467df6e90291fd0252c0A8a637C1e03f'
await centrifuge.balance(tUSD, user)
// One call to get the metadata, one to get the balance, and one to poll events
expect(fetchSpy.getCalls().length).to.equal(3)
})
})

describe('Transactions', () => {
Expand Down

0 comments on commit 47ae92c

Please sign in to comment.