Skip to content

Commit

Permalink
Merge pull request #2 from KILTprotocol/aa/integration-tests
Browse files Browse the repository at this point in the history
feat: add basic integration tests
  • Loading branch information
ntn-x2 authored Dec 1, 2023
2 parents c92aa09 + edd45b8 commit 089bda9
Show file tree
Hide file tree
Showing 21 changed files with 2,494 additions and 619 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"builtin",
"external",
"internal",
["index", "parent", "sibling"],
["index", "sibling"],
"object",
"type"
],
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Lint and Build

on:
push:
branches:
- "main"
paths:
- "**.ts"
pull_request:
branches:
- "**"

jobs:
lint-and-build:
runs-on: ubuntu-latest

steps:
- name: Download source
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
cache: "yarn"
- name: Install dependencies
run: yarn install
- name: Lint
run: yarn lint
- name: Check dependency duplication
run: if ! yarn dedupe --check; then echo "::warning ::Dependencies may be deduplicated"; fi;
- name: Check versioning
run: yarn version check
- name: Try build for CJS and ESM
run: yarn build
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ cjs
# VSCode

.vscode

# Tests
.env.*
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
lts/Gallium
lts/Hydrogen
2 changes: 2 additions & 0 deletions .yarn/versions/06802af5.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declined:
- "@kiltprotocol/dip-sdk"
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,19 @@ YARN:
```
yarn add @kiltprotocol/dip-sdk
```

## End-to-end testing

The end-to-end testing use a Zombienet-based setup with a Kubernetes provider.
Hence, a Kubernetes cluster, e.g., [minikube](https://minikube.sigs.k8s.io/docs/start/) must be installed on the machine where the tests are to be executed.
For more information on how to set up the machine to spawn Zombienet-based network, please refer to the [official Zombienet repository](https://github.com/paritytech/zombienet).

### Test execution

Test execution requires the following steps:

1. Switch to the expected Node version with `nvm use`
2. Install the repo dependencies with `yarn install`
3. Spin up the Zombienet network with `yarn test:e2e:deploy`.
4. Once the network deployment is complete, create a `.env.test` file with `RELAY_ADDRESS`, `PROVIDER_ADDRESS`, and `CONSUMER_ADDRESS` values pointing to the started nodes for relaychain, provider chain and consumer chain respectively.
5. Run the end-to-end tests with `yarn test:e2e`.
23 changes: 14 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,26 @@
"bugs": "https://github.com/KILTprotocol/dip-sdk/issues",
"description": "An SDK to help integration of the KILT Decentralized Identity Provider (DIP) protocol using KILT as an Identity Provider.",
"dependencies": {
"@kiltprotocol/did": "0.34.0-dip-1",
"@kiltprotocol/types": "0.34.0-dip-1",
"@kiltprotocol/did": "0.34.0-dip-2",
"@kiltprotocol/types": "0.34.0-dip-2",
"@polkadot/api": "^10.10.1",
"@polkadot/util": "^12.5.1",
"typescript-object-builder": "^0.3.0"
"@polkadot/util": "^12.5.1"
},
"devDependencies": {
"@kiltprotocol/sdk-js": "0.34.0-dip-2",
"@types/node": "^20.9.4",
"@typescript-eslint/eslint-plugin": "^6.2.0",
"@typescript-eslint/parser": "^6.2.0",
"@zombienet/cli": "^1.3.82",
"bn.js": "^5.2.1",
"dotenv": "^16.3.1",
"eslint": "^8.45.0",
"eslint-config-prettier": "^8.9.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-license-header": "^0.6.0",
"prettier": "^3.0.0",
"rimraf": "^5.0.1",
"typescript": "^5.1.6",
"typescript": "^5.3.2",
"vitest": "^0.33.0"
},
"engines": {
Expand All @@ -41,14 +45,15 @@
"scripts": {
"build": "yarn build:cjs && yarn build:esm",
"build:cjs": "run -T tsc -p tsconfig.cjs.json && echo '{\"type\": \"commonjs\"}' > ./dist/cjs/package.json",
"build:esm": "run -T tsc -p tsconfig.json && echo '{\"type\": \"module\"}' > ./dist/esm/package.json",
"check": "tsc -p tsconfig.check.json",
"build:esm": "run -T tsc -p tsconfig.esm.json && echo '{\"type\": \"module\"}' > ./dist/esm/package.json",
"check": "tsc -p tsconfig.json",
"clean": "yarn rimraf -g */{cjs,esm}",
"lint": "eslint --ext .ts . && prettier -c .",
"lint:fix": "prettier -w . && eslint --fix --ext .ts .",
"test:e2e": "vitest run tests",
"prepublish": "yarn exec cp -f ../../LICENSE .",
"publish": "yarn npm publish --access=public --tolerate-republish"
"publish": "yarn npm publish --access=public",
"test:e2e": "yarn build && vitest run tests",
"test:e2e:deploy": "yarn zombienet --spawn-concurrency 3 spawn tests/zombienet/network.toml"
},
"stableVersion": "0.0.0",
"type": "module",
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
*/

/**
* @module @kiltprotocol/dip
* @module @kiltprotocol/dip-sdk
*/

export * from "./parent.js"
export * from "./runtime.js"
export * from "./sibling.js"
export * from "./utils.js"
197 changes: 0 additions & 197 deletions src/parent.ts

This file was deleted.

29 changes: 29 additions & 0 deletions src/runtime.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Copyright (c) 2023, BOTLabs GmbH.
*
* This source code is licensed under the BSD 4-Clause "Original" license
* found in the LICENSE file in the root directory of this source tree.
*/

import type { DefinitionsCall } from "@polkadot/types/types"

export const dipProviderCalls: DefinitionsCall = {
DipProvider: [
{
methods: {
generate_proof: {
description:
"Generate a Merkle proof for the DIP protocol for the specified request parameters.",
params: [
{
name: "request",
type: "DipProofRequest",
},
],
type: "Result<CompleteMerkleProof, RuntimeApiDipProofError>",
},
},
version: 1,
},
],
}
Loading

0 comments on commit 089bda9

Please sign in to comment.