Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

feat: test suite cli runner #27

Merged
merged 4 commits into from
Apr 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DAPI_CLIENT_SEEDS=ip1,ip2
DAPI_CLIENT_PORT=3000
# Dapi seed (format - ip:port)
DAPI_SEED=
FAUCET_PRIVATE_KEY=
NETWORK=
64 changes: 64 additions & 0 deletions bin/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env bash

set -ea

cmd_usage="Run test suite

Usage: test <seed> [options]

<seed> can be IP or IP:port

Options:
-ni=pkg --npm-install=pkg - install npm package before running the suite
-s=a,b,c --scope=a,b,c - test scope to run
-k=key --faucet-key=key - faucet private key string
-h --help - show help

Possible scopes:
e2e
functional
core
platform
e2e:dpns
e2e:contacts
functional:core
functional:platform"

DAPI_SEED="$1"

if [ -z "$DAPI_SEED" ] || [[ $DAPI_SEED == -* ]]
then
echo "Seed is not specified"
exit 0
fi

for i in "$@"
do
case ${i} in
-h|--help)
echo "$cmd_usage"
exit 0
;;
-ni=*|--npm-install=*)
npm_package_to_install="${i#*=}"
;;
-s=*|--scope=*)
scope="${i#*=}"
;;
-k=*|--faucet-key=*)
faucet_key="${i#*=}"
;;
esac
done

if [ -n "$npm_package_to_install" ]
then
cd .. && npm install "$npm_package_to_install"
fi

if [ -n "$scope" ]
then
cd .. && DAPI_SEED="$DAPI_SEED" FAUCET_PRIVATE_KEY="$faucet_key" npm run test:"$scope"
else
cd .. && DAPI_SEED="$DAPI_SEED" FAUCET_PRIVATE_KEY="$faucet_key" npm run test
fi
11 changes: 11 additions & 0 deletions lib/test/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const dotenvSafe = require('dotenv-safe');
const { expect, use } = require('chai');
const dirtyChai = require('dirty-chai');
const chaiAsPromised = require('chai-as-promised');
const Dash = require('dash');

use(chaiAsPromised);
use(dirtyChai);
Expand All @@ -14,3 +15,13 @@ dotenvSafe.config({
});

global.expect = expect;

const seeds = [{ service: process.env.DASHJS_SEED }];

global.dashClient = new Dash.Client({
seeds,
});

before(async () => {
await global.dashClient.isReady();
});
Loading