mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
more test updates
This commit is contained in:
parent
a3a772c92e
commit
2521866e92
@ -10,13 +10,13 @@ import datatokensTemplate from '@oceanprotocol/contracts/artifacts/DataTokenTemp
|
||||
const web3 = new Web3('http://127.0.0.1:8545')
|
||||
|
||||
describe('DataTokens', () => {
|
||||
let minter
|
||||
let spender
|
||||
let balance
|
||||
let contracts
|
||||
let datatoken
|
||||
let tokenAddress
|
||||
const tokenAmount = 100
|
||||
let minter: string
|
||||
let spender: string
|
||||
let balance: string
|
||||
let contracts: TestContractHandler
|
||||
let datatoken: DataTokens
|
||||
let tokenAddress: string
|
||||
const tokenAmount = '100'
|
||||
const blob = 'https://example.com/dataset-1'
|
||||
|
||||
describe('#test', () => {
|
||||
@ -52,18 +52,23 @@ describe('DataTokens', () => {
|
||||
it('should create datatokens with fallback cap, name & symbol', async () => {
|
||||
tokenAddress = await datatoken.create(blob, minter)
|
||||
assert(tokenAddress !== null)
|
||||
|
||||
const tokenName = await datatoken.getName(tokenAddress, minter)
|
||||
const tokenSymbol = await datatoken.getSymbol(tokenAddress, minter)
|
||||
assert(tokenName !== null || tokenName !== '')
|
||||
assert(tokenSymbol !== null || tokenSymbol !== '')
|
||||
})
|
||||
|
||||
it('should mint datatokens', async () => {
|
||||
await datatoken.mint(tokenAddress, minter, tokenAmount)
|
||||
balance = await datatoken.balance(tokenAddress, minter)
|
||||
assert(balance.toString() === tokenAmount.toString())
|
||||
assert(balance === tokenAmount)
|
||||
})
|
||||
|
||||
it('should transfer datatokens', async () => {
|
||||
await datatoken.transfer(tokenAddress, spender, tokenAmount, minter)
|
||||
balance = await datatoken.balance(tokenAddress, spender)
|
||||
assert(balance.toString() === tokenAmount.toString())
|
||||
assert(balance === tokenAmount)
|
||||
})
|
||||
|
||||
it('should approve datatokens transfer', async () => {
|
||||
@ -73,7 +78,7 @@ describe('DataTokens', () => {
|
||||
it('should transferFrom datatokens', async () => {
|
||||
await datatoken.transferFrom(tokenAddress, spender, tokenAmount, minter)
|
||||
balance = await datatoken.balance(tokenAddress, minter)
|
||||
assert(balance.toString() === tokenAmount.toString())
|
||||
assert(balance === tokenAmount)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -17,21 +17,22 @@ const web3 = new Web3('http://127.0.0.1:8545')
|
||||
describe('Balancer flow', () => {
|
||||
let oceanTokenAddress
|
||||
let OceanPoolFactoryAddress
|
||||
let Pool
|
||||
let oceandatatoken
|
||||
let Pool: OceanPool
|
||||
let oceandatatoken: DataTokens
|
||||
let alicePoolAddress
|
||||
let currentDtPrice
|
||||
let owner
|
||||
let bob
|
||||
let alice
|
||||
let contracts
|
||||
let datatoken
|
||||
let tokenAddress
|
||||
let owner: string
|
||||
let bob: string
|
||||
let alice: string
|
||||
let contracts: TestContractHandler
|
||||
let datatoken: DataTokens
|
||||
let tokenAddress: string
|
||||
let consoleDebug: false
|
||||
let greatPool
|
||||
const tokenAmount = '1000'
|
||||
const transferAmount = '200'
|
||||
const blob = 'http://localhost:8030/api/v1/services/consume'
|
||||
|
||||
describe('#test', () => {
|
||||
before(async () => {
|
||||
// deploy SFactory
|
||||
@ -74,7 +75,7 @@ describe('Balancer flow', () => {
|
||||
})
|
||||
|
||||
it('should create datatokens smart contract', async () => {
|
||||
tokenAddress = await datatoken.create(blob, 'AliceDT', 'DTA', '10000000000', alice)
|
||||
tokenAddress = await datatoken.create(blob, alice, '10000000000', 'AliceDT', 'DTA')
|
||||
assert(tokenAddress !== null)
|
||||
})
|
||||
it('Create a dummy OceanToken', async () => {
|
||||
@ -87,10 +88,10 @@ describe('Balancer flow', () => {
|
||||
)
|
||||
oceanTokenAddress = await oceandatatoken.create(
|
||||
blob,
|
||||
'AliceDT2',
|
||||
'DTA2',
|
||||
alice,
|
||||
'10000000000',
|
||||
alice
|
||||
'AliceDT2',
|
||||
'DTA2'
|
||||
)
|
||||
})
|
||||
it('should initialize OceanPool class', async () => {
|
||||
@ -137,19 +138,19 @@ describe('Balancer flow', () => {
|
||||
})
|
||||
it('Get dtToken pool reserve ', async () => {
|
||||
const currentDtReserve = await Pool.getDTReserve(alice, alicePoolAddress)
|
||||
assert(currentDtReserve > 0)
|
||||
assert(Number(currentDtReserve) > 0)
|
||||
})
|
||||
it('Get Ocean pool reserve ', async () => {
|
||||
const currentOceanReserve = await Pool.getOceanReserve(alice, alicePoolAddress)
|
||||
assert(currentOceanReserve > 0)
|
||||
assert(Number(currentOceanReserve) > 0)
|
||||
})
|
||||
it('Get total supply of pool tokens', async () => {
|
||||
const totalSupply = await Pool.totalSupply(alicePoolAddress)
|
||||
assert(totalSupply > 0)
|
||||
assert(Number(totalSupply) > 0)
|
||||
})
|
||||
it('Get amount of Ocean needed to buy 1 dtToken', async () => {
|
||||
const requiredOcean = await Pool.getOceanNeeded(alice, alicePoolAddress, '1')
|
||||
assert(requiredOcean > 0)
|
||||
assert(Number(requiredOcean) > 0)
|
||||
})
|
||||
|
||||
it('Bob should search for pools with this DT', async () => {
|
||||
@ -162,8 +163,8 @@ describe('Balancer flow', () => {
|
||||
await Pool.buyDT(bob, greatPool, '1', '2', String(maxPrice))
|
||||
const bobDtBalance = await datatoken.balance(tokenAddress, bob)
|
||||
const bobOceanBalance = await datatoken.balance(oceanTokenAddress, bob)
|
||||
assert(bobDtBalance > 0)
|
||||
assert(bobOceanBalance > 0)
|
||||
assert(Number(bobDtBalance) > 0)
|
||||
assert(Number(bobOceanBalance) > 0)
|
||||
})
|
||||
it('Bob should add DT liquidity to pool ', async () => {
|
||||
const currentDtReserve = await Pool.getDTReserve(bob, greatPool)
|
||||
|
Loading…
x
Reference in New Issue
Block a user