Skip to content
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
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
.nyc_output

logs
db
scripts
node_modules

Expand Down
8 changes: 4 additions & 4 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
2 changes: 2 additions & 0 deletions db/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
2 changes: 2 additions & 0 deletions packages/platform-test-suite/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,5 @@ COPY --from=builder /platform /platform
RUN cp /platform/packages/platform-test-suite/.env.example /platform/packages/platform-test-suite/.env

EXPOSE 2500 2501 2510

ENTRYPOINT ["/platform/packages/platform-test-suite/bin/test.sh"]
30 changes: 20 additions & 10 deletions packages/platform-test-suite/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ To run using [Docker](https://www.docker.com/), make sure you have it installed.
Install all the necessary dependencies:

```sh
$ npm i
$ yarn
Comment thread
shumkov marked this conversation as resolved.
```

Use `./bin/test.sh` script to run tests:
Expand All @@ -38,16 +38,21 @@ Run test suite

Usage: test <seed> [options]

<seed> can be IP or IP:port
<seed> can be IP or IP:port (or pass via DAPI_SEED env)

Options:
--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
-n=network --network=network - use regtest, devnet or testnet
--skip-sync-before-height=H - start sync funding wallet from specific height
--dpns-tld-identity-private-key=private_key - top level identity private key
--dpns-tld-identity-id=identity_id - top level identity id
--dpns-contract-id=contract_id - dpns contract id
--dpns-tld-identity-id=tld_identity_id - top level identity id
--dpns-contract-id=tld_contract_id - dpns contract id
--feature-flags-identity-id=ff_identity_id - feature-flags contract id
--feature-flags-contract-id=ff_contract_id - feature-flags contract id
--faucet-wallet-use-storage=true - use persistent wallet storage for faucet
--faucet-wallet-storage-dir=absolute_dir - specify directory where faucet wallet persistent storage will be stored
-t --timeout - test timeout in milliseconds
-h --help - show help

Possible scopes:
Expand All @@ -66,22 +71,27 @@ Usage: test <seed> [options]
Just run pre-built image using the same arguments as [running locally](#running-locally):

```sh
$ docker run --network=host dashpay/platform-test-suite
$ docker run --network=host --env ./.env dashpay/platform-test-suite

Run test suite

Usage: test <seed> [options]

<seed> can be IP or IP:port
<seed> can be IP or IP:port (or pass via DAPI_SEED env)

Options:
--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
-n=network --network=network - use regtest, devnet or testnet
--skip-sync-before-height=H - start sync funding wallet from specific height
--dpns-tld-identity-private-key=private_key - top level identity private key
--dpns-tld-identity-id=identity_id - top level identity id
--dpns-contract-id=contract_id - dpns contract id
--dpns-tld-identity-id=tld_identity_id - top level identity id
--dpns-contract-id=tld_contract_id - dpns contract id
--feature-flags-identity-id=ff_identity_id - feature-flags contract id
--feature-flags-contract-id=ff_contract_id - feature-flags contract id
--faucet-wallet-use-storage=true - use persistent wallet storage for faucet
--faucet-wallet-storage-dir=absolute_dir - specify directory where faucet wallet persistent storage will be stored
-t --timeout - test timeout in milliseconds
-h --help - show help

Possible scopes:
Expand Down
36 changes: 23 additions & 13 deletions packages/platform-test-suite/bin/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ cmd_usage="Run test suite

Usage: test <seed> [options]

<seed> can be IP or IP:port
<seed> can be IP or IP:port (or pass via DAPI_SEED env)

Options:
--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
-n=network --network=network - use regtest, devnet or testnet
Expand All @@ -19,6 +18,8 @@ Usage: test <seed> [options]
--dpns-contract-id=tld_contract_id - dpns contract id
--feature-flags-identity-id=ff_identity_id - feature-flags contract id
--feature-flags-contract-id=ff_contract_id - feature-flags contract id
--faucet-wallet-use-storage=true - use persistent wallet storage for faucet
--faucet-wallet-storage-dir=absolute_dir - specify directory where faucet wallet persistent storage will be stored
-t --timeout - test timeout in milliseconds
-h --help - show help

Expand All @@ -32,7 +33,8 @@ Usage: test <seed> [options]
functional:core
functional:platform"

DAPI_SEED="$1"
FIRST_ARG="$1"
DAPI_SEED="${DAPI_SEED:=$FIRST_ARG}"
network="testnet"

DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
Expand All @@ -46,9 +48,6 @@ case ${i} in
echo "$cmd_usage"
exit 0
;;
--npm-install=*)
npm_package_to_install="${i#*=}"
;;
-s=*|--scope=*)
scope="${i#*=}"
;;
Expand Down Expand Up @@ -79,6 +78,12 @@ case ${i} in
-t=*|--timeout=*)
timeout="${i#*=}"
;;
--faucet-wallet-storage-dir=*)
faucet_wallet_storage_dir="${i#*=}"
;;
--faucet-wallet-use-storage=*)
faucet_wallet_use_storage="${i#*=}"
;;
esac
done

Expand All @@ -96,12 +101,6 @@ then
exit 1
fi

if [ -n "$npm_package_to_install" ]
then
npm install "$npm_package_to_install"
npm dedupe
fi

if [ -n "$scope" ]
then
scope_dirs=""
Expand Down Expand Up @@ -187,11 +186,22 @@ then
cmd="${cmd} DPNS_TOP_LEVEL_IDENTITY_PRIVATE_KEY=${identity_private_key}"
fi

if [ -n "$faucet_wallet_use_storage" ]
then
cmd="${cmd} FAUCET_WALLET_USE_STORAGE=${faucet_wallet_use_storage}"
fi

if [ -n "$faucet_wallet_storage_dir" ]
then
cmd="${cmd} FAUCET_WALLET_STORAGE_DIR=${faucet_wallet_storage_dir}"
fi

if [ -n "$GITHUB_ACTIONS" ]
then
cmd="${cmd} NODE_ENV=test node_modules/.bin/mocha -b ${scope_dirs}"
else
cmd="${cmd} NODE_ENV=test mocha -b ${scope_dirs}"
echo $cmd
cmd="${cmd} NODE_ENV=test yarn mocha --inspect-brk -b ${scope_dirs}"
fi

if [ -n "$timeout" ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let faucetClient;
* @returns {Promise<Client>}
*/
async function createClientWithFundedWallet(HDPrivateKey = undefined, amount = 40000) {
const useFaucetWalletStorage = process.env.FAUCET_WALLET_USE_STORAGE === "true"
const useFaucetWalletStorage = process.env.FAUCET_WALLET_USE_STORAGE === 'true';
const seeds = getDAPISeeds();

const clientOpts = {
Expand Down
8 changes: 6 additions & 2 deletions packages/platform-test-suite/lib/test/createFaucetClient.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
const Dash = require('dash');
const path = require('path');

let storageAdapter;

if (typeof window === 'undefined') {
// eslint-disable-next-line global-require
const { NodeForage } = require('nodeforage');
storageAdapter = new NodeForage({ name: `faucet-wallet-${process.env.FAUCET_ADDRESS}` });
storageAdapter = new NodeForage({
dir: process.env.FAUCET_WALLET_STORAGE_DIR || process.cwd(),
name: `faucet-wallet-${process.env.FAUCET_ADDRESS}`,
});
} else {
// eslint-disable-next-line global-require
storageAdapter = require('localforage');
Expand Down Expand Up @@ -34,7 +38,7 @@ function createFaucetClient() {
privateKey: process.env.FAUCET_PRIVATE_KEY,
};

if (process.env.FAUCET_WALLET_USE_STORAGE === "true") {
if (process.env.FAUCET_WALLET_USE_STORAGE === 'true') {
walletOptions.adapter = storageAdapter;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/platform-test-suite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"localforage": "^1.10.0",
"mocha": "^9.1.2",
"net": "^1.0.2",
"nodeforage": "^1.1.1",
"nodeforage": "^1.1.2",
"os-browserify": "^0.3.0",
"path-browserify": "^1.0.1",
"process": "^0.11.10",
Expand Down
1 change: 1 addition & 0 deletions scripts/configure_test_suite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ echo "DAPI_SEED=127.0.0.1
FAUCET_ADDRESS=${FAUCET_ADDRESS}
FAUCET_PRIVATE_KEY=${FAUCET_PRIVATE_KEY}
FAUCET_WALLET_USE_STORAGE=${FAUCET_WALLET_USE_STORAGE}
FAUCET_WALLET_STORAGE_DIR="${PATH_TO_PROJECT_ROOT}/db"
DPNS_OWNER_PRIVATE_KEY=${DPNS_OWNER_PRIVATE_KEY}
FEATURE_FLAGS_OWNER_PRIVATE_KEY=${FEATURE_FLAGS_OWNER_PRIVATE_KEY}
DASHPAY_OWNER_PRIVATE_KEY=${DASHPAY_OWNER_PRIVATE_KEY}
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1758,7 +1758,7 @@ __metadata:
localforage: ^1.10.0
mocha: ^9.1.2
net: ^1.0.2
nodeforage: ^1.1.1
nodeforage: ^1.1.2
os-browserify: ^0.3.0
path-browserify: ^1.0.1
process: ^0.11.10
Expand Down Expand Up @@ -10879,16 +10879,16 @@ fsevents@~2.3.2:
languageName: node
linkType: hard

"nodeforage@npm:^1.1.1":
version: 1.1.1
resolution: "nodeforage@npm:1.1.1"
"nodeforage@npm:^1.1.2":
version: 1.1.2
resolution: "nodeforage@npm:1.1.2"
dependencies:
lodash.find: ^4.6.0
lodash.ismatch: ^4.4.0
lodash.merge: ^4.6.1
proper-lockfile: ^3.2.0
slocket: ^1.0.5
checksum: 0cb4e4aa853cb9cd81ec2c3aabb2a9032b68ec067cef0bc31b7f7b70522a0081983f730fecc9053d6911cb0114edc2d54201c296b5acf9ea85bf96cc016cbb22
checksum: a670ece8b5e486514bb859d3723d8998806a071f200315fc7457755617d37515ceba8c13b46d9aa644b3517271b561dc50b57a9325a5537cbb34bccdd418ded5
languageName: node
linkType: hard

Expand Down