1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

more pool tests

This commit is contained in:
Matthias Kretschmann 2020-09-08 16:51:03 +02:00
parent 7456360d00
commit 6f85014e00
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -15,12 +15,12 @@ import OceanSPool from '@oceanprotocol/contracts/artifacts/BPool.json'
const web3 = new Web3('http://127.0.0.1:8545') const web3 = new Web3('http://127.0.0.1:8545')
describe('Balancer flow', () => { describe('Balancer flow', () => {
let oceanTokenAddress let oceanTokenAddress: string
let OceanPoolFactoryAddress let OceanPoolFactoryAddress: string
let Pool: OceanPool let Pool: OceanPool
let oceandatatoken: DataTokens let oceandatatoken: DataTokens
let alicePoolAddress let alicePoolAddress: string
let currentDtPrice let currentDtPrice: string
let owner: string let owner: string
let bob: string let bob: string
let alice: string let alice: string
@ -28,12 +28,11 @@ describe('Balancer flow', () => {
let datatoken: DataTokens let datatoken: DataTokens
let tokenAddress: string let tokenAddress: string
let consoleDebug: false let consoleDebug: false
let greatPool let greatPool: string
const tokenAmount = '1000' const tokenAmount = '1000'
const transferAmount = '200' const transferAmount = '200'
const blob = 'http://localhost:8030/api/v1/services/consume' const blob = 'http://localhost:8030/api/v1/services/consume'
describe('#test', () => {
before(async () => { before(async () => {
// deploy SFactory // deploy SFactory
const SContracts = new BalancerContractHandler( const SContracts = new BalancerContractHandler(
@ -128,10 +127,32 @@ describe('Balancer flow', () => {
assert(currentTokens.includes(tokenAddress)) assert(currentTokens.includes(tokenAddress))
assert(currentTokens.includes(oceanTokenAddress)) assert(currentTokens.includes(oceanTokenAddress))
}) })
it('Get pool swap fee', async () => { it('Get pool swap fee', async () => {
const currentSwapFee = await Pool.getSwapFee(alice, alicePoolAddress) const currentSwapFee = await Pool.getSwapFee(alice, alicePoolAddress)
assert(currentSwapFee === '0.02') assert(currentSwapFee === '0.02')
}) })
it('Get spot price for swapping', async () => {
const spotPrice = await Pool.getSpotPrice(
alice,
alicePoolAddress,
tokenAddress,
oceanTokenAddress
)
assert(Number(spotPrice) > 0)
})
it('Get spot price for swapping without fees', async () => {
const spotPrice = await Pool.getSpotPriceSansFee(
alice,
alicePoolAddress,
tokenAddress,
oceanTokenAddress
)
assert(Number(spotPrice) > 0)
})
it('Get dtPrice from the pool ', async () => { it('Get dtPrice from the pool ', async () => {
currentDtPrice = await Pool.getDTPrice(alice, alicePoolAddress) currentDtPrice = await Pool.getDTPrice(alice, alicePoolAddress)
assert(currentDtPrice > 0) assert(currentDtPrice > 0)
@ -249,5 +270,4 @@ describe('Balancer flow', () => {
assert(parseFloat(bobDtBalance) < parseFloat(newbobDtBalance)) assert(parseFloat(bobDtBalance) < parseFloat(newbobDtBalance))
assert(parseFloat(poolShares) > parseFloat(newpoolShares)) assert(parseFloat(poolShares) > parseFloat(newpoolShares))
}) })
})
}) })