Skip to content

Commit

Permalink
WIP: compositeswap tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shohamc1 committed Nov 10, 2022
1 parent 210806d commit 471faee
Showing 1 changed file with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -594,4 +594,60 @@ describe('compositeSwap', () => {
await expect(promise).rejects.toThrow(RpcApiError)
await expect(promise).rejects.toThrow('TokenTo was not found')
})

it('should not compositeSwap for more than 3 pools', async () => {
await testing.generate(20)
const [toAddress, fromAddress] = await testing.generateAddress(2)
await testing.token.create({ symbol: 'T1' })
await testing.token.create({ symbol: 'T2' })
await testing.token.create({ symbol: 'T3' })
await testing.token.create({ symbol: 'T4' })
await testing.token.create({ symbol: 'T5' })
await testing.generate(1)

await testing.token.mint({ symbol: 'T1', amount: 20 })
await testing.token.mint({ symbol: 'T2', amount: 20 })
await testing.token.mint({ symbol: 'T3', amount: 20 })
await testing.token.mint({ symbol: 'T4', amount: 20 })
await testing.token.mint({ symbol: 'T5', amount: 10 })
await testing.generate(1)

await testing.poolpair.create({ tokenA: 'T1', tokenB: 'T2' })
await testing.poolpair.create({ tokenA: 'T2', tokenB: 'T3' })
await testing.poolpair.create({ tokenA: 'T3', tokenB: 'T4' })
await testing.poolpair.create({ tokenA: 'T4', tokenB: 'T5' })
await testing.generate(1)

await testing.poolpair.add({
a: { symbol: 'T1', amount: 10 },
b: { symbol: 'T2', amount: 10 }
})
await testing.poolpair.add({
a: { symbol: 'T2', amount: 10 },
b: { symbol: 'T3', amount: 10 }
})
await testing.poolpair.add({
a: { symbol: 'T3', amount: 10 },
b: { symbol: 'T4', amount: 10 }
})
await testing.poolpair.add({
a: { symbol: 'T4', amount: 10 },
b: { symbol: 'T5', amount: 10 }
})
await testing.generate(1)

await testing.token.send({ symbol: 'T1', amount: 1, address: fromAddress })
await testing.generate(1)

const metadata: poolpair.PoolSwapMetadata = {
from: fromAddress,
tokenFrom: 'T1',
amountFrom: 1,
to: toAddress,
tokenTo: 'T5',
maxPrice: 1
}

await client.poolpair.testPoolSwap(metadata)
})
})

0 comments on commit 471faee

Please sign in to comment.