Skip to content

Commit

Permalink
build(js): use local network
Browse files Browse the repository at this point in the history
Signed-off-by: blu3beri <blu3beri@proton.me>
  • Loading branch information
blu3beri committed May 27, 2023
1 parent 628bf66 commit f47b27a
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 29 deletions.
19 changes: 14 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ jobs:
build-javascript:
name: Build and Test JavaScript wrapper
needs: [build-release]
# needs: [build-release]
runs-on: ubuntu-latest
defaults:
run:
Expand All @@ -223,10 +223,10 @@ jobs:
with:
node-version: 16.x

- name: Fetch library artifacts
uses: actions/download-artifact@v3
with:
name: library-linux-x86_64
# - name: Fetch library artifacts
# uses: actions/download-artifact@v3
# with:
# name: library-linux-x86_64

- name: Install dependencies
run: yarn install
Expand All @@ -243,6 +243,15 @@ jobs:
- name: Check types
run: yarn check-types

- name: Run local node pool
run: |
cd ../../
docker build -f ci/indy-pool.dockerfile -t test_pool --build-arg pool_ip=10.0.0.2 ci
docker network create --subnet=10.0.0.0/8 indy-sdk-network
docker run -d --name indy_pool -p 9701-9708:9701-9708 --net=indy-sdk-network test_pool
cd wrappers/javascript
docker exec $(docker ps -aqf "ancestor=test_pool") cat /var/lib/indy/sandbox/pool_transactions_genesis >> genesis.txn
- name: Run tests
env:
# binary is downloaded to root of repository
Expand Down
15 changes: 13 additions & 2 deletions wrappers/javascript/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ module.exports = {
},
overrides: [
{
files: ['arch.js'],
env: { node: true },
files: ['arch.js', 'platform.js'],
env: {
node: true,
},
rules: {
'@typescript-eslint/no-unsafe-assignment': 'off',
'no-console': 'off',
Expand All @@ -91,5 +93,14 @@ module.exports = {
'@typescript-eslint/no-unsafe-call': 'off',
},
},
{
files: ['**.test.**'],
env: {
node: true,
},
rules: {
'@typescript-eslint/no-unsafe-assignment': 'off',
},
},
],
}
18 changes: 18 additions & 0 deletions wrappers/javascript/indy-vdr-nodejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,22 @@ const getSchemaRequest = new GetSchemaRequest({
const schemaResponse = await pool.submitRequest(getSchemaRequest)
```

## Testing

In order to test this library, you need a local indy network running. This can be done with the following commands (from the root of the repository):

```sh
docker build -f ci/indy-pool.dockerfile -t test_pool --build-arg pool_ip=10.0.0.2 ci
docker network create --subnet=10.0.0.0/8 indy-sdk-network
docker run -d --name indy_pool -p 9701-9708:9701-9708 --net=indy-sdk-network test_pool

# Network is now running

cd wrappers/javascript

docker exec $(docker ps -aqf "ancestor=test_pool") cat /var/lib/indy/sandbox/pool_transactions_genesis >> genesis.txn

yarn test:local-build
```

> **Note**: If you want to use this library in a cross-platform environment you need to import methods from the `@hyperledger/indy-vdr-shared` package instead. This is a platform independent package that allows to register the native bindings. The `@hyperledger/indy-vdr-nodejs` package uses this package under the hood. See the [Indy VDR Shared README](https://github.com/hyperledger/indy-vdr/tree/main/wrappers/javascript/indy-vdr-shared/README.md) for documentation on how to use this package.
4 changes: 0 additions & 4 deletions wrappers/javascript/indy-vdr-nodejs/scripts/platform.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable no-console */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable no-undef */
const os = require('os')

// Find appropriate target architecture for retrieving the anoncreds library
Expand Down
7 changes: 2 additions & 5 deletions wrappers/javascript/indy-vdr-nodejs/tests/IndyVdrPool.test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
// TODO: this should be turned off at a eslint config level for tests
/* eslint-disable @typescript-eslint/no-unsafe-assignment */

import type { IndyVdrPool } from '@hyperledger/indy-vdr-nodejs'

import { SOVRIN_GENESIS_TRANSACTION_BUILDER_NET } from './utils'
import { genesisTxnPath } from './utils'

import { PoolCreate } from '@hyperledger/indy-vdr-nodejs'

describe('IndyVdrPool', () => {
let pool: IndyVdrPool

beforeAll(() => {
pool = new PoolCreate({ parameters: { transactions: SOVRIN_GENESIS_TRANSACTION_BUILDER_NET } })
pool = new PoolCreate({ parameters: { transactions_path: genesisTxnPath } })
})

test('Get pool handle', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */

import type { IndyVdrRequest } from '@hyperledger/indy-vdr-nodejs'

import { DID, SCHEMA_ID } from './utils'
Expand Down
11 changes: 2 additions & 9 deletions wrappers/javascript/indy-vdr-nodejs/tests/utils/fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
export const SOVRIN_GENESIS_TRANSACTION_BUILDER_NET = `
{"reqSignature":{},"txn":{"data":{"data":{"alias":"FoundationBuilder","blskey":"3gmhmqpPLqznZF3g3niodaHjbpsB6TEeE9SpgXgBnZJLmXgeRzJqTLajVwbhxrkomJFTFU4ohDC4ZRXKbUPCQywJuPAQnst8XBtCFredMECn4Z3goi1mNt5QVRdU8Ue2xMSkdLpsQMjCsNwYUsBguwXYUQnDXQXnHqRkK9qrivucQ5Z","blskey_pop":"RHWacPhUNc9JWsGNdmWYHrAvvhsow399x3ttNKKLDpz9GkxxnTKxtiZqarkx4uP5ByTwF4kM8nZddFKWuzoKizVLttALQ2Sc2BNJfRzzUZMNeQSnESkKZ7U5vE2NhUDff6pjANczrrDAXd12AjSG61QADWdg8CVciZFYtEGmKepwzP","client_ip":"35.161.146.16","client_port":"9702","node_ip":"50.112.53.5","node_port":"9701","services":["VALIDATOR"]},"dest":"GVvdyd7Y6hsBEy5yDDHjqkXgH8zW34K74RsxUiUCZDCE"},"metadata":{"from":"V5qJo72nMeF7x3ci8Zv2WP"},"type":"0"},"txnMetadata":{"seqNo":1,"txnId":"fe991cd590fff10f596bb6fe2362229de47d49dd50748e38b96f368152be29c7"},"ver":"1"}
{"reqSignature":{},"txn":{"data":{"data":{"alias":"vnode1","blskey":"t5jtREu8au2dwFwtH6QWopmTGxu6qmJ3iSnk321yLgeu7mHQRXf2ZCBuez8KCAQvFZGqqAoy2FcYvDGCqQxRCz9qXKgiBtykzxjDjYu87JECwwddnktz5UabPfZmfu6EoDn4rFxvd4myPu2hksb5Z9GT6UeoEYi7Ub3yLFQ3xxaQXc","blskey_pop":"QuHB7tiuFBPQ6zPkwHfMtjzWqXJBLACtfggm7zCRHHgdva18VN4tNg7LUU2FfKGQSLZz1M7oRxhhgJkZLL19aGvaHB2MPtnBWK9Hr8LMiwi95UjX3TVXJri4EvPjQ6UUvHrjZGUFvKQphPyVTMZBJwfkpGAGhpbTQuQpEH7f56m1X5","client_ip":"206.189.143.34","client_port":"9796","node_ip":"206.189.143.34","node_port":"9797","services":["VALIDATOR"]},"dest":"9Aj2LjQ2fwszJRSdZqg53q5e6ayScmtpeZyPGgKDswT8"},"metadata":{"from":"FzAaV9Waa1DccDa72qwg13"},"type":"0"},"txnMetadata":{"seqNo":2,"txnId":"5afc282bf9a7a5e3674c09ee48e54d73d129aa86aa226691b042e56ff9eaf59b"},"ver":"1"}
{"reqSignature":{},"txn":{"data":{"data":{"alias":"xsvalidatorec2irl","blskey":"4ge1yEvjdcV6sDSqbevqPRWq72SgkZqLqfavBXC4LxnYh4QHFpHkrwzMNjpVefvhn1cgejHayXTfTE2Fhpu1grZreUajV36T6sT4BiewAisdEw59mjMxkp9teYDYLQqwPUFPgaGKDbFCUBEaNdAP4E8Q4UFiF13Qo5842pAY13mKC23","blskey_pop":"R5PoEfWvni5BKvy7EbUbwFMQrsgcuzuU1ksxfvySH6FC5jpmisvcHMdVNik6LMvAeSdt6K4sTLrqnaaQCf5aCHkeTcQRgDVR7oFYgyZCkF953m4kSwUM9QHzqWZP89C6GkBx6VPuL1RgPahuBHDJHHiK73xLaEJzzFZtZZxwoWYABH","client_ip":"52.50.114.133","client_port":"9702","node_ip":"52.209.6.196","node_port":"9701","services":["VALIDATOR"]},"dest":"DXn8PUYKZZkq8gC7CZ2PqwECzUs2bpxYiA5TWgoYARa7"},"metadata":{"from":"QuCBjYx4CbGCiMcoqQg1y"},"type":"0"},"txnMetadata":{"seqNo":3,"txnId":"1972fce7af84b7f63b7f0c00495a84425cce3b0c552008576e7996524cca04cb"},"ver":"1"}
{"reqSignature":{},"txn":{"data":{"data":{"alias":"danube","blskey":"3Vt8fxn7xg8n8pR872cvGWNuR7STFzFSPMftX96zF6871wYVTR27aspxGSeEtx9wj8g4D3GdCxHJbQ4FsxQz6TATQswiiZfxAVNjLLUci8WSH4t1GPx9CvGXB2uzDfVnnJyhhnASxJEbvykLUBBFG3fW4tMQixujpowUADz5jHm427u","blskey_pop":"RJpXXLkjRRv9Lk8tJz8LTkhhC7RWjHQcB9CG8J8U8fXT6arTDMYc62zXtToBAmGkGu8Udsmo3Hh7mv4KB9JAf8ufGY9WsnppCVwar7zEXyBfLpCnDhvVcBAzkhRpHmqHygN24DeBu9aH6tw4uXxVJvRRGSbPtxjWa379BmfQWzXHCb","client_ip":"207.180.207.73","client_port":"9702","node_ip":"173.249.14.196","node_port":"9701","services":["VALIDATOR"]},"dest":"52muwfE7EjTGDKxiQCYWr58D8BcrgyKVjhHgRQdaLiMw"},"metadata":{"from":"VbPQNHsvoLZdaNU7fTBeFx"},"type":"0"},"txnMetadata":{"seqNo":4,"txnId":"ebf340b317c044d970fcd0ca018d8903726fa70c8d8854752cd65e29d443686c"},"ver":"1"}
`
import path from 'path'

export const genesisTxnPath = path.join(__dirname, '../../../genesis.txn')
export const DID = 'PqdUtwWhuX4GWRa58WSdvn'

export const SCHEMA_ID = 'J6nTnUo3YLayzc2GUUctb1:2:MyName:1.0'

export const CRED_DEF_ID = 'GeUpJLNXHEgTBJEy4nSjnd:3:CL:47756:default'

export const REVOC_REG_DEF_ID =
'EsUFXEDp9uqPL3tMNXhUst:4:EsUFXEDp9uqPL3tMNXhUst:3:CL:63132:Oliu.id:CL_ACCUM:6074b559-164e-458a-8532-2057d5b26946'
4 changes: 2 additions & 2 deletions wrappers/javascript/indy-vdr-nodejs/tests/utils/initialize.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PoolCreate } from '@hyperledger/indy-vdr-shared'

import { SOVRIN_GENESIS_TRANSACTION_BUILDER_NET } from './fixtures'
import { genesisTxnPath } from './fixtures'

export const setupPool = () => {
return new PoolCreate({ parameters: { transactions: SOVRIN_GENESIS_TRANSACTION_BUILDER_NET } })
return new PoolCreate({ parameters: { transactions_path: genesisTxnPath } })
}

0 comments on commit f47b27a

Please sign in to comment.