From 68f435a11d9016dca92d5da6d0d3de4df796e3a3 Mon Sep 17 00:00:00 2001 From: arsenyjin Date: Mon, 22 Jun 2020 08:59:02 +0200 Subject: [PATCH] add rinkeby test --- test/TestContractHandler.ts | 14 ++++++------- test/integration/Marketplaceflow.test.ts | 5 +++-- test/integration/Rinkeby.test.ts | 25 ++++++++++++++++++++++++ test/integration/Simpleflow.test.ts | 3 ++- 4 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 test/integration/Rinkeby.test.ts diff --git a/test/TestContractHandler.ts b/test/TestContractHandler.ts index f6484dd9..e2041832 100644 --- a/test/TestContractHandler.ts +++ b/test/TestContractHandler.ts @@ -1,8 +1,5 @@ import { Contract } from 'web3-eth-contract' -const Web3 = require('web3') -const web3 = new Web3('http://127.0.0.1:8545') - export class TestContractHandler { public factory: Contract public template: Contract @@ -11,21 +8,24 @@ export class TestContractHandler { public factoryBytecode: string public factoryAddress: string public templateAddress: string + public web3: any constructor( factoryABI: Contract, datatokensABI: Contract, templateBytecode: string, - factoryBytecode: string + factoryBytecode: string, + web3: any ) { - this.factory = new web3.eth.Contract(factoryABI) - this.template = new web3.eth.Contract(datatokensABI) + this.web3 = web3 + this.factory = new this.web3.eth.Contract(factoryABI) + this.template = new this.web3.eth.Contract(datatokensABI) this.templateBytecode = templateBytecode this.factoryBytecode = factoryBytecode } public async getAccounts() { - this.accounts = await web3.eth.getAccounts() + this.accounts = await this.web3.eth.getAccounts() } public async deployContracts(minter: string) { diff --git a/test/integration/Marketplaceflow.test.ts b/test/integration/Marketplaceflow.test.ts index 76ca66b5..78e96926 100644 --- a/test/integration/Marketplaceflow.test.ts +++ b/test/integration/Marketplaceflow.test.ts @@ -27,7 +27,8 @@ describe('Marketplace flow', () => { factory.abi, datatokensTemplate.abi, datatokensTemplate.bytecode, - factory.bytecode + factory.bytecode, + web3 ) await contracts.getAccounts() owner = contracts.accounts[0] @@ -66,4 +67,4 @@ describe('Marketplace flow', () => { await ocean.assets.download(ddo, blob, transactionId, bob) }) }) -}) +}) \ No newline at end of file diff --git a/test/integration/Rinkeby.test.ts b/test/integration/Rinkeby.test.ts new file mode 100644 index 00000000..741e42ac --- /dev/null +++ b/test/integration/Rinkeby.test.ts @@ -0,0 +1,25 @@ +import { TestContractHandler } from '../TestContractHandler' + +const Web3 = require('web3') +const web3 = new Web3('wss://rinkeby.infura.io/ws/v3/357f2fe737db4304bd2f7285c5602d0d') +const factory = require('@oceanprotocol/contracts/artifacts/development/Factory.json') +const datatokensTemplate = require('@oceanprotocol/contracts/artifacts/development/DataTokenTemplate.json') + +describe('Rinkeby test', () => { + let owner + let contracts + + describe('#test', () => { + it('Initialize Ocean contracts v3', async () => { + contracts = new TestContractHandler( + factory.abi, + datatokensTemplate.abi, + datatokensTemplate.bytecode, + factory.bytecode, + web3 + ) + await contracts.deployContracts(owner) + }) + + }) +}) \ No newline at end of file diff --git a/test/integration/Simpleflow.test.ts b/test/integration/Simpleflow.test.ts index 7617048f..1dd54e39 100644 --- a/test/integration/Simpleflow.test.ts +++ b/test/integration/Simpleflow.test.ts @@ -27,7 +27,8 @@ describe('Simple flow', () => { factory.abi, datatokensTemplate.abi, datatokensTemplate.bytecode, - factory.bytecode + factory.bytecode, + web3 ) await contracts.getAccounts() owner = contracts.accounts[0]