diff --git a/src/Vault.test.ts b/src/Vault.test.ts index 444584c..24d6000 100644 --- a/src/Vault.test.ts +++ b/src/Vault.test.ts @@ -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' @@ -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 () => { diff --git a/src/tests/Centrifuge.test.ts b/src/tests/Centrifuge.test.ts index 81e05c6..23617d5 100644 --- a/src/tests/Centrifuge.test.ts +++ b/src/tests/Centrifuge.test.ts @@ -15,6 +15,7 @@ describe('Centrifuge', () => { afterEach(() => { clock.restore() + sinon.restore() }) it('should be connected to sepolia', async () => { @@ -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', () => {