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 2 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
3 changes: 1 addition & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
DAPI_CLIENT_SEEDS=ip1,ip2
DAPI_CLIENT_PORT=3000
DAPI_SEED=ip:port
shumkov marked this conversation as resolved.
Show resolved Hide resolved
FAUCET_PRIVATE_KEY=
NETWORK=
67 changes: 67 additions & 0 deletions bin/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env bash

set -ea

cmd_usage="Run test suite

Usage: run-test <seed> <faucet-private-key> [options]
shumkov marked this conversation as resolved.
Show resolved Hide resolved

<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 tp run
-h --help - show help

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

DAPI_SEED="$1"
FAUCET_PRIVATE_KEY="$2"

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

if [ -z "$FAUCET_PRIVATE_KEY" ] || [[ $FAUCET_PRIVATE_KEY == -* ]]
then
echo "Faucet private key 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#*=}"
;;
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_PRIVATE_KEY" npm run test:"$scope"
else
cd .. && DAPI_SEED="$DAPI_SEED" FAUCET_PRIVATE_KEY="$FAUCET_PRIVATE_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