Skip to content

Commit 6415ac8

Browse files
author
Vyacheslav
authored
Merge pull request hyperledger-indy#830 from Artemkaaas/feature/nodejs-ci
Feature/nodejs ci
2 parents 78f54b6 + 4612196 commit 6415ac8

File tree

13 files changed

+88
-42
lines changed

13 files changed

+88
-42
lines changed

Jenkinsfile.ci

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ def linuxTesting(file, env_name, network_name) {
234234

235235
sh "cp libindy/target/debug/libindy.so wrappers/java/lib"
236236
sh "cp libindy/target/debug/libindy.so wrappers/python"
237+
sh "cp libindy/target/debug/libindy.so wrappers/nodejs"
237238
sh "cp libindy/target/debug/libindy.so cli"
238239
sh "cp libindy/target/debug/libindy.so libnullpay"
239240

@@ -250,6 +251,7 @@ def linuxTesting(file, env_name, network_name) {
250251

251252
stash includes: 'wrappers/java/lib/libindy.so', name: "LibindyJavaSO${env_name}"
252253
stash includes: 'wrappers/python/libindy.so', name: "LibindyPythonSO${env_name}"
254+
stash includes: 'wrappers/nodejs/libindy.so', name: "LibindyNodejsSO${env_name}"
253255
stash includes: 'cli/libindy.so', name: "LibindyCliSO${env_name}"
254256
stash includes: 'cli/libnullpay.so', name: "LibnullpayCliSO${env_name}"
255257

@@ -282,6 +284,7 @@ def linuxTesting(file, env_name, network_name) {
282284
},
283285
"${env_name}-java-test" : { linuxModuleTesting(file, env_name, network_name, this.&linuxJavaTesting) },
284286
"${env_name}-python-test" : { linuxModuleTesting(file, env_name, network_name, this.&linuxPythonTesting) },
287+
"${env_name}-nodejs-test" : { linuxModuleTesting(file, env_name, network_name, this.&linuxNodejsTesting) },
285288
"${env_name}-cli-test" : { linuxModuleTesting(file, env_name, network_name, this.&linuxCLITesting) }
286289
])
287290
}
@@ -338,6 +341,20 @@ def linuxPythonTesting(env_name, network_name, testEnv) {
338341
}
339342
}
340343

344+
def linuxNodejsTesting(env_name, network_name, testEnv) {
345+
unstash name: "LibindyNodejsSO${env_name}"
346+
testEnv.inside("--network=${network_name}") {
347+
echo "${env_name} Libindy Test: Test nodejs wrapper"
348+
349+
sh '''
350+
cd wrappers/nodejs
351+
npm run prepare
352+
npm install
353+
LD_LIBRARY_PATH=./:${LD_LIBRARY_PATH} RUST_LOG=trace TEST_POOL_IP=10.0.0.2 npm test
354+
'''
355+
}
356+
}
357+
341358
def linuxCLITesting(env_name, network_name, testEnv) {
342359
if (env_name == "RedHat"){ // TODO: Delete it IS-702
343360
return;

cli/src/commands/wallet.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ pub mod list_command {
161161
print_list_table(&wallets,
162162
&vec![("name", "Name"),
163163
("pool_name", "Associated pool name"),
164-
("xtype", "Type")],
164+
("type", "Type")],
165165
"There are no wallets");
166166

167167
if let Some((_, cur_wallet)) = get_opened_wallet(ctx) {
@@ -424,7 +424,7 @@ pub mod tests {
424424
{
425425
let cmd = list_command::new();
426426
let params = CommandParams::new();
427-
cmd.execute(&ctx, &params).unwrap_err();
427+
cmd.execute(&ctx, &params).unwrap();
428428
}
429429
TestUtils::cleanup_storage();
430430
}

libindy/ci/amazon.dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ RUN \
1717
libsodium-devel \
1818
spectool
1919

20+
# install nodejs and npm
21+
RUN curl --silent --location https://rpm.nodesource.com/setup_8.x | bash -
22+
RUN yum -y install nodejs
23+
2024
RUN cd /tmp && \
2125
curl https://download.libsodium.org/libsodium/releases/libsodium-1.0.14.tar.gz | tar -xz && \
2226
cd /tmp/libsodium-1.0.14 && \

libindy/ci/ubuntu.dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ RUN apt-get update && \
2323
libncursesw5-dev \
2424
libzmq3-dev
2525

26+
# install nodejs and npm
27+
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
28+
RUN apt-get install -y nodejs
29+
2630
RUN pip3 install -U \
2731
pip \
2832
setuptools \
@@ -49,4 +53,4 @@ USER indy
4953
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain 1.26.0
5054
ENV PATH /home/indy/.cargo/bin:$PATH
5155

52-
WORKDIR /home/indy
56+
WORKDIR /home/indy

libindy/src/services/wallet/mod.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ use utils::crypto::pwhash_argon2i13::PwhashArgon2i13;
3636
#[derive(Serialize, Deserialize, Debug)]
3737
pub struct WalletDescriptor {
3838
pool_name: String,
39+
#[serde(rename = "type")]
3940
xtype: String,
4041
name: String
4142
}
@@ -326,14 +327,16 @@ impl WalletService {
326327
let mut descriptors = Vec::new();
327328
let wallet_home_path = EnvironmentUtils::wallet_home_path();
328329

329-
for entry in fs::read_dir(wallet_home_path)? {
330-
let dir_entry = if let Ok(dir_entry) = entry { dir_entry } else { continue };
331-
if let Some(wallet_name) = dir_entry.path().file_name().and_then(|os_str| os_str.to_str()) {
332-
let mut descriptor_json = String::new();
333-
File::open(_wallet_descriptor_path(wallet_name)).ok()
334-
.and_then(|mut f| f.read_to_string(&mut descriptor_json).ok())
335-
.and_then(|_| WalletDescriptor::from_json(descriptor_json.as_str()).ok())
336-
.map(|descriptor| descriptors.push(descriptor));
330+
if let Ok(entries) = fs::read_dir(wallet_home_path) {
331+
for entry in entries {
332+
let dir_entry = if let Ok(dir_entry) = entry { dir_entry } else { continue };
333+
if let Some(wallet_name) = dir_entry.path().file_name().and_then(|os_str| os_str.to_str()) {
334+
let mut descriptor_json = String::new();
335+
File::open(_wallet_descriptor_path(wallet_name)).ok()
336+
.and_then(|mut f| f.read_to_string(&mut descriptor_json).ok())
337+
.and_then(|_| WalletDescriptor::from_json(descriptor_json.as_str()).ok())
338+
.map(|descriptor| descriptors.push(descriptor));
339+
}
337340
}
338341
}
339342

wrappers/nodejs/README.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,8 +1582,12 @@ Creates a new secure wallet with the given unique name.
15821582
Custom types can be registered with indy\_register\_wallet\_type call.
15831583
* `config`: String? - Wallet configuration json. List of supported keys are defined by wallet type.
15841584
if NULL, then default config will be used.
1585-
* `credentials`: String? - Wallet credentials json. List of supported keys are defined by wallet type.
1586-
if NULL, then default config will be used.
1585+
* `credentials`: String? - Wallet credentials json.
1586+
```
1587+
{
1588+
"key": "wallet pass phrase"
1589+
}
1590+
```
15871591
* __->__ void
15881592
15891593
Errors: `Common*`, `Wallet*`
@@ -1603,8 +1607,12 @@ It is impossible to open wallet with the same name more than once.
16031607
... List of additional supported keys are defined by wallet type.
16041608
}
16051609
````
1606-
* `credentials`: String? - Wallet credentials json. List of supported keys are defined by wallet type.
1607-
if NULL, then default credentials will be used.
1610+
* `credentials`: String? - Wallet credentials json.
1611+
```
1612+
{
1613+
"key": "wallet pass phrase"
1614+
}
1615+
```
16081616
* __->__ `handle`: Handle (Number) - Handle to opened wallet to use in methods that require wallet access.
16091617
16101618
Errors: `Common*`, `Wallet*`
@@ -1630,8 +1638,12 @@ Errors: `Common*`, `Wallet*`
16301638
Deletes created wallet.
16311639
16321640
* `name`: String - Name of the wallet to delete.
1633-
* `credentials`: String? - Wallet credentials json. List of supported keys are defined by wallet type.
1634-
if NULL, then default credentials will be used.
1641+
* `credentials`: String? - Wallet credentials json.
1642+
```
1643+
{
1644+
"key": "wallet pass phrase"
1645+
}
1646+
```
16351647
* __->__ void
16361648
16371649
Errors: `Common*`, `Wallet*`

wrappers/nodejs/src/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -519,13 +519,13 @@ indy.deletePoolLedgerConfig = function deletePoolLedgerConfig (configName, cb) {
519519

520520
indy.createWallet = function createWallet (poolName, name, xtype, config, credentials, cb) {
521521
cb = wrapIndyCallback(cb)
522-
capi.createWallet(poolName, name, xtype, config, credentials, cb)
522+
capi.createWallet(poolName, name, xtype, config, toJson(credentials), cb)
523523
return cb.promise
524524
}
525525

526526
indy.openWallet = function openWallet (name, runtimeConfig, credentials, cb) {
527527
cb = wrapIndyCallback(cb)
528-
capi.openWallet(name, runtimeConfig, credentials, cb)
528+
capi.openWallet(name, runtimeConfig, toJson(credentials), cb)
529529
return cb.promise
530530
}
531531

@@ -543,7 +543,7 @@ indy.closeWallet = function closeWallet (handle, cb) {
543543

544544
indy.deleteWallet = function deleteWallet (name, credentials, cb) {
545545
cb = wrapIndyCallback(cb)
546-
capi.deleteWallet(name, credentials, cb)
546+
capi.deleteWallet(name, toJson(credentials), cb)
547547
return cb.promise
548548
}
549549

wrappers/nodejs/test/anoncreds.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ var indyHomeDir = require('home-dir')('.indy_client')
88
test('anoncreds', async function (t) {
99
var pool = await initTestPool()
1010
var wName = 'wallet-' + cuid()
11-
await indy.createWallet(pool.name, wName, 'default', null, null)
12-
var wh = await indy.openWallet(wName, null, null)
11+
var walletCredentials = {'key': 'key'}
12+
await indy.createWallet(pool.name, wName, 'default', null, walletCredentials)
13+
var wh = await indy.openWallet(wName, null, walletCredentials)
1314
var issuerDid = 'NcYxiDXkpYi6ov5FcYDi1e'
1415
var proverDid = 'VsKV7grR1BUE29mG2Fm2kX'
1516

@@ -139,6 +140,6 @@ test('anoncreds', async function (t) {
139140
t.truthy(/^true /.test(mergedDelta.value.accum))
140141

141142
await indy.closeWallet(wh)
142-
await indy.deleteWallet(wName, null)
143+
await indy.deleteWallet(wName, walletCredentials)
143144
pool.cleanup()
144145
})

wrappers/nodejs/test/crypto.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ var initTestPool = require('./helpers/initTestPool')
66
test('crypto', async function (t) {
77
var pool = await initTestPool()
88
var wName = 'wallet-' + cuid()
9-
await indy.createWallet(pool.name, wName, 'default', null, null)
10-
var wh = await indy.openWallet(wName, null, null)
9+
var walletCredentials = {'key': 'key'}
10+
await indy.createWallet(pool.name, wName, 'default', null, walletCredentials)
11+
var wh = await indy.openWallet(wName, null, walletCredentials)
1112

1213
// Create Key
1314
var error = await t.throws(indy.createKey(-1, {}))
@@ -54,6 +55,6 @@ test('crypto', async function (t) {
5455
t.is(decrypted.toString('utf8'), message.toString('utf8'))
5556

5657
await indy.closeWallet(wh)
57-
await indy.deleteWallet(wName, null)
58+
await indy.deleteWallet(wName, walletCredentials)
5859
pool.cleanup()
5960
})

wrappers/nodejs/test/did.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ var initTestPool = require('./helpers/initTestPool')
66
test('did', async function (t) {
77
var pool = await initTestPool()
88
var wName = 'wallet-' + cuid()
9-
await indy.createWallet(pool.name, wName, 'default', null, null)
10-
var wh = await indy.openWallet(wName, null, null)
9+
var walletCredentials = {'key': 'key'}
10+
await indy.createWallet(pool.name, wName, 'default', null, walletCredentials)
11+
var wh = await indy.openWallet(wName, null, walletCredentials)
1112

1213
// List, create, and get
1314
t.deepEqual(await indy.listMyDidsWithMeta(wh), [])
@@ -55,6 +56,6 @@ test('did', async function (t) {
5556
t.deepEqual(await indy.listMyDidsWithMeta(wh), [data])
5657

5758
await indy.closeWallet(wh)
58-
await indy.deleteWallet(wName, null)
59+
await indy.deleteWallet(wName, walletCredentials)
5960
pool.cleanup()
6061
})

0 commit comments

Comments
 (0)