From 354149d2d4cab3815a94386757bd654c4d4f544d Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 31 Oct 2019 11:23:41 +0100 Subject: [PATCH] test tweaks --- .travis.yml | 2 +- integration/ocean/AssetOwners.test.ts | 10 +++------- src/keeper/ContractEvent.ts | 2 +- test/config.ts | 2 +- test/keeper/ContractEvent.test.ts | 6 +++--- test/keeper/TestContractHandler.ts | 18 +++++++++++++----- 6 files changed, 22 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5ee50a0..5478392 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,7 @@ before_script: - export KEEPER_VERSION=v0.12.6 - export EVENTS_HANDLER_VERSION=v0.1.2 - export KEEPER_OWNER_ROLE_ADDRESS="0xe2DD09d719Da89e5a3D0F2549c7E24566e947260" - - bash -x start_ocean.sh --no-commons --local-spree-node 2>&1 > start_ocean.log & + - bash -x start_ocean.sh --no-commons --no-dashboard 2>&1 > start_ocean.log & - cd .. script: diff --git a/integration/ocean/AssetOwners.test.ts b/integration/ocean/AssetOwners.test.ts index e188ffc..03165df 100644 --- a/integration/ocean/AssetOwners.test.ts +++ b/integration/ocean/AssetOwners.test.ts @@ -1,9 +1,6 @@ import { assert } from 'chai' - import { config } from '../config' - import { getMetadata } from '../utils' - import { Ocean, Account } from '../../src' // @oceanprotocol/squid describe('Asset Owners', () => { @@ -25,15 +22,14 @@ describe('Asset Owners', () => { } }) - it('should be set correctly the owner of an asset', async () => { + it('should set the owner of an asset', async () => { const ddo = await ocean.assets.create(metadata as any, account1) - const owner = await ocean.assets.owner(ddo.id) assert.equal(owner, account1.getId()) }) - it('should be set correctly the provider of an asset', async () => { + it('should set the provider of an asset', async () => { const ddo = await ocean.assets.create(metadata as any, account1) const isProvider = await ocean.keeper.didRegistry.isDIDProvider( @@ -61,7 +57,7 @@ describe('Asset Owners', () => { assert.equal(finalLength - initialLength, 1) }) - it('should get the assets that can be consumer by a user', async () => { + it('should get the assets that can be consumed by a user', async () => { const { length: initialLength } = await ocean.assets.consumerAssets( account2.getId() ) diff --git a/src/keeper/ContractEvent.ts b/src/keeper/ContractEvent.ts index 7220ec3..9deb54b 100644 --- a/src/keeper/ContractEvent.ts +++ b/src/keeper/ContractEvent.ts @@ -20,7 +20,7 @@ export class ContractEvent { public subscribe( callback: (events: any[]) => void ): ContractEventSubscription { - const onEvent = async blockNumber => { + const onEvent = async (blockNumber: number) => { const events = await this.contract.getEventData(this.eventName, { filter: this.filter, fromBlock: blockNumber, diff --git a/test/config.ts b/test/config.ts index 37f1459..1954f33 100644 --- a/test/config.ts +++ b/test/config.ts @@ -5,7 +5,7 @@ LoggerInstance.setLevel(LogLevel.Error) export default { aquariusUri: 'http://localhost:5000', - brizoUri: 'http://localhost:3000', + brizoUri: 'http://localhost:8030', nodeUri: `http://localhost:${process.env.ETH_PORT || 8545}`, parityUri: 'http://localhost:9545', secretStoreUri: 'http://localhost:12001', diff --git a/test/keeper/ContractEvent.test.ts b/test/keeper/ContractEvent.test.ts index 179a224..238015a 100644 --- a/test/keeper/ContractEvent.test.ts +++ b/test/keeper/ContractEvent.test.ts @@ -22,7 +22,7 @@ describe('ContractEvent', () => { }) describe('#subscribe()', () => { - it('should listen the events', async () => { + it('should be able to listen to events', async () => { const event = eventHandler.getEvent( ocean.keeper.token, 'Transfer', @@ -55,7 +55,7 @@ describe('ContractEvent', () => { }) describe('#once()', () => { - it('should listen only once', async () => { + it('should listen to event only once', async () => { const to = account const event = eventHandler.getEvent( ocean.keeper.token, @@ -65,7 +65,7 @@ describe('ContractEvent', () => { let canBeRejected = false const waitUntilEvent = new Promise((resolve, reject) => { - event.once(events => { + event.once(() => { if (canBeRejected) { reject(new Error('')) } diff --git a/test/keeper/TestContractHandler.ts b/test/keeper/TestContractHandler.ts index ca0c980..557d965 100644 --- a/test/keeper/TestContractHandler.ts +++ b/test/keeper/TestContractHandler.ts @@ -4,6 +4,11 @@ import Web3Provider from '../../src/keeper/Web3Provider' import Logger from '../../src/utils/Logger' import config from '../config' +interface TestContract extends Contract { + testContract?: boolean + $initialized?: boolean +} + export default class TestContractHandler extends ContractHandler { public static async prepareContracts() { const web3 = Web3Provider.getWeb3(config) @@ -134,20 +139,23 @@ export default class TestContractHandler extends ContractHandler { from: string, args: any[] = [], tokens: { [name: string]: string } = {} - ): Promise { + ): Promise { const where = this.networkId // dont redeploy if there is already something loaded if (TestContractHandler.hasContract(name, where)) { - const contract = await ContractHandler.getContract(name, where) - if ((contract as any).testContract) { + const contract: TestContract = ContractHandler.getContract( + name, + where + ) + if (contract.testContract) { return { ...contract, $initialized: true } } } const web3 = Web3Provider.getWeb3(config) - let contractInstance: Contract + let contractInstance: TestContract try { Logger.log('Deploying', name) const sendConfig = { @@ -188,7 +196,7 @@ export default class TestContractHandler extends ContractHandler { .initialize(...args) .send(sendConfig) } - ;(contractInstance as any).testContract = true + contractInstance.testContract = true ContractHandler.setContract(name, where, contractInstance) // Logger.log("Deployed", name, "at", contractInstance.options.address); } catch (err) {