Skip to content

Commit 86395e3

Browse files
build(js): use local network (#192)
Signed-off-by: blu3beri <[email protected]>
1 parent 628bf66 commit 86395e3

File tree

8 files changed

+46
-24
lines changed

8 files changed

+46
-24
lines changed

.github/workflows/build.yml

+9
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,15 @@ jobs:
243243
- name: Check types
244244
run: yarn check-types
245245

246+
- name: Run local node pool
247+
run: |
248+
cd ../../
249+
docker build -f ci/indy-pool.dockerfile -t test_pool --build-arg pool_ip=10.0.0.2 ci
250+
docker network create --subnet=10.0.0.0/8 indy-sdk-network
251+
docker run -d --name indy_pool -p 9701-9708:9701-9708 --net=indy-sdk-network test_pool
252+
cd wrappers/javascript
253+
docker exec $(docker ps -aqf "ancestor=test_pool") cat /var/lib/indy/sandbox/pool_transactions_genesis >> genesis.txn
254+
246255
- name: Run tests
247256
env:
248257
# binary is downloaded to root of repository

wrappers/javascript/.eslintrc.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@ module.exports = {
7171
},
7272
overrides: [
7373
{
74-
files: ['arch.js'],
75-
env: { node: true },
74+
files: ['arch.js', 'platform.js'],
75+
env: {
76+
node: true,
77+
},
7678
rules: {
7779
'@typescript-eslint/no-unsafe-assignment': 'off',
7880
'no-console': 'off',
@@ -91,5 +93,14 @@ module.exports = {
9193
'@typescript-eslint/no-unsafe-call': 'off',
9294
},
9395
},
96+
{
97+
files: ['**.test.**'],
98+
env: {
99+
node: true,
100+
},
101+
rules: {
102+
'@typescript-eslint/no-unsafe-assignment': 'off',
103+
},
104+
},
94105
],
95106
}

wrappers/javascript/indy-vdr-nodejs/README.md

+18
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,22 @@ const getSchemaRequest = new GetSchemaRequest({
3333
const schemaResponse = await pool.submitRequest(getSchemaRequest)
3434
```
3535

36+
## Testing
37+
38+
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):
39+
40+
```sh
41+
docker build -f ci/indy-pool.dockerfile -t test_pool --build-arg pool_ip=10.0.0.2 ci
42+
docker network create --subnet=10.0.0.0/8 indy-sdk-network
43+
docker run -d --name indy_pool -p 9701-9708:9701-9708 --net=indy-sdk-network test_pool
44+
45+
# Network is now running
46+
47+
cd wrappers/javascript
48+
49+
docker exec $(docker ps -aqf "ancestor=test_pool") cat /var/lib/indy/sandbox/pool_transactions_genesis >> genesis.txn
50+
51+
yarn test:local-build
52+
```
53+
3654
> **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.

wrappers/javascript/indy-vdr-nodejs/scripts/platform.js

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-var-requires */
2-
/* eslint-disable no-console */
3-
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
4-
/* eslint-disable no-undef */
51
const os = require('os')
62

73
// Find appropriate target architecture for retrieving the anoncreds library

wrappers/javascript/indy-vdr-nodejs/tests/IndyVdrPool.test.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
// TODO: this should be turned off at a eslint config level for tests
2-
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
3-
41
import type { IndyVdrPool } from '@hyperledger/indy-vdr-nodejs'
52

6-
import { SOVRIN_GENESIS_TRANSACTION_BUILDER_NET } from './utils'
3+
import { genesisTxnPath } from './utils'
74

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

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

1310
beforeAll(() => {
14-
pool = new PoolCreate({ parameters: { transactions: SOVRIN_GENESIS_TRANSACTION_BUILDER_NET } })
11+
pool = new PoolCreate({ parameters: { transactions_path: genesisTxnPath } })
1512
})
1613

1714
test('Get pool handle', () => {

wrappers/javascript/indy-vdr-nodejs/tests/IndyVdrRequest.test.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
2-
31
import type { IndyVdrRequest } from '@hyperledger/indy-vdr-nodejs'
42

53
import { DID, SCHEMA_ID } from './utils'
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
export const SOVRIN_GENESIS_TRANSACTION_BUILDER_NET = `
2-
{"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"}
3-
{"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"}
4-
{"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"}
5-
{"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"}
6-
`
1+
import path from 'path'
72

3+
export const genesisTxnPath = path.join(__dirname, '../../../genesis.txn')
84
export const DID = 'PqdUtwWhuX4GWRa58WSdvn'
9-
105
export const SCHEMA_ID = 'J6nTnUo3YLayzc2GUUctb1:2:MyName:1.0'
11-
126
export const CRED_DEF_ID = 'GeUpJLNXHEgTBJEy4nSjnd:3:CL:47756:default'
13-
147
export const REVOC_REG_DEF_ID =
158
'EsUFXEDp9uqPL3tMNXhUst:4:EsUFXEDp9uqPL3tMNXhUst:3:CL:63132:Oliu.id:CL_ACCUM:6074b559-164e-458a-8532-2057d5b26946'
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { PoolCreate } from '@hyperledger/indy-vdr-shared'
22

3-
import { SOVRIN_GENESIS_TRANSACTION_BUILDER_NET } from './fixtures'
3+
import { genesisTxnPath } from './fixtures'
44

55
export const setupPool = () => {
6-
return new PoolCreate({ parameters: { transactions: SOVRIN_GENESIS_TRANSACTION_BUILDER_NET } })
6+
return new PoolCreate({ parameters: { transactions_path: genesisTxnPath } })
77
}

0 commit comments

Comments
 (0)