mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
Revert "use balance() function from library"
This reverts commit b6894100a820e603273594b311f9fd37af3a5404.
This commit is contained in:
parent
2de5418899
commit
9ff8b977e6
@ -1,9 +1,11 @@
|
||||
import { assert, expect } from 'chai'
|
||||
import { AbiItem } from 'web3-utils/types'
|
||||
import { deployContracts, Addresses } from '../../TestContractHandler'
|
||||
import ERC721Factory from '@oceanprotocol/contracts/artifacts/contracts/ERC721Factory.sol/ERC721Factory.json'
|
||||
import ERC20Template from '@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.json'
|
||||
import MockERC20 from '@oceanprotocol/contracts/artifacts/contracts/utils/mock/MockERC20Decimals.sol/MockERC20Decimals.json'
|
||||
import { web3 } from '../../config'
|
||||
import { NftFactory, NftCreateData, balance } from '../../../src'
|
||||
import { NftFactory, NftCreateData } from '../../../src'
|
||||
import { Router } from '../../../src/pools/Router'
|
||||
import { Erc20CreateParams, PoolCreationParams, Operation } from '../../../src/@types'
|
||||
|
||||
@ -112,7 +114,11 @@ describe('Router unit test', () => {
|
||||
swapFeeMarketRunner: '0.001'
|
||||
}
|
||||
|
||||
const nftFactory = new NftFactory(contracts.erc721FactoryAddress, web3)
|
||||
const nftFactory = new NftFactory(
|
||||
contracts.erc721FactoryAddress,
|
||||
web3,
|
||||
ERC721Factory.abi as AbiItem[]
|
||||
)
|
||||
|
||||
const txReceipt = await nftFactory.createNftErc20WithPool(
|
||||
factoryOwner,
|
||||
@ -121,7 +127,7 @@ describe('Router unit test', () => {
|
||||
poolParams
|
||||
)
|
||||
|
||||
const erc20TokenAddress = txReceipt.events.TokenCreated.returnValues.newTokenAddress
|
||||
const erc20Token = txReceipt.events.TokenCreated.returnValues.newTokenAddress
|
||||
const pool1 = txReceipt.events.NewPool.returnValues.poolAddress
|
||||
|
||||
// CREATE A SECOND POOL
|
||||
@ -168,13 +174,22 @@ describe('Router unit test', () => {
|
||||
poolParams2
|
||||
)
|
||||
|
||||
const erc20Token2Address = txReceipt2.events.TokenCreated.returnValues.newTokenAddress
|
||||
const erc20Token2 = txReceipt2.events.TokenCreated.returnValues.newTokenAddress
|
||||
const pool2 = txReceipt2.events.NewPool.returnValues.poolAddress
|
||||
|
||||
const erc20Contract = new web3.eth.Contract(
|
||||
ERC20Template.abi as AbiItem[],
|
||||
erc20Token
|
||||
)
|
||||
// user1 has no dt1
|
||||
expect(await balance(web3, erc20TokenAddress, user1)).to.equal('0')
|
||||
expect(await erc20Contract.methods.balanceOf(user1).call()).to.equal('0')
|
||||
|
||||
const erc20Contract2 = new web3.eth.Contract(
|
||||
ERC20Template.abi as AbiItem[],
|
||||
erc20Token2
|
||||
)
|
||||
// user1 has no dt2
|
||||
expect(await balance(web3, erc20Token2Address, user1)).to.equal('0')
|
||||
expect(await erc20Contract2.methods.balanceOf(user1).call()).to.equal('0')
|
||||
|
||||
// we now can prepare the Operations objects
|
||||
|
||||
@ -188,7 +203,7 @@ describe('Router unit test', () => {
|
||||
operation: 0, // swapExactAmountIn
|
||||
tokenIn: contracts.daiAddress,
|
||||
amountsIn: web3.utils.toWei('1'), // when swapExactAmountIn is EXACT amount IN
|
||||
tokenOut: erc20TokenAddress,
|
||||
tokenOut: erc20Token,
|
||||
amountsOut: web3.utils.toWei('0.1'), // when swapExactAmountIn is MIN amount OUT
|
||||
maxPrice: web3.utils.toWei('10'), // max price (only for pools),
|
||||
swapMarketFee: web3.utils.toWei('0.1'),
|
||||
@ -201,7 +216,7 @@ describe('Router unit test', () => {
|
||||
operation: 0, // swapExactAmountIn
|
||||
tokenIn: contracts.daiAddress,
|
||||
amountsIn: web3.utils.toWei('1'), // when swapExactAmountIn is EXACT amount IN
|
||||
tokenOut: erc20Token2Address,
|
||||
tokenOut: erc20Token2,
|
||||
amountsOut: web3.utils.toWei('0.1'), // when swapExactAmountIn is MIN amount OUT
|
||||
maxPrice: web3.utils.toWei('10'), // max price (only for pools)
|
||||
swapMarketFee: web3.utils.toWei('0.1'),
|
||||
@ -211,7 +226,7 @@ describe('Router unit test', () => {
|
||||
await router.buyDTBatch(user1, [operations1, operations2])
|
||||
|
||||
// user1 got his dts
|
||||
expect(await balance(web3, erc20TokenAddress, user1)).gt(0)
|
||||
expect(await balance(web3, erc20Token2Address, user1)).gt(0)
|
||||
expect(parseInt(await erc20Contract.methods.balanceOf(user1).call())).gt(0)
|
||||
expect(parseInt(await erc20Contract2.methods.balanceOf(user1).call())).gt(0)
|
||||
})
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user