1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00

consolidate test files

This commit is contained in:
Matthias Kretschmann 2020-01-30 22:08:18 +01:00
parent db6864d921
commit 078c35146f
Signed by: m
GPG Key ID: 606EEEF3C479A91F
55 changed files with 94 additions and 94 deletions

View File

@ -7,8 +7,8 @@
}, },
"project": [ "project": [
"./tsconfig.json", "./tsconfig.json",
"./test/tsconfig.json", "./test/unit/tsconfig.json",
"./integration/tsconfig.json" "./test/integration/tsconfig.json"
] ]
}, },
"extends": [ "extends": [

View File

@ -38,7 +38,7 @@ script:
- export ETH_PORT=18545; npm run test:cover - export ETH_PORT=18545; npm run test:cover
- npm run build - npm run build
- npm run doc - npm run doc
- npm run integration:cover - npm run test:integration:cover
after_script: after_script:
- npm run report-codacy - npm run report-codacy

View File

@ -152,7 +152,7 @@ npm run test:cover
### Integration Tests ### Integration Tests
Besides a running `ganache-cli` instance, a locally running Ocean network is required. To do so before running the tests, use [Barge](https://github.com/oceanprotocol/barge): A locally running Ocean network is required. To do so before running the tests, use [Barge](https://github.com/oceanprotocol/barge):
```bash ```bash
git clone https://github.com/oceanprotocol/barge git clone https://github.com/oceanprotocol/barge
@ -176,13 +176,13 @@ Once everything is up, run the integration tests:
```bash ```bash
# integration tests work with the spree network and the SEED_WORDS in previous step are required. # integration tests work with the spree network and the SEED_WORDS in previous step are required.
# Make sure to reset `ETH_PORT` to 8545 (or whatever port is used in `spree1) # Make sure to reset `ETH_PORT` to 8545 (or whatever port is used in `spree1)
npm run integration npm run test:integration
``` ```
to generate code coverage information during test, run: to generate code coverage information during test, run:
```bash ```bash
npm run integration:cover npm run test:integration:cover
``` ```
## Code Style ## Code Style

View File

@ -12,15 +12,15 @@
"build:metadata": "./scripts/get-metadata.js > src/metadata.json", "build:metadata": "./scripts/get-metadata.js > src/metadata.json",
"build:dist": "cross-env NODE_ENV=production webpack", "build:dist": "cross-env NODE_ENV=production webpack",
"build:watch": "tsc -w", "build:watch": "tsc -w",
"test": "mocha", "test": "mocha --opts test/unit/mocha.opts",
"test:watch": "mocha -w --watch-extensions js,ts,json", "test:watch": "npm test -- -w --watch-extensions js,ts,json",
"test:cover": "nyc --report-dir coverage/unit mocha", "test:cover": "nyc --report-dir coverage/unit npm test",
"integration": "mocha --opts integration/mocha.opts", "test:integration": "mocha --opts test/integration/mocha.opts",
"integration:pacific": "export NETWORK_NAME=pacific; mocha --opts integration/mocha.opts", "test:integration:pacific": "export NETWORK_NAME=pacific; npm run test:integration",
"integration:nile": "export NETWORK_NAME=nile; mocha --opts integration/mocha.opts", "test:integration:nile": "export NETWORK_NAME=nile; npm run test:integration",
"integration:duero": "export NETWORK_NAME=duero; mocha --opts integration/mocha.opts", "test:integration:duero": "export NETWORK_NAME=duero; npm run test:integration",
"integration:watch": "mocha -w --watch-extensions js,ts,json --opts integration/mocha.opts", "test:integration:watch": "npm run test:integration -- -w --watch-extensions js,ts,json",
"integration:cover": "nyc --report-dir coverage/integration mocha --opts integration/mocha.opts", "test:integration:cover": "nyc --report-dir coverage/integration npm run test:integration",
"clean": "rm -rf ./dist/ ./doc/ ./.nyc_output", "clean": "rm -rf ./dist/ ./doc/ ./.nyc_output",
"lint": "eslint --ignore-path .gitignore --ext .ts,.tsx .", "lint": "eslint --ignore-path .gitignore --ext .ts,.tsx .",
"format": "prettier --parser typescript --ignore-path .gitignore --write '**/*.{js,jsx,ts,tsx}'", "format": "prettier --parser typescript --ignore-path .gitignore --write '**/*.{js,jsx,ts,tsx}'",
@ -105,7 +105,7 @@
"ts-node/register" "ts-node/register"
], ],
"reporter": [ "reporter": [
"text-summary", "text",
"lcov", "lcov",
"html" "html"
], ],

View File

@ -1,4 +1,4 @@
import { Config } from '../src' import { Config } from '../../src'
import HDWalletProvider from '@truffle/hdwallet-provider' import HDWalletProvider from '@truffle/hdwallet-provider'
const configJson: Config = { const configJson: Config = {

View File

@ -4,4 +4,4 @@
--full-trace --full-trace
--exit --exit
--timeout 300000 --timeout 300000
integration/**/*.test.ts test/integration/**/*.test.ts

View File

@ -1,7 +1,7 @@
import { assert } from 'chai' import { assert } from 'chai'
import { config } from '../config' import { config } from '../config'
import { getMetadata } from '../utils' import { getMetadata } from '../utils'
import { Ocean, Account } from '../../src' // @oceanprotocol/squid import { Ocean, Account } from '../../../src' // @oceanprotocol/squid
describe('Asset Owners', () => { describe('Asset Owners', () => {
let ocean: Ocean let ocean: Ocean

View File

@ -1,6 +1,6 @@
import { assert } from 'chai' import { assert } from 'chai'
import { config } from '../config' import { config } from '../config'
import { Ocean, Account } from '../../src' // @oceanprotocol/squid import { Ocean, Account } from '../../../src' // @oceanprotocol/squid
describe('Authentication Token', () => { describe('Authentication Token', () => {
let ocean: Ocean let ocean: Ocean

View File

@ -4,7 +4,7 @@ import * as fs from 'fs'
import { config } from '../config' import { config } from '../config'
import { getMetadata } from '../utils' import { getMetadata } from '../utils'
import { Ocean, DDO, Account, ConditionState } from '../../src' // @oceanprotocol/squid import { Ocean, DDO, Account, ConditionState } from '../../../src' // @oceanprotocol/squid
describe('Consume Asset', () => { describe('Consume Asset', () => {
let ocean: Ocean let ocean: Ocean

View File

@ -4,7 +4,7 @@ import * as fs from 'fs'
import { config } from '../config' import { config } from '../config'
import { getMetadata } from '../utils' import { getMetadata } from '../utils'
import { Ocean, Account, DDO } from '../../src' // @oceanprotocol/squid import { Ocean, Account, DDO } from '../../../src' // @oceanprotocol/squid
describe('Consume Asset (Brizo)', () => { describe('Consume Asset (Brizo)', () => {
let ocean: Ocean let ocean: Ocean

View File

@ -4,7 +4,7 @@ import * as fs from 'fs'
import { config } from '../config' import { config } from '../config'
import { getMetadata } from '../utils' import { getMetadata } from '../utils'
import { Ocean, Account, DDO } from '../../src' // @oceanprotocol/squid import { Ocean, Account, DDO } from '../../../src' // @oceanprotocol/squid
// Ensure that your network is fast enought and you have some free ram before run it. // Ensure that your network is fast enought and you have some free ram before run it.
xdescribe('Consume Asset (Large size)', () => { xdescribe('Consume Asset (Large size)', () => {

View File

@ -2,7 +2,7 @@ import { assert } from 'chai'
import { config } from '../config' import { config } from '../config'
import { Ocean, templates, conditions, utils, Account, Keeper } from '../../src' // @oceanprotocol/squid import { Ocean, templates, conditions, utils, Account, Keeper } from '../../../src' // @oceanprotocol/squid
const { LockRewardCondition, EscrowReward, AccessSecretStoreCondition } = conditions const { LockRewardCondition, EscrowReward, AccessSecretStoreCondition } = conditions

View File

@ -2,7 +2,7 @@ import { assert } from 'chai'
import { config } from '../config' import { config } from '../config'
import { Ocean, templates, conditions, utils, Account, Keeper } from '../../src' // @oceanprotocol/squid import { Ocean, templates, conditions, utils, Account, Keeper } from '../../../src' // @oceanprotocol/squid
const { LockRewardCondition, EscrowReward, ComputeExecutionCondition } = conditions const { LockRewardCondition, EscrowReward, ComputeExecutionCondition } = conditions

View File

@ -4,7 +4,7 @@ import { config } from '../config'
import { generateMetadata } from '../utils' import { generateMetadata } from '../utils'
import { Ocean, Account, DDO } from '../../src' // @oceanprotocol/squid import { Ocean, Account, DDO } from '../../../src' // @oceanprotocol/squid
describe('Search Asset', () => { describe('Search Asset', () => {
let ocean: Ocean let ocean: Ocean

View File

@ -2,7 +2,7 @@ import { assert } from 'chai'
import { config } from '../config' import { config } from '../config'
import { Ocean, Account, DID } from '../../src' // @oceanprotocol/squid import { Ocean, Account, DID } from '../../../src' // @oceanprotocol/squid
describe('Secret Store', () => { describe('Secret Store', () => {
let ocean: Ocean let ocean: Ocean

View File

@ -2,7 +2,7 @@ import { assert } from 'chai'
import { config } from '../config' import { config } from '../config'
import { Ocean, Account, DDO } from '../../src' // @oceanprotocol/squid import { Ocean, Account, DDO } from '../../../src' // @oceanprotocol/squid
// WARN: not integration test. It has been done here because constant values // WARN: not integration test. It has been done here because constant values
// depends on the first account on spree (only accessible from integration test) // depends on the first account on spree (only accessible from integration test)

View File

@ -2,7 +2,7 @@ import { assert } from 'chai'
import { config } from '../config' import { config } from '../config'
import { Ocean, OceanPlatformTechStatus } from '../../src' // @oceanprotocol/squid import { Ocean, OceanPlatformTechStatus } from '../../../src' // @oceanprotocol/squid
describe('Versions', () => { describe('Versions', () => {
let ocean: Ocean let ocean: Ocean

View File

@ -1,4 +1,4 @@
import { MetaData } from '../../src' // @oceanprotocol/squid import { MetaData } from '../../../src' // @oceanprotocol/squid
const metadata: Partial<MetaData> = { const metadata: Partial<MetaData> = {
main: { main: {

View File

@ -1,5 +1,5 @@
import assert from 'assert' import assert from 'assert'
import * as squid from '../src/squid' import * as squid from '../../src/squid'
describe('Squid', () => { describe('Squid', () => {
describe('interface', () => { describe('interface', () => {

View File

@ -1,4 +1,4 @@
import { generateId } from '../src/utils/GeneratorHelpers' import { generateId } from '../../src/utils/GeneratorHelpers'
export default class TestIdGenerator { export default class TestIdGenerator {
public static generatePrefixedId() { public static generatePrefixedId() {

View File

@ -1,11 +1,11 @@
import { assert, spy, use } from 'chai' import { assert, spy, use } from 'chai'
import spies from 'chai-spies' import spies from 'chai-spies'
import { Ocean } from '../../src/ocean/Ocean' import { Ocean } from '../../../src/ocean/Ocean'
import { Aquarius, SearchQuery } from '../../src/aquarius/Aquarius' import { Aquarius, SearchQuery } from '../../../src/aquarius/Aquarius'
import { DDO } from '../../src/ddo/DDO' import { DDO } from '../../../src/ddo/DDO'
import DID from '../../src/ocean/DID' import DID from '../../../src/ocean/DID'
import config from '../config' import config from '../config'
import { LoggerInstance } from '../../src/utils' import { LoggerInstance } from '../../../src/utils'
use(spies) use(spies)

View File

@ -1,5 +1,5 @@
import { Config, LogLevel } from '../src/models/Config' import { Config, LogLevel } from '../../src/models/Config'
import { LoggerInstance } from '../src/utils' import { LoggerInstance } from '../../src/utils'
LoggerInstance.setLevel(LogLevel.Error) LoggerInstance.setLevel(LogLevel.Error)

View File

@ -1,9 +1,9 @@
import { assert, expect, spy, use } from 'chai' import { assert, expect, spy, use } from 'chai'
import spies from 'chai-spies' import spies from 'chai-spies'
import { DDO } from '../../src/ddo/DDO' import { DDO } from '../../../src/ddo/DDO'
import { Service } from '../../src/ddo/Service' import { Service } from '../../../src/ddo/Service'
import { Ocean } from '../../src/ocean/Ocean' import { Ocean } from '../../../src/ocean/Ocean'
import config from '../config' import config from '../config'
import TestContractHandler from '../keeper/TestContractHandler' import TestContractHandler from '../keeper/TestContractHandler'

View File

@ -1,6 +1,6 @@
import { assert } from 'chai' import { assert } from 'chai'
import Account from '../../src/ocean/Account' import Account from '../../../src/ocean/Account'
import { Ocean } from '../../src/ocean/Ocean' import { Ocean } from '../../../src/ocean/Ocean'
import config from '../config' import config from '../config'
import ContractBaseMock from '../mocks/ContractBase.Mock' import ContractBaseMock from '../mocks/ContractBase.Mock'
import TestContractHandler from './TestContractHandler' import TestContractHandler from './TestContractHandler'

View File

@ -1,7 +1,7 @@
import { assert } from 'chai' import { assert } from 'chai'
import { EventHandler } from '../../src/keeper/EventHandler' import { EventHandler } from '../../../src/keeper/EventHandler'
import { ContractEventSubscription } from '../../src/keeper/ContractEvent' import { ContractEventSubscription } from '../../../src/keeper/ContractEvent'
import { Ocean } from '../../src/ocean/Ocean' import { Ocean } from '../../../src/ocean/Ocean'
import config from '../config' import config from '../config'
import TestContractHandler from './TestContractHandler' import TestContractHandler from './TestContractHandler'

View File

@ -1,6 +1,6 @@
import { assert } from 'chai' import { assert } from 'chai'
import ContractHandler from '../../src/keeper/ContractHandler' import ContractHandler from '../../../src/keeper/ContractHandler'
import { Ocean } from '../../src/ocean/Ocean' import { Ocean } from '../../../src/ocean/Ocean'
import config from '../config' import config from '../config'
describe('ContractHandler', () => { describe('ContractHandler', () => {

View File

@ -1,8 +1,8 @@
import { assert } from 'chai' import { assert } from 'chai'
import DIDRegistry from '../../src/keeper/contracts/DIDRegistry' import DIDRegistry from '../../../src/keeper/contracts/DIDRegistry'
import Account from '../../src/ocean/Account' import Account from '../../../src/ocean/Account'
import { Ocean } from '../../src/ocean/Ocean' import { Ocean } from '../../../src/ocean/Ocean'
import { generateId } from '../../src/utils/GeneratorHelpers' import { generateId } from '../../../src/utils/GeneratorHelpers'
import config from '../config' import config from '../config'
import TestContractHandler from './TestContractHandler' import TestContractHandler from './TestContractHandler'

View File

@ -1,7 +1,7 @@
import { assert, expect, spy, use } from 'chai' import { assert, expect, spy, use } from 'chai'
import spies from 'chai-spies' import spies from 'chai-spies'
import { EventHandler } from '../../src/keeper/EventHandler' import { EventHandler } from '../../../src/keeper/EventHandler'
import { Ocean } from '../../src/ocean/Ocean' import { Ocean } from '../../../src/ocean/Ocean'
import config from '../config' import config from '../config'
use(spies) use(spies)

View File

@ -1,8 +1,8 @@
import { assert } from 'chai' import { assert } from 'chai'
import config from '../config' import config from '../config'
import TestContractHandler from './TestContractHandler' import TestContractHandler from './TestContractHandler'
import Keeper from '../../src/keeper/Keeper' import Keeper from '../../../src/keeper/Keeper'
import { Ocean } from '../../src/ocean/Ocean' import { Ocean } from '../../../src/ocean/Ocean'
let keeper: Keeper let keeper: Keeper

View File

@ -1,7 +1,7 @@
import { Contract } from 'web3-eth-contract' import { Contract } from 'web3-eth-contract'
import ContractHandler from '../../src/keeper/ContractHandler' import ContractHandler from '../../../src/keeper/ContractHandler'
import Web3Provider from '../../src/keeper/Web3Provider' import Web3Provider from '../../../src/keeper/Web3Provider'
import Logger from '../../src/utils/Logger' import Logger from '../../../src/utils/Logger'
import config from '../config' import config from '../config'
interface ContractTest extends Contract { interface ContractTest extends Contract {

View File

@ -1,6 +1,6 @@
import { assert } from 'chai' import { assert } from 'chai'
import { AccessSecretStoreCondition } from '../../../src/keeper/contracts/conditions' import { AccessSecretStoreCondition } from '../../../../src/keeper/contracts/conditions'
import { Ocean } from '../../../src/ocean/Ocean' import { Ocean } from '../../../../src/ocean/Ocean'
import config from '../../config' import config from '../../config'
import TestContractHandler from '../TestContractHandler' import TestContractHandler from '../TestContractHandler'

View File

@ -1,6 +1,6 @@
import { assert } from 'chai' import { assert } from 'chai'
import { EscrowReward } from '../../../src/keeper/contracts/conditions' import { EscrowReward } from '../../../../src/keeper/contracts/conditions'
import { Ocean } from '../../../src/ocean/Ocean' import { Ocean } from '../../../../src/ocean/Ocean'
import config from '../../config' import config from '../../config'
import TestContractHandler from '../TestContractHandler' import TestContractHandler from '../TestContractHandler'

View File

@ -1,6 +1,6 @@
import { assert } from 'chai' import { assert } from 'chai'
import { LockRewardCondition } from '../../../src/keeper/contracts/conditions' import { LockRewardCondition } from '../../../../src/keeper/contracts/conditions'
import { Ocean } from '../../../src/ocean/Ocean' import { Ocean } from '../../../../src/ocean/Ocean'
import config from '../../config' import config from '../../config'
import TestContractHandler from '../TestContractHandler' import TestContractHandler from '../TestContractHandler'

View File

@ -5,4 +5,4 @@
--bail --bail
--exit --exit
--timeout 20000 --timeout 20000
test/config.ts test/**/*.test.ts test/unit/config.ts test/unit/**/*.test.ts

View File

@ -1,6 +1,6 @@
import { Aquarius } from '../../src/aquarius/Aquarius' import { Aquarius } from '../../../src/aquarius/Aquarius'
import { DDO } from '../../src/ddo/DDO' import { DDO } from '../../../src/ddo/DDO'
import DID from '../../src/ocean/DID' import DID from '../../../src/ocean/DID'
const ddoStore: Map<string, any> = new Map<string, any>() const ddoStore: Map<string, any> = new Map<string, any>()

View File

@ -1,4 +1,4 @@
import { Brizo } from '../../src/brizo/Brizo' import { Brizo } from '../../../src/brizo/Brizo'
export default class BrizoMock extends Brizo { export default class BrizoMock extends Brizo {
public async initializeServiceAgreement( public async initializeServiceAgreement(

View File

@ -1,4 +1,4 @@
import ContractBase from '../../src/keeper/contracts/ContractBase' import ContractBase from '../../../src/keeper/contracts/ContractBase'
export default class ContractBaseMock extends ContractBase { export default class ContractBaseMock extends ContractBase {
public async initMock(config: any) { public async initMock(config: any) {

View File

@ -1,7 +1,7 @@
import { assert } from 'chai' import { assert } from 'chai'
import Web3Provider from '../../src/keeper/Web3Provider' import Web3Provider from '../../../src/keeper/Web3Provider'
import Account from '../../src/ocean/Account' import Account from '../../../src/ocean/Account'
import { Ocean } from '../../src/ocean/Ocean' import { Ocean } from '../../../src/ocean/Ocean'
import config from '../config' import config from '../config'
import TestContractHandler from '../keeper/TestContractHandler' import TestContractHandler from '../keeper/TestContractHandler'

View File

@ -1,5 +1,5 @@
import assert from 'assert' import assert from 'assert'
import DID from '../../src/ocean/DID' import DID from '../../../src/ocean/DID'
describe('DID', () => { describe('DID', () => {
describe('#generate()', () => { describe('#generate()', () => {

View File

@ -1,8 +1,8 @@
import { assert, spy, use } from 'chai' import { assert, spy, use } from 'chai'
import spies from 'chai-spies' import spies from 'chai-spies'
import Account from '../../src/ocean/Account' import Account from '../../../src/ocean/Account'
import { Ocean } from '../../src/ocean/Ocean' import { Ocean } from '../../../src/ocean/Ocean'
import config from '../config' import config from '../config'
import TestContractHandler from '../keeper/TestContractHandler' import TestContractHandler from '../keeper/TestContractHandler'

View File

@ -2,9 +2,9 @@ import { assert, spy, use } from 'chai'
import spies from 'chai-spies' import spies from 'chai-spies'
import config from '../config' import config from '../config'
import Account from '../../src/ocean/Account' import Account from '../../../src/ocean/Account'
import { Ocean } from '../../src/ocean/Ocean' import { Ocean } from '../../../src/ocean/Ocean'
import { OceanAccounts } from '../../src/ocean/OceanAccounts' import { OceanAccounts } from '../../../src/ocean/OceanAccounts'
use(spies) use(spies)

View File

@ -1,8 +1,8 @@
import { assert, spy, use } from 'chai' import { assert, spy, use } from 'chai'
import spies from 'chai-spies' import spies from 'chai-spies'
import { SearchQuery } from '../../src/aquarius/Aquarius' import { SearchQuery } from '../../../src/aquarius/Aquarius'
import { Ocean } from '../../src/ocean/Ocean' import { Ocean } from '../../../src/ocean/Ocean'
import config from '../config' import config from '../config'
use(spies) use(spies)

View File

@ -2,9 +2,9 @@ import { assert, expect, spy, use } from 'chai'
import spies from 'chai-spies' import spies from 'chai-spies'
import config from '../config' import config from '../config'
import Account from '../../src/ocean/Account' import Account from '../../../src/ocean/Account'
import { Ocean } from '../../src/ocean/Ocean' import { Ocean } from '../../../src/ocean/Ocean'
import { OceanAuth } from '../../src/ocean/OceanAuth' import { OceanAuth } from '../../../src/ocean/OceanAuth'
use(spies) use(spies)

View File

@ -1,9 +1,9 @@
import { assert, expect, spy, use } from 'chai' import { assert, expect, spy, use } from 'chai'
import spies from 'chai-spies' import spies from 'chai-spies'
import Account from '../../src/ocean/Account' import Account from '../../../src/ocean/Account'
import { Ocean } from '../../src/ocean/Ocean' import { Ocean } from '../../../src/ocean/Ocean'
import { OceanSecretStore } from '../../src/ocean/OceanSecretStore' import { OceanSecretStore } from '../../../src/ocean/OceanSecretStore'
import config from '../config' import config from '../config'
use(spies) use(spies)

View File

@ -3,7 +3,7 @@ import spies from 'chai-spies'
import Web3 from 'web3' import Web3 from 'web3'
import config from '../../config' import config from '../../config'
import { Ocean } from '../../../src/ocean/Ocean' import { Ocean } from '../../../../src/ocean/Ocean'
use(spies) use(spies)

View File

@ -4,7 +4,7 @@ import {
noZeroX, noZeroX,
didPrefixed, didPrefixed,
noDidPrefixed noDidPrefixed
} from '../../src/utils/ConversionTypeHelpers' } from '../../../src/utils/ConversionTypeHelpers'
describe('ConversionTypeHelpers', () => { describe('ConversionTypeHelpers', () => {
describe('#zeroXTransformer()', () => { describe('#zeroXTransformer()', () => {

View File

@ -1,5 +1,5 @@
import { assert } from 'chai' import { assert } from 'chai'
import { generateId } from '../../src/utils/GeneratorHelpers' import { generateId } from '../../../src/utils/GeneratorHelpers'
describe('GeneratorHelpers', () => { describe('GeneratorHelpers', () => {
describe('#generateId()', () => { describe('#generateId()', () => {

View File

@ -1,7 +1,7 @@
import { assert, expect, spy, use } from 'chai' import { assert, expect, spy, use } from 'chai'
import spies from 'chai-spies' import spies from 'chai-spies'
import { SubscribableObserver } from '../../src/utils/SubscribableObserver' import { SubscribableObserver } from '../../../src/utils/SubscribableObserver'
use(spies) use(spies)

View File

@ -1,7 +1,7 @@
import { assert, expect, spy, use } from 'chai' import { assert, expect, spy, use } from 'chai'
import spies from 'chai-spies' import spies from 'chai-spies'
import { SubscribablePromise } from '../../src/utils/SubscribablePromise' import { SubscribablePromise } from '../../../src/utils/SubscribablePromise'
use(spies) use(spies)