diff --git a/.gitignore b/.gitignore index 35ad619..17aaee4 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ node_modules/ dist/ .nyc_output/ coverage/ +artifacts/ doc/ test/**/*.js src/**/*.js diff --git a/.travis.yml b/.travis.yml index ef4fd17..99eb08f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,14 +18,19 @@ before_install: before_script: - greenkeeper-lockfile-update - - ganache-cli > ganache-cli.log & - - sleep 2 + - ganache-cli --port 18545 > ganache-cli.log & + - git clone https://github.com/oceanprotocol/barge + - cd barge + - bash -x start_ocean.sh --latest --no-brizo --no-pleuston --local-nile-node 2>&1 > start_ocean.log & + - cd .. script: - - npm run test:cover + - export ETH_PORT=18545; npm run test:cover - npm run report-coverage - npm run build - npm run doc + # - ./scripts/wait_for_migration_and_extract_keeper_artifacts.sh + - ./src/examples/fire_lazers.sh after_script: - greenkeeper-lockfile-upload diff --git a/scripts/wait_for_migration_and_extract_keeper_artifacts.sh b/scripts/wait_for_migration_and_extract_keeper_artifacts.sh new file mode 100755 index 0000000..18b60ec --- /dev/null +++ b/scripts/wait_for_migration_and_extract_keeper_artifacts.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +RETRY_COUNT=0 +COMMAND_STATUS=1 + +mkdir -p artifacts + +until [ $COMMAND_STATUS -eq 0 ] || [ $RETRY_COUNT -eq 120 ]; do + keeper_contracts_docker_id=$(docker container ls | grep keeper-contracts | awk '{print $1}') + docker cp ${keeper_contracts_docker_id}:/keeper-contracts/artifacts/ready ./artifacts/ + COMMAND_STATUS=$? + sleep 5 + let RETRY_COUNT=RETRY_COUNT+1 +done + +if [ $COMMAND_STATUS -ne 0 ]; then + echo "Waited for more than two minutes, but keeper contracts have not been migrated yet. Did you run an Ethereum RPC client and the migration script?" + exit 1 +fi + +docker cp ${keeper_contracts_docker_id}:/keeper-contracts/artifacts/. ./artifacts/ diff --git a/src/examples/BuyAsset.ts b/src/examples/BuyAsset.ts index 983e4ff..9d59078 100644 --- a/src/examples/BuyAsset.ts +++ b/src/examples/BuyAsset.ts @@ -68,4 +68,6 @@ import config from "./config" const paid = await serviceAgreement.payAsset(did.getId(), metaData.base.price, consumer) Logger.log(`Asset paid: ${paid}`) + + process.exit(0) })() diff --git a/src/examples/ExecuteAgreement.ts b/src/examples/ExecuteAgreement.ts index c48e783..7dd5d8d 100644 --- a/src/examples/ExecuteAgreement.ts +++ b/src/examples/ExecuteAgreement.ts @@ -6,7 +6,6 @@ import {Account, Logger, Ocean, ServiceAgreement} from "../squid" import config from "./config" (async () => { - const ocean: Ocean = await Ocean.getInstance(config) const publisher: Account = (await ocean.getAccounts())[0] @@ -65,4 +64,5 @@ import config from "./config" publisher) Logger.log("ServiceAgreement Id:", serviceAgreement.getId()) + process.exit(0) })() diff --git a/src/examples/GetAccounts.ts b/src/examples/GetAccounts.ts index d895761..9f14d23 100644 --- a/src/examples/GetAccounts.ts +++ b/src/examples/GetAccounts.ts @@ -2,10 +2,11 @@ import {Logger, Ocean} from "../squid" import config from "./config" (async () => { - const ocean: Ocean = await Ocean.getInstance(config) const accounts = await ocean.getAccounts() Logger.log(JSON.stringify(accounts, null, 2)) + + process.exit(0) })() diff --git a/src/examples/GetBalance.ts b/src/examples/GetBalance.ts index 1961943..308f8b4 100644 --- a/src/examples/GetBalance.ts +++ b/src/examples/GetBalance.ts @@ -7,4 +7,6 @@ import config from "./config" const accounts = await ocean.getAccounts() Logger.log(await accounts[0].getBalance()) + + process.exit(0) })() diff --git a/src/examples/GetHDWalletAccounts.ts b/src/examples/GetHDWalletAccounts.ts index e285e2e..9f14d23 100644 --- a/src/examples/GetHDWalletAccounts.ts +++ b/src/examples/GetHDWalletAccounts.ts @@ -7,4 +7,6 @@ import config from "./config" const accounts = await ocean.getAccounts() Logger.log(JSON.stringify(accounts, null, 2)) + + process.exit(0) })() diff --git a/src/examples/GrantAccess.ts b/src/examples/GrantAccess.ts index f9e3b97..ecc2237 100644 --- a/src/examples/GrantAccess.ts +++ b/src/examples/GrantAccess.ts @@ -71,4 +71,6 @@ import config from "./config" const accessGranted = await serviceAgreement.grantAccess(did.getId(), did.getId(), publisher) Logger.log(`Asset access granted: ${accessGranted}`) + + process.exit(0) })() diff --git a/src/examples/InitializeAgreement.ts b/src/examples/InitializeAgreement.ts index c69d4f8..e936312 100644 --- a/src/examples/InitializeAgreement.ts +++ b/src/examples/InitializeAgreement.ts @@ -67,4 +67,5 @@ import config from "./config" consumer, ) + process.exit(0) })() diff --git a/src/examples/RegisterAsset.ts b/src/examples/RegisterAsset.ts index e13a821..2b91a8e 100644 --- a/src/examples/RegisterAsset.ts +++ b/src/examples/RegisterAsset.ts @@ -5,7 +5,6 @@ import {Account, Logger, Ocean} from "../squid" import config from "./config" (async () => { - const ocean: Ocean = await Ocean.getInstance(config) const publisher: Account = (await ocean.getAccounts())[0] @@ -42,4 +41,6 @@ import config from "./config" const ddo: DDO = await ocean.registerAsset(metaData, publisher) Logger.log(ddo.id) + + process.exit(0) })() diff --git a/src/examples/RegisterServiceAgreementTemplates.ts b/src/examples/RegisterServiceAgreementTemplates.ts index e0d23af..3a3e03f 100644 --- a/src/examples/RegisterServiceAgreementTemplates.ts +++ b/src/examples/RegisterServiceAgreementTemplates.ts @@ -2,7 +2,6 @@ import {Account, Logger, Ocean, ServiceAgreementTemplate, Templates} from "../sq import config from "./config" (async () => { - const ocean: Ocean = await Ocean.getInstance(config) const templateOwner: Account = (await ocean.getAccounts())[0] @@ -12,4 +11,6 @@ import config from "./config" Logger.log("ServiceAgreementTemplate registered:", serviceAgreementRegistered, "templateId:", serviceAgreementTemplate.getId()) + + process.exit(0) })() diff --git a/src/examples/Search.ts b/src/examples/Search.ts index c056291..8f41312 100644 --- a/src/examples/Search.ts +++ b/src/examples/Search.ts @@ -14,4 +14,6 @@ import config from "./config" }) Logger.log(names.length, names) + + process.exit(0) })() diff --git a/src/examples/SignAgreement.ts b/src/examples/SignAgreement.ts index 80668bc..0b9d792 100644 --- a/src/examples/SignAgreement.ts +++ b/src/examples/SignAgreement.ts @@ -77,4 +77,6 @@ import config from "./config" Logger.log("ServiceAgreement Id:", serviceAgreementResult.serviceAgreementId) Logger.log("ServiceAgreement Signature:", serviceAgreementResult.serviceAgreementSignature) + + process.exit(0) })() diff --git a/src/examples/config.ts b/src/examples/config.ts index bddea88..ebd8192 100644 --- a/src/examples/config.ts +++ b/src/examples/config.ts @@ -2,8 +2,8 @@ import * as HDWalletProvider from "truffle-hdwallet-provider" import Config from "../models/Config" import * as config from "./config/config.json" -if (false) { - const seedphrase = "xxx" +if (process.env.SEED_WORDS) { + const seedphrase = process.env.SEED_WORDS // @ts-ignore config.web3Provider = new HDWalletProvider( diff --git a/test/config.ts b/test/config.ts index f18bfa2..1a376d0 100644 --- a/test/config.ts +++ b/test/config.ts @@ -3,7 +3,7 @@ import Config from "../src/models/Config" export default { aquariusUri: "http://localhost:5000", brizoUri: "http://localhost:3000", - nodeUri: "http://localhost:8545", + nodeUri: `http://localhost:${process.env.ETH_PORT || 8545}`, parityUri: "http://localhost:9545", secretStoreUri: "http://localhost:12001", } as Config diff --git a/test/mocha.opts b/test/mocha.opts index 4b1f5d4..2500e57 100644 --- a/test/mocha.opts +++ b/test/mocha.opts @@ -3,5 +3,5 @@ --full-trace --bail --exit ---timeout 5000 +--timeout 20000 test/**/*.test.ts