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

Fix integration tests and remove parallel execution workaround.

This commit is contained in:
Pedro Gutiérrez 2019-03-21 03:02:05 +01:00 committed by Pedro Gutiérrez
parent 7a13ad8daa
commit ebb2308df7
9 changed files with 29 additions and 25 deletions

View File

@ -7,5 +7,5 @@
"threshold": 0, "threshold": 0,
"password": "secret", "password": "secret",
"address": "0x068Ed00cF0441e4829D9784fCBe7b9e26D4BD8d0", "address": "0x068Ed00cF0441e4829D9784fCBe7b9e26D4BD8d0",
"verbose": 0 "verbose": false
} }

View File

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

View File

@ -26,9 +26,10 @@ describe("Consume Asset", () => {
}) })
// Accounts // Accounts
publisher = new Account("0x00Bd138aBD70e2F00903268F3Db08f2D25677C9e") const instanceConfig = (<any>ocean).instanceConfig
publisher = new Account("0x00Bd138aBD70e2F00903268F3Db08f2D25677C9e", instanceConfig)
publisher.setPassword("node0") publisher.setPassword("node0")
consumer = new Account("0x068Ed00cF0441e4829D9784fCBe7b9e26D4BD8d0") consumer = new Account("0x068Ed00cF0441e4829D9784fCBe7b9e26D4BD8d0", instanceConfig)
consumer.setPassword("secret") consumer.setPassword("secret")
}) })

View File

@ -26,9 +26,10 @@ describe("Consume Asset (Brizo)", () => {
}) })
// Accounts // Accounts
publisher = new Account("0x00Bd138aBD70e2F00903268F3Db08f2D25677C9e") const instanceConfig = (<any>ocean).instanceConfig
publisher = new Account("0x00Bd138aBD70e2F00903268F3Db08f2D25677C9e", instanceConfig)
publisher.setPassword("node0") publisher.setPassword("node0")
consumer = new Account("0x068Ed00cF0441e4829D9784fCBe7b9e26D4BD8d0") consumer = new Account("0x068Ed00cF0441e4829D9784fCBe7b9e26D4BD8d0", instanceConfig)
consumer.setPassword("secret") consumer.setPassword("secret")
}) })

View File

@ -2,10 +2,9 @@ import { assert } from "chai"
import { config } from "../config" import { config } from "../config"
import { Ocean, templates, conditions, utils, Keeper, Account } 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
const { EscrowAccessSecretStoreTemplate } = templates
describe("Register Escrow Access Secret Store Template", () => { describe("Register Escrow Access Secret Store Template", () => {
let ocean: Ocean let ocean: Ocean
@ -27,9 +26,9 @@ describe("Register Escrow Access Secret Store Template", () => {
before(async () => { before(async () => {
ocean = await Ocean.getInstance(config) ocean = await Ocean.getInstance(config)
keeper = await Keeper.getInstance() keeper = ocean.keeper
template = await EscrowAccessSecretStoreTemplate.getInstance() template = keeper.templates.escrowAccessSecretStoreTemplate
// Accounts // Accounts
templateManagerOwner = (await ocean.accounts.list())[0] templateManagerOwner = (await ocean.accounts.list())[0]
@ -37,22 +36,22 @@ describe("Register Escrow Access Secret Store Template", () => {
consumer = (await ocean.accounts.list())[2] consumer = (await ocean.accounts.list())[2]
// Conditions // Conditions
accessSecretStoreCondition = await AccessSecretStoreCondition.getInstance() accessSecretStoreCondition = keeper.conditions.accessSecretStoreCondition
lockRewardCondition = await LockRewardCondition.getInstance() lockRewardCondition = keeper.conditions.lockRewardCondition
escrowReward = await EscrowReward.getInstance() escrowReward = keeper.conditions.escrowReward
}) })
describe("Propose and approve template", () => { describe("Propose and approve template", () => {
it("should propose the template", async () => { it("should propose the template", async () => {
await keeper.templateStoreManager.proposeTemplate(template.getAddress(), consumer.getId(), true) await keeper.templateStoreManager.proposeTemplate(template.getAddress(), consumer.getId(), true)
// TODO: Use a event to detect template mined // TODO: Use a event to detect template mined
await new Promise((_) => setTimeout(_, 6 * 1000)) await new Promise((_) => setTimeout(_, 2 * 1000))
}) })
it("should approve the template", async () => { it("should approve the template", async () => {
await keeper.templateStoreManager.approveTemplate(template.getAddress(), templateManagerOwner.getId(), true) await keeper.templateStoreManager.approveTemplate(template.getAddress(), templateManagerOwner.getId(), true)
// TODO: Use a event to detect template mined // TODO: Use a event to detect template mined
await new Promise((_) => setTimeout(_, 6 * 1000)) await new Promise((_) => setTimeout(_, 2 * 1000))
}) })
}) })

View File

@ -3,7 +3,7 @@ import * as Web3 from "web3"
import { config } from "../config" import { config } from "../config"
import { Ocean, Account, DDO, Keeper } from "../../src" // @oceanprotocol/squid import { Ocean, Account, DDO } from "../../src" // @oceanprotocol/squid
import ServiceAgreement from "../../src/ocean/ServiceAgreements/ServiceAgreement" import ServiceAgreement from "../../src/ocean/ServiceAgreements/ServiceAgreement"
@ -11,14 +11,17 @@ import ServiceAgreement from "../../src/ocean/ServiceAgreements/ServiceAgreement
// depends on the first account on spree (only accessible from integration test) // depends on the first account on spree (only accessible from integration test)
describe("Signature", () => { describe("Signature", () => {
let ocean: Ocean
let web3: Web3
let consumer: Account let consumer: Account
before(async () => { before(async () => {
await Ocean.getInstance({ ocean = await Ocean.getInstance({
...config, ...config,
web3Provider: new (Web3 as any).providers web3Provider: new (Web3 as any).providers
.HttpProvider("http://localhost:8545", 0, "0x00Bd138aBD70e2F00903268F3Db08f2D25677C9e", "node0"), .HttpProvider("http://localhost:8545", 0, "0x00Bd138aBD70e2F00903268F3Db08f2D25677C9e", "node0"),
}) })
web3 = (ocean as any).web3
// Accounts // Accounts
consumer = new Account("0x00bd138abd70e2f00903268f3db08f2d25677c9e") consumer = new Account("0x00bd138abd70e2f00903268f3db08f2d25677c9e")
@ -45,7 +48,7 @@ describe("Signature", () => {
}) })
it("should generate the correct signature", async () => { it("should generate the correct signature", async () => {
const templates = (await Keeper.getInstance()).templates const templates = ocean.keeper.templates
const did = `did:op:${"c".repeat(64)}` const did = `did:op:${"c".repeat(64)}`
const templateId = `0x${"f".repeat(40)}` const templateId = `0x${"f".repeat(40)}`
@ -80,6 +83,7 @@ describe("Signature", () => {
.getAgreementIdsFromDDO(agreementId, ddo, consumer.getId(), consumer.getId()) .getAgreementIdsFromDDO(agreementId, ddo, consumer.getId(), consumer.getId())
const signature = await ServiceAgreement.signServiceAgreement( const signature = await ServiceAgreement.signServiceAgreement(
web3,
ddo, ddo,
serviceDefinitionId, serviceDefinitionId,
agreementId, agreementId,

View File

@ -7,7 +7,7 @@
"dependencies": [ "dependencies": [
{ {
"name": "keeper-contracts", "name": "keeper-contracts",
"version": "~0.8.5" "version": "~0.8.6"
}, },
{ {
"name": "brizo", "name": "brizo",

View File

@ -9,10 +9,9 @@
"test": "mocha", "test": "mocha",
"test:watch": "mocha -w --watch-extensions js,ts,json", "test:watch": "mocha -w --watch-extensions js,ts,json",
"test:cover": "nyc --report-dir coverage/unit mocha", "test:cover": "nyc --report-dir coverage/unit mocha",
"@@integration@@": "Using mocha-parallel-tests to ensure independent execution", "integration": "mocha --opts integration/mocha.opts",
"integration": "mocha-parallel-tests --max-parallel 1 --opts integration/mocha.opts",
"integration:watch": "mocha -w --watch-extensions js,ts,json --opts integration/mocha.opts", "integration:watch": "mocha -w --watch-extensions js,ts,json --opts integration/mocha.opts",
"integration:cover": "nyc --report-dir coverage/integration mocha-parallel-tests --max-parallel 1 --opts integration/mocha.opts", "integration:cover": "nyc --report-dir coverage/integration mocha --opts integration/mocha.opts",
"examples": "./src/examples/fire_lazers.sh", "examples": "./src/examples/fire_lazers.sh",
"clean": "rm -rf ./dist/ ./doc/ ./coverage ./.nyc_output", "clean": "rm -rf ./dist/ ./doc/ ./coverage ./.nyc_output",
"lint": "tslint -c tslint.json 'src/**/*.ts' 'test/**/*.ts' 'integration/**/*.ts'", "lint": "tslint -c tslint.json 'src/**/*.ts' 'test/**/*.ts' 'integration/**/*.ts'",
@ -23,7 +22,7 @@
"build:watch": "tsc -w", "build:watch": "tsc -w",
"doc": "typedoc --mode modules --exclude \"**/examples/**\" --out ./doc/ ./src/", "doc": "typedoc --mode modules --exclude \"**/examples/**\" --out ./doc/ ./src/",
"merge-coverages": "npx lcov-result-merger \"coverage/*/lcov.info\" coverage/lcov.info", "merge-coverages": "npx lcov-result-merger \"coverage/*/lcov.info\" coverage/lcov.info",
"report-coverage": "cat ./coverage/lcov.info | codacy-coverage --token 71ef0d15f6f04ac29b31d704b28f866a", "report-coverage": "cat ./coverage/unit/lcov.info | codacy-coverage --token 71ef0d15f6f04ac29b31d704b28f866a",
"run": "ts-node", "run": "ts-node",
"release": "./node_modules/release-it/bin/release-it.js --src.tagName='v%s' --github.release --npm.publish --non-interactive", "release": "./node_modules/release-it/bin/release-it.js --src.tagName='v%s' --github.release --npm.publish --non-interactive",
"release-minor": "./node_modules/release-it/bin/release-it.js minor --src.tagName='v%s' --github.release --npm.publish --non-interactive", "release-minor": "./node_modules/release-it/bin/release-it.js minor --src.tagName='v%s' --github.release --npm.publish --non-interactive",
@ -82,7 +81,6 @@
"cross-env": "^5.2.0", "cross-env": "^5.2.0",
"lcov-result-merger": "^3.1.0", "lcov-result-merger": "^3.1.0",
"mocha": "^5.2.0", "mocha": "^5.2.0",
"mocha-parallel-tests": "^2.0.6-alpha.3",
"nyc": "^13.1.0", "nyc": "^13.1.0",
"source-map-support": "^0.5.9", "source-map-support": "^0.5.9",
"truffle-hdwallet-provider": "^1.0.4", "truffle-hdwallet-provider": "^1.0.4",

View File

@ -1,9 +1,10 @@
count=0 count=0
echo "Starting..." echo "Starting..."
while sleep 0.2; while sleep 0.1;
do do
curl --data '{"method":"personal_unlockAccount","params":["0x00Bd138aBD70e2F00903268F3Db08f2D25677C9e","node0",null],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8545 &> /dev/null; curl --data '{"method":"personal_unlockAccount","params":["0x00Bd138aBD70e2F00903268F3Db08f2D25677C9e","node0",null],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8545 &> /dev/null;
curl --data '{"method":"personal_unlockAccount","params":["0x068Ed00cF0441e4829D9784fCBe7b9e26D4BD8d0","secret",null],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8545 &> /dev/null; curl --data '{"method":"personal_unlockAccount","params":["0x068Ed00cF0441e4829D9784fCBe7b9e26D4BD8d0","secret",null],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8545 &> /dev/null;
curl --data '{"method":"personal_unlockAccount","params":["0xA99D43d86A0758d5632313b8fA3972B6088A21BB","secret",null],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8545 &> /dev/null;
count=$((count+1)); count=$((count+1));
echo -en "\e[1A"; echo -en "\e[1A";
echo -e "\e[0K\rRequest ${count}"; echo -e "\e[0K\rRequest ${count}";