Skip to content

Commit

Permalink
refactor(indy-sdk)!: remove indy-sdk package (#1629)
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Glastra <timo@animo.id>
Co-authored-by: Ariel Gentile <gentilester@gmail.com>
  • Loading branch information
TimoGlastra and genaris committed Jan 31, 2024
1 parent 867a5fb commit 0feda53
Show file tree
Hide file tree
Showing 242 changed files with 2,058 additions and 10,727 deletions.
18 changes: 0 additions & 18 deletions .devcontainer/Dockerfile

This file was deleted.

4 changes: 1 addition & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"build": {
"dockerfile": "Dockerfile"
},
"image": "node:18",
"runArgs": ["--env-file", ".devcontainer/devcontainer.env"],
"workspaceMount": "source=${localWorkspaceFolder},target=/work,type=bind",
"workspaceFolder": "/work"
Expand Down
14 changes: 0 additions & 14 deletions .github/actions/setup-cheqd/action.yml

This file was deleted.

36 changes: 0 additions & 36 deletions .github/actions/setup-indy-pool/action.yml

This file was deleted.

18 changes: 0 additions & 18 deletions .github/actions/setup-libindy/action.yml

This file was deleted.

21 changes: 0 additions & 21 deletions .github/actions/setup-postgres-wallet-plugin/action.yml

This file was deleted.

12 changes: 0 additions & 12 deletions .github/actions/setup-postgres/action.yml

This file was deleted.

8 changes: 0 additions & 8 deletions .github/workflows/continuous-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ jobs:
# pulls all commits (needed for lerna to correctly version)
fetch-depth: 0

# setup dependencies
- name: Setup Libindy
uses: ./.github/actions/setup-libindy

- name: Setup NodeJS
uses: actions/setup-node@v4
with:
Expand Down Expand Up @@ -69,10 +65,6 @@ jobs:
- name: Checkout credo
uses: actions/checkout@v4

# setup dependencies
- name: Setup Libindy
uses: ./.github/actions/setup-libindy

- name: Setup NodeJS
uses: actions/setup-node@v4
with:
Expand Down
34 changes: 3 additions & 31 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ on:
workflow_dispatch:

env:
TEST_AGENT_PUBLIC_DID_SEED: 000000000000000000000000Trustee9
ENDORSER_AGENT_PUBLIC_DID_SEED: 00000000000000000000000Endorser9
GENESIS_TXN_PATH: network/genesis/local-genesis.txn
LIB_INDY_STRG_POSTGRES: /home/runner/work/credo-ts/indy-sdk/experimental/plugins/postgres_storage/target/release # for Linux
NODE_OPTIONS: --max_old_space_size=6144

# Make sure we're not running multiple release steps at the same time as this can give issues with determining the next npm version to release.
Expand Down Expand Up @@ -53,10 +49,6 @@ jobs:
- name: Checkout credo-ts
uses: actions/checkout@v4

# setup dependencies
- name: Setup Libindy
uses: ./.github/actions/setup-libindy

- name: Setup NodeJS
uses: actions/setup-node@v4
with:
Expand Down Expand Up @@ -91,24 +83,8 @@ jobs:
uses: actions/checkout@v4

# setup dependencies

- name: Setup Libindy
uses: ./.github/actions/setup-libindy

- name: Setup Indy Pool
uses: ./.github/actions/setup-indy-pool
with:
seed: ${TEST_AGENT_PUBLIC_DID_SEED}
endorserSeed: ${ENDORSER_AGENT_PUBLIC_DID_SEED}

- name: Setup Cheqd
uses: ./.github/actions/setup-cheqd

- name: Setup Postgres
uses: ./.github/actions/setup-postgres

- name: Setup Postgres wallet plugin
uses: ./.github/actions/setup-postgres-wallet-plugin
- name: Setup services
run: docker compose up -d

- name: Setup NodeJS
uses: actions/setup-node@v4
Expand All @@ -120,7 +96,7 @@ jobs:
run: yarn install --frozen-lockfile

- name: Run tests
run: TEST_AGENT_PUBLIC_DID_SEED=${TEST_AGENT_PUBLIC_DID_SEED} ENDORSER_AGENT_PUBLIC_DID_SEED=${ENDORSER_AGENT_PUBLIC_DID_SEED} GENESIS_TXN_PATH=${GENESIS_TXN_PATH} yarn test --coverage --forceExit --bail
run: yarn test --coverage --forceExit --bail

- uses: codecov/codecov-action@v3
if: always()
Expand All @@ -138,10 +114,6 @@ jobs:
fetch-depth: 0
persist-credentials: false

# setup dependencies
- name: Setup Libindy
uses: ./.github/actions/setup-libindy

- name: Setup NodeJS
uses: actions/setup-node@v4
with:
Expand Down
107 changes: 19 additions & 88 deletions DEVREADME.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,74 +18,22 @@ GENESIS_TXN_PATH=/work/network/genesis/local-genesis.txn

## Running tests

Test are executed using jest. Some test require either the **mediator agents** or the **ledger** to be running. When running tests that require a connection to the ledger pool, you need to set the `TEST_AGENT_PUBLIC_DID_SEED`, `ENDORSER_AGENT_PUBLIC_DID_SEED` and `GENESIS_TXN_PATH` environment variables.
Test are executed using jest. Some test require the **indy ledger**, **cheqd ledger** or **postgres database** to be running.

### Setting environment variables

If you're using the setup as described in this document, you don't need to provide any environment variables as the default will be sufficient.

- `GENESIS_TXN_PATH`: The path to the genesis transaction that allows us to connect to the indy pool.
- `GENESIS_TXN_PATH=network/genesis/local-genesis.txn` - default. Works with the [ledger setup](#setup-indy-ledger) from the previous step.
- `GENESIS_TXN_PATH=network/genesis/builder-net-genesis.txn` - Sovrin BuilderNet genesis.
- `GENESIS_TXN_PATH=/path/to/any/ledger/you/like`
- `TEST_AGENT_PUBLIC_DID_SEED`: The seed to use for the public DID. This will be used to do public write operations to the ledger. You should use a seed for a DID that is already registered on the ledger.
- If using the local or default genesis, use the same seed you used for the `add-did-from-seed` command from the [ledger setup](#setup-indy-ledger) in the previous step. (default is `000000000000000000000000Trustee9`)
- If using the BuilderNet genesis, make sure your seed is registered on the BuilderNet using [selfserve.sovrin.org](https://selfserve.sovrin.org/) and you have read and accepted the associated [Transaction Author Agreement](https://github.com/sovrin-foundation/sovrin/blob/master/TAA/TAA.md). We are not responsible for any unwanted consequences of using the BuilderNet.
- `ENDORSER_AGENT_PUBLIC_DID_SEED`: The seed to use for the public Endorser DID. This will be used to endorse transactions. You should use a seed for a DID that is already registered on the ledger.
- If using the local or default genesis, use the same seed you used for the `add-did-from-seed` command from the [ledger setup](#setup-indy-ledger) in the previous step. (default is `00000000000000000000000Endorser9`)
- If using the BuilderNet genesis, make sure your seed is registered on the BuilderNet using [selfserve.sovrin.org](https://selfserve.sovrin.org/) and you have read and accepted the associated [Transaction Author Agreement](https://github.com/sovrin-foundation/sovrin/blob/master/TAA/TAA.md). We are not responsible for any unwanted consequences of using the BuilderNet.

### Setup Postgres
When running tests that require a connection to the indy ledger pool, you can set the `TEST_AGENT_PUBLIC_DID_SEED`, `ENDORSER_AGENT_PUBLIC_DID_SEED` and `GENESIS_TXN_PATH` environment variables.

> Note: Setup the postgres plugin first by following the [docs](https://https://credo.js.org/)
### Quick Setup

```sh
# Get postgres docker image
docker pull postgres

# Run postgres in docker
docker run --name postgres -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 -d postgres
```

### Setup Indy Ledger

For testing we've added a setup to this repo that allows you to quickly setup an indy ledger.
To quickly set up all services needed to run tests (Postgres, Hyperledger Indy Ledger, and Cheqd Ledger), run the following command:

```sh
# Build indy pool
docker build -f network/indy-pool.dockerfile -t indy-pool . --platform linux/amd64

# NOTE: If you are on an ARM (M1) mac use the `network/indy-pool-arm.dockerfile` instead
# docker build -f network/indy-pool-arm.dockerfile -t indy-pool . --platform linux/arm64/v8

# Start indy pool
docker run -d --rm --name indy-pool -p 9701-9708:9701-9708 indy-pool

# Setup CLI. This creates a wallet, connects to the ledger and sets the Transaction Author Agreement
docker exec indy-pool indy-cli-setup

# DID and Verkey from seed. Set 'ENDORSER' role in order to be able to register public DIDs
docker exec indy-pool add-did-from-seed 00000000000000000000000Endorser9 ENDORSER

# DID and Verkey from seed. Set 'Trustee'
docker exec indy-pool add-did-from-seed 000000000000000000000000Trustee9 TRUSTEE

# If you want to register using the DID/Verkey you can use
# docker exec indy-pool add-did "NkGXDEPgpFGjQKMYmz6SyF" "CrSA1WbYYWLJoHm16Xw1VEeWxFvXtWjtsfEzMsjB5vDT"
docker compose up -d
```

### Setup Cheqd Ledger

In addition, there's also a docker command to run a cheqd test network.
If you're running on an ARM based machine (such as Apple Silicon), you can use the `docker-compose.arm.yml` file instead:

```sh
docker run --rm -d -p 26657:26657 ghcr.io/cheqd/cheqd-testnet:latest
```

If you want to run tests without the cheqd ledger, you can use the following ignore pattern:

```sh
yarn test --testPathIgnorePatterns packages/cheqd
docker compose -f docker-compose.arm.yml up -d
```

### Run all tests
Expand All @@ -96,34 +44,17 @@ You can run the tests using the following command.
yarn test
```

If you're not using the ledger setup from above, make sure you pass the correct environment variables from [Setting environment variables](#setting-environment-variables) for connecting to the indy **ledger** pool.

```sh
GENESIS_TXN_PATH=network/genesis/local-genesis.txn TEST_AGENT_PUBLIC_DID_SEED=000000000000000000000000Trustee9 ENDORSER_AGENT_PUBLIC_DID_SEED=00000000000000000000000Endorser9 yarn test
```

Locally, you might want to run the tests without postgres tests. You can do that by ignoring the tests:

```sh
yarn test --testPathIgnorePatterns postgres.e2e.test.ts
```

In case you run into trouble running the tests, e.g. complaining about snapshots not being up-to-date, you can try and remove the data stored for the indy-client or Credo. Note this removes all wallets and data, so make sure you're okay with all data being removed. On a Unix system with default setup you achieve this by running:

```sh
rm -rf ~/.indy-client ~/.afj
```

## Usage with Docker

If you don't want to install the libindy dependencies yourself, or want a clean environment when running the framework or tests you can use docker.

Make sure you followed the [local ledger setup](#setup-indy-ledger) to setup a local indy pool inside docker.
### Setting environment variables

```sh
# Builds the framework docker image with all dependencies installed
docker build -t credo .
If you're using the setup as described in this document, you don't need to provide any environment variables as the default will be sufficient.

# Run test with ledger pool
docker run -it --rm --network host credo yarn test
```
- `GENESIS_TXN_PATH`: The path to the genesis transaction that allows us to connect to the indy pool.
- `GENESIS_TXN_PATH=network/genesis/local-genesis.txn` - default. Works with the [ledger setup](#setup-indy-ledger) from the previous step.
- `GENESIS_TXN_PATH=network/genesis/builder-net-genesis.txn` - Sovrin BuilderNet genesis.
- `GENESIS_TXN_PATH=/path/to/any/ledger/you/like`
- `TEST_AGENT_PUBLIC_DID_SEED`: The seed to use for the public DID. This will be used to do public write operations to the ledger. You should use a seed for a DID that is already registered on the ledger.
- If using the local or default genesis, use the same seed you used for the `add-did-from-seed` command from the [ledger setup](#setup-indy-ledger) in the previous step. (default is `000000000000000000000000Trustee9`)
- If using the BuilderNet genesis, make sure your seed is registered on the BuilderNet using [selfserve.sovrin.org](https://selfserve.sovrin.org/) and you have read and accepted the associated [Transaction Author Agreement](https://github.com/sovrin-foundation/sovrin/blob/master/TAA/TAA.md). We are not responsible for any unwanted consequences of using the BuilderNet.
- `ENDORSER_AGENT_PUBLIC_DID_SEED`: The seed to use for the public Endorser DID. This will be used to endorse transactions. You should use a seed for a DID that is already registered on the ledger.
- If using the local or default genesis, use the same seed you used for the `add-did-from-seed` command from the [ledger setup](#setup-indy-ledger) in the previous step. (default is `00000000000000000000000Endorser9`)
- If using the BuilderNet genesis, make sure your seed is registered on the BuilderNet using [selfserve.sovrin.org](https://selfserve.sovrin.org/) and you have read and accepted the associated [Transaction Author Agreement](https://github.com/sovrin-foundation/sovrin/blob/master/TAA/TAA.md). We are not responsible for any unwanted consequences of using the BuilderNet.
Loading

0 comments on commit 0feda53

Please sign in to comment.