mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
add test:integration
This commit is contained in:
parent
bce7c6c9d2
commit
5a1a660d49
@ -17,7 +17,8 @@
|
||||
"release": "release-it --non-interactive",
|
||||
"changelog": "auto-changelog -p",
|
||||
"prepublishOnly": "npm run build",
|
||||
"test": "mocha --opts test/unit/mocha.opts"
|
||||
"test": "mocha --opts test/unit/mocha.opts",
|
||||
"test:integration": "mocha --opts test/integration/mocha.opts"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
43
test/integration/Simpleflow.test.ts
Normal file
43
test/integration/Simpleflow.test.ts
Normal file
@ -0,0 +1,43 @@
|
||||
import { assert } from 'chai'
|
||||
import { TestContractHandler } from '../TestContractHandler'
|
||||
import { DataTokens } from '../../src/datatokens/Datatokens'
|
||||
|
||||
const Web3 = require('web3')
|
||||
const web3 = new Web3("http://127.0.0.1:8545")
|
||||
|
||||
const factoryABI = require('../../src/datatokens/FactoryABI.json')
|
||||
const datatokensABI = require('../../src/datatokens/DatatokensABI.json')
|
||||
|
||||
describe('Simple flow', () => {
|
||||
|
||||
let minter
|
||||
let spender
|
||||
let balance
|
||||
let contracts
|
||||
let datatoken
|
||||
let tokenAddress
|
||||
|
||||
let tokenAmount = 100
|
||||
let blob = 'https://example.com/dataset-1'
|
||||
|
||||
describe('#test', () => {
|
||||
it('should deploy contracts', async () => {
|
||||
contracts = new TestContractHandler(factoryABI,datatokensABI)
|
||||
await contracts.getAccounts()
|
||||
minter = contracts.accounts[0]
|
||||
spender = contracts.accounts[1]
|
||||
await contracts.deployContracts(minter)
|
||||
})
|
||||
|
||||
it('should create Datatoken object', async () => {
|
||||
datatoken = new DataTokens(contracts.factoryAddress, factoryABI, datatokensABI, web3)
|
||||
assert(datatoken !== null)
|
||||
})
|
||||
|
||||
it('should create Datatoken contract', async () => {
|
||||
tokenAddress = await datatoken.create(blob, minter)
|
||||
assert(tokenAddress !== null)
|
||||
})
|
||||
|
||||
})
|
||||
})
|
7
test/integration/mocha.opts
Normal file
7
test/integration/mocha.opts
Normal file
@ -0,0 +1,7 @@
|
||||
--require ts-node/register
|
||||
--require source-map-support/register
|
||||
--require mock-local-storage
|
||||
--full-trace
|
||||
--exit
|
||||
--timeout 300000
|
||||
test/integration/**/*.test.ts
|
@ -1,5 +1,5 @@
|
||||
import { assert } from 'chai'
|
||||
import { TestContractHandler } from './TestContractHandler'
|
||||
import { TestContractHandler } from '../TestContractHandler'
|
||||
import { DataTokens } from '../../src/datatokens/Datatokens'
|
||||
|
||||
const Web3 = require('web3')
|
||||
@ -49,7 +49,6 @@ describe('DataTokens', () => {
|
||||
await datatoken.transfer(tokenAddress, spender, tokenAmount, minter)
|
||||
balance = await datatoken.balance(tokenAddress, spender)
|
||||
assert(balance.toString() === tokenAmount.toString())
|
||||
|
||||
})
|
||||
|
||||
it('should approve Datatokens to spend', async () => {
|
||||
@ -61,6 +60,5 @@ describe('DataTokens', () => {
|
||||
minter = await datatoken.balance(tokenAddress, spender)
|
||||
assert(balance.toString() === tokenAmount.toString())
|
||||
})
|
||||
|
||||
})
|
||||
})
|
Loading…
x
Reference in New Issue
Block a user