mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
test tweaks
This commit is contained in:
parent
6f85014e00
commit
455983f7b6
@ -26,10 +26,8 @@ before_script:
|
|||||||
- sleep 300
|
- sleep 300
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- npm run lint
|
- npm test
|
||||||
- npm run build
|
- npm run build
|
||||||
- npm run test:unit:cover
|
|
||||||
- npm run test:integration:cover
|
|
||||||
|
|
||||||
after_script:
|
after_script:
|
||||||
- ./cc-test-reporter format-coverage -t lcov -o coverage/codeclimate.unit.json coverage/unit/lcov.info # Format unit test coverage
|
- ./cc-test-reporter format-coverage -t lcov -o coverage/codeclimate.unit.json coverage/unit/lcov.info # Format unit test coverage
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
"test:unit": "mocha --config=test/unit/.mocharc.json --node-env=test --exit 'test/unit/**/*.test.ts'",
|
"test:unit": "mocha --config=test/unit/.mocharc.json --node-env=test --exit 'test/unit/**/*.test.ts'",
|
||||||
"test:unit:cover": "nyc --report-dir coverage/unit npm run test:unit",
|
"test:unit:cover": "nyc --report-dir coverage/unit npm run test:unit",
|
||||||
"test:integration": "mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/**/*.test.ts'",
|
"test:integration": "mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/**/*.test.ts'",
|
||||||
"test:integration:cover": "nyc --report-dir coverage/integration npm run test:integration"
|
"test:integration:cover": "nyc --report-dir coverage/integration --no-clean npm run test:integration"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -26,8 +26,9 @@ export class BalancerContractHandler {
|
|||||||
this.poolBytecode = poolBytecode
|
this.poolBytecode = poolBytecode
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getAccounts() {
|
public async getAccounts(): Promise<string[]> {
|
||||||
this.accounts = await this.web3.eth.getAccounts()
|
this.accounts = await this.web3.eth.getAccounts()
|
||||||
|
return this.accounts
|
||||||
}
|
}
|
||||||
|
|
||||||
public async deployContracts(minter: string) {
|
public async deployContracts(minter: string) {
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import Web3 from 'web3'
|
import Web3 from 'web3'
|
||||||
import { Contract } from 'web3-eth-contract'
|
import { Contract } from 'web3-eth-contract'
|
||||||
import { AbiItem } from 'web3-utils/types'
|
import { AbiItem } from 'web3-utils/types'
|
||||||
|
|
||||||
const communityCollector = '0xeE9300b7961e0a01d9f0adb863C7A227A07AaD75'
|
const communityCollector = '0xeE9300b7961e0a01d9f0adb863C7A227A07AaD75'
|
||||||
|
|
||||||
export class TestContractHandler {
|
export class TestContractHandler {
|
||||||
public factory: Contract
|
public factory: Contract
|
||||||
public template: Contract
|
public template: Contract
|
||||||
@ -26,8 +28,9 @@ export class TestContractHandler {
|
|||||||
this.factoryBytecode = factoryBytecode
|
this.factoryBytecode = factoryBytecode
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getAccounts() {
|
public async getAccounts(): Promise<string[]> {
|
||||||
this.accounts = await this.web3.eth.getAccounts()
|
this.accounts = await this.web3.eth.getAccounts()
|
||||||
|
return this.accounts
|
||||||
}
|
}
|
||||||
|
|
||||||
public async deployContracts(minter: string) {
|
public async deployContracts(minter: string) {
|
||||||
|
@ -53,7 +53,6 @@ describe('Compute flow', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('#MarketplaceComputeFlow-Test', () => {
|
|
||||||
it('Initialize Ocean contracts v3', async () => {
|
it('Initialize Ocean contracts v3', async () => {
|
||||||
contracts = new TestContractHandler(
|
contracts = new TestContractHandler(
|
||||||
factory.abi as AbiItem[],
|
factory.abi as AbiItem[],
|
||||||
@ -114,10 +113,7 @@ describe('Compute flow', () => {
|
|||||||
|
|
||||||
it('Alice publishes dataset with a compute service that allows Raw Algo', async () => {
|
it('Alice publishes dataset with a compute service that allows Raw Algo', async () => {
|
||||||
price = datatoken.toWei('2') // in datatoken
|
price = datatoken.toWei('2') // in datatoken
|
||||||
cluster = ocean.compute.createClusterAttributes(
|
cluster = ocean.compute.createClusterAttributes('Kubernetes', 'http://10.0.0.17/xxx')
|
||||||
'Kubernetes',
|
|
||||||
'http://10.0.0.17/xxx'
|
|
||||||
)
|
|
||||||
servers = [
|
servers = [
|
||||||
ocean.compute.createServerAttributes(
|
ocean.compute.createServerAttributes(
|
||||||
'1',
|
'1',
|
||||||
@ -241,12 +237,7 @@ describe('Compute flow', () => {
|
|||||||
dateCreated,
|
dateCreated,
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
algorithmAsset = await ocean.assets.create(
|
algorithmAsset = await ocean.assets.create(algoAsset, alice, [service1], tokenAddress)
|
||||||
algoAsset,
|
|
||||||
alice,
|
|
||||||
[service1],
|
|
||||||
tokenAddress
|
|
||||||
)
|
|
||||||
assert(algorithmAsset.dataToken === tokenAddress)
|
assert(algorithmAsset.dataToken === tokenAddress)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -389,4 +380,3 @@ describe('Compute flow', () => {
|
|||||||
// it('Bob restarts compute job', async () => {})
|
// it('Bob restarts compute job', async () => {})
|
||||||
// it('Bob gets outputs', async () => {})
|
// it('Bob gets outputs', async () => {})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
@ -30,7 +30,6 @@ describe('Marketplace flow', () => {
|
|||||||
const marketplaceAllowance = '20'
|
const marketplaceAllowance = '20'
|
||||||
const tokenAmount = '100'
|
const tokenAmount = '100'
|
||||||
|
|
||||||
describe('#MarketplaceDownloadFlow-Test', () => {
|
|
||||||
it('Initialize Ocean contracts v3', async () => {
|
it('Initialize Ocean contracts v3', async () => {
|
||||||
contracts = new TestContractHandler(
|
contracts = new TestContractHandler(
|
||||||
factory.abi as AbiItem[],
|
factory.abi as AbiItem[],
|
||||||
@ -186,4 +185,3 @@ describe('Marketplace flow', () => {
|
|||||||
assert(assets.length > 0)
|
assert(assets.length > 0)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
import { TestContractHandler } from '../TestContractHandler'
|
|
||||||
import { DataTokens } from '../../src/datatokens/Datatokens'
|
|
||||||
|
|
||||||
import Web3 from 'web3'
|
|
||||||
import factory from '@oceanprotocol/contracts/artifacts/DTFactory.json'
|
|
||||||
import datatokensTemplate from '@oceanprotocol/contracts/artifacts/DataTokenTemplate.json'
|
|
||||||
const web3 = new Web3('wss://rinkeby.infura.io/ws/v3/357f2fe737db4304bd2f7285c5602d0d')
|
|
||||||
|
|
||||||
describe('Rinkeby test', () => {
|
|
||||||
// let account
|
|
||||||
// let contracts
|
|
||||||
// let datatoken
|
|
||||||
// let tokenAddress
|
|
||||||
// const tokenAmount = 100
|
|
||||||
// const blob = 'http://localhost:8030/api/v1/provider/services'
|
|
||||||
// describe('#test', () => {
|
|
||||||
// it('Initialize Ocean contracts v3', async () => {
|
|
||||||
// contracts = new TestContractHandler(
|
|
||||||
// factory.abi,
|
|
||||||
// datatokensTemplate.abi,
|
|
||||||
// datatokensTemplate.bytecode,
|
|
||||||
// factory.bytecode,
|
|
||||||
// web3
|
|
||||||
// )
|
|
||||||
// const privateKey = 'PRIVATE_KEY'
|
|
||||||
// account = web3.eth.accounts.privateKeyToAccount('0x' + privateKey)
|
|
||||||
// web3.eth.accounts.wallet.add(account)
|
|
||||||
// await contracts.deployContracts(account.address)
|
|
||||||
// })
|
|
||||||
// it('Publish a dataset', async () => {
|
|
||||||
// datatoken = new DataTokens(
|
|
||||||
// contracts.factoryAddress,
|
|
||||||
// factory.abi,
|
|
||||||
// datatokensTemplate.abi,
|
|
||||||
// web3
|
|
||||||
// )
|
|
||||||
// tokenAddress = await datatoken.create(blob, account.address)
|
|
||||||
// })
|
|
||||||
// it('Mint 100 tokens', async () => {
|
|
||||||
// await datatoken.mint(tokenAddress, account.address, tokenAmount)
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
})
|
|
@ -18,7 +18,7 @@ describe('Simple flow', () => {
|
|||||||
const tokenAmount = '100'
|
const tokenAmount = '100'
|
||||||
const transferAmount = '1'
|
const transferAmount = '1'
|
||||||
const blob = 'http://localhost:8030/api/v1/services/consume'
|
const blob = 'http://localhost:8030/api/v1/services/consume'
|
||||||
describe('#test', () => {
|
|
||||||
it('Initialize Ocean contracts v3', async () => {
|
it('Initialize Ocean contracts v3', async () => {
|
||||||
contracts = new TestContractHandler(
|
contracts = new TestContractHandler(
|
||||||
factory.abi as AbiItem[],
|
factory.abi as AbiItem[],
|
||||||
@ -56,4 +56,3 @@ describe('Simple flow', () => {
|
|||||||
// await ocean.assets.simpleDownload(tokenAddress, blob, transactionId, bob)
|
// await ocean.assets.simpleDownload(tokenAddress, blob, transactionId, bob)
|
||||||
// })
|
// })
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
@ -19,7 +19,6 @@ describe('DataTokens', () => {
|
|||||||
const tokenAmount = '100'
|
const tokenAmount = '100'
|
||||||
const blob = 'https://example.com/dataset-1'
|
const blob = 'https://example.com/dataset-1'
|
||||||
|
|
||||||
describe('#test', () => {
|
|
||||||
it('should deploy contracts', async () => {
|
it('should deploy contracts', async () => {
|
||||||
contracts = new TestContractHandler(
|
contracts = new TestContractHandler(
|
||||||
factory.abi as AbiItem[],
|
factory.abi as AbiItem[],
|
||||||
@ -81,4 +80,3 @@ describe('DataTokens', () => {
|
|||||||
assert(balance === tokenAmount)
|
assert(balance === tokenAmount)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
@ -155,7 +155,7 @@ describe('Balancer flow', () => {
|
|||||||
|
|
||||||
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(Number(currentDtPrice) > 0)
|
||||||
})
|
})
|
||||||
it('Get dtToken pool reserve ', async () => {
|
it('Get dtToken pool reserve ', async () => {
|
||||||
const currentDtReserve = await Pool.getDTReserve(alice, alicePoolAddress)
|
const currentDtReserve = await Pool.getDTReserve(alice, alicePoolAddress)
|
||||||
|
@ -23,7 +23,7 @@ describe('FixedRateExchange flow', () => {
|
|||||||
let datatoken: DataTokens
|
let datatoken: DataTokens
|
||||||
let tokenAddress: string
|
let tokenAddress: string
|
||||||
|
|
||||||
let owner
|
let owner: string
|
||||||
let contracts: TestContractHandler
|
let contracts: TestContractHandler
|
||||||
|
|
||||||
const consoleDebug = false
|
const consoleDebug = false
|
||||||
@ -33,7 +33,6 @@ describe('FixedRateExchange flow', () => {
|
|||||||
const swapAmount = '1'
|
const swapAmount = '1'
|
||||||
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 Contracts = new FixedPricedContractHandler(
|
const Contracts = new FixedPricedContractHandler(
|
||||||
@ -181,10 +180,7 @@ describe('FixedRateExchange flow', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('Bob should get the amount of Ocean needed', async () => {
|
it('Bob should get the amount of Ocean needed', async () => {
|
||||||
const OceansNeeded = await FixedRateClass.CalcInGivenOut(
|
const OceansNeeded = await FixedRateClass.CalcInGivenOut(aliceExchangeId, swapAmount)
|
||||||
aliceExchangeId,
|
|
||||||
swapAmount
|
|
||||||
)
|
|
||||||
if (consoleDebug) console.log('Oceans needed:' + OceansNeeded)
|
if (consoleDebug) console.log('Oceans needed:' + OceansNeeded)
|
||||||
assert(OceansNeeded !== null)
|
assert(OceansNeeded !== null)
|
||||||
})
|
})
|
||||||
@ -226,4 +222,3 @@ describe('FixedRateExchange flow', () => {
|
|||||||
assert(exchangeDetails.active === true)
|
assert(exchangeDetails.active === true)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user