Skip to content

Commit

Permalink
more test updates
Browse files Browse the repository at this point in the history
  • Loading branch information
kremalicious committed Sep 3, 2020
1 parent a3a772c commit 2521866
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 28 deletions.
25 changes: 15 additions & 10 deletions test/unit/Datatokens.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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 () => {
Expand All @@ -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)
})
})
})
37 changes: 19 additions & 18 deletions test/unit/balancer/Balancer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 () => {
Expand All @@ -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 () => {
Expand Down Expand Up @@ -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 () => {
Expand All @@ -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)
Expand Down

0 comments on commit 2521866

Please sign in to comment.