Skip to content

Commit a82bf9e

Browse files
authored
Merge branch 'master' into feature/sp_plugged
2 parents 7959b3d + d0f11e2 commit a82bf9e

File tree

18 files changed

+115
-69
lines changed

18 files changed

+115
-69
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/domain/anoncreds/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ pub mod revocation_state;
1414
pub mod schema;
1515
pub mod master_secret;
1616

17-
pub const DELIMITER: &'static str = ":";
17+
pub const DELIMITER: char = ':';

libindy/src/services/crypto/mod.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ impl CryptoService {
142142
pub fn sign(&self, my_key: &Key, doc: &[u8]) -> Result<Vec<u8>, CryptoError> {
143143
trace!("sign >>> my_key: {:?}, doc: {:?}", my_key, doc);
144144

145-
let crypto_type_name = if my_key.verkey.contains(":") {
146-
let splits: Vec<&str> = my_key.verkey.split(":").collect();
145+
let crypto_type_name = if my_key.verkey.contains(':') {
146+
let splits: Vec<&str> = my_key.verkey.split(':').collect();
147147
splits[1]
148148
} else {
149149
DEFAULT_CRYPTO_TYPE
@@ -168,8 +168,8 @@ impl CryptoService {
168168
pub fn verify(&self, their_vk: &str, msg: &[u8], signature: &[u8]) -> Result<bool, CryptoError> {
169169
trace!("verify >>> their_vk: {:?}, msg: {:?}, signature: {:?}", their_vk, msg, signature);
170170

171-
let (their_vk, crypto_type_name) = if their_vk.contains(":") {
172-
let splits: Vec<&str> = their_vk.split(":").collect();
171+
let (their_vk, crypto_type_name) = if their_vk.contains(':') {
172+
let splits: Vec<&str> = their_vk.split(':').collect();
173173
(splits[0], splits[1])
174174
} else {
175175
(their_vk, DEFAULT_CRYPTO_TYPE)
@@ -210,15 +210,15 @@ impl CryptoService {
210210
pub fn encrypt(&self, my_key: &Key, their_vk: &str, doc: &[u8]) -> Result<(Vec<u8>, Vec<u8>), CryptoError> {
211211
trace!("encrypt >>> my_key: {:?}, their_vk: {:?}, doc: {:?}", my_key, their_vk, doc);
212212

213-
let (_my_vk, crypto_type_name) = if my_key.verkey.contains(":") {
214-
let splits: Vec<&str> = my_key.verkey.split(":").collect();
213+
let (_my_vk, crypto_type_name) = if my_key.verkey.contains(':') {
214+
let splits: Vec<&str> = my_key.verkey.split(':').collect();
215215
(splits[0], splits[1])
216216
} else {
217217
(my_key.verkey.as_str(), DEFAULT_CRYPTO_TYPE)
218218
};
219219

220-
let (their_vk, their_crypto_type_name) = if their_vk.contains(":") {
221-
let splits: Vec<&str> = their_vk.split(":").collect();
220+
let (their_vk, their_crypto_type_name) = if their_vk.contains(':') {
221+
let splits: Vec<&str> = their_vk.split(':').collect();
222222
(splits[0], splits[1])
223223
} else {
224224
(their_vk, DEFAULT_CRYPTO_TYPE)
@@ -252,15 +252,15 @@ impl CryptoService {
252252
pub fn decrypt(&self, my_key: &Key, their_vk: &str, doc: &[u8], nonce: &[u8]) -> Result<Vec<u8>, CryptoError> {
253253
trace!("decrypt >>> my_key: {:?}, their_vk: {:?}, doc: {:?}, nonce: {:?}", my_key, their_vk, doc, nonce);
254254

255-
let (_my_vk, crypto_type_name) = if my_key.verkey.contains(":") {
256-
let splits: Vec<&str> = my_key.verkey.split(":").collect();
255+
let (_my_vk, crypto_type_name) = if my_key.verkey.contains(':') {
256+
let splits: Vec<&str> = my_key.verkey.split(':').collect();
257257
(splits[0], splits[1])
258258
} else {
259259
(my_key.verkey.as_str(), DEFAULT_CRYPTO_TYPE)
260260
};
261261

262-
let (their_vk, their_crypto_type_name) = if their_vk.contains(":") {
263-
let splits: Vec<&str> = their_vk.split(":").collect();
262+
let (their_vk, their_crypto_type_name) = if their_vk.contains(':') {
263+
let splits: Vec<&str> = their_vk.split(':').collect();
264264
(splits[0], splits[1])
265265
} else {
266266
(their_vk, DEFAULT_CRYPTO_TYPE)
@@ -294,8 +294,8 @@ impl CryptoService {
294294
pub fn encrypt_sealed(&self, their_vk: &str, doc: &[u8]) -> Result<Vec<u8>, CryptoError> {
295295
trace!("encrypt_sealed >>> their_vk: {:?}, doc: {:?}", their_vk, doc);
296296

297-
let (their_vk, crypto_type_name) = if their_vk.contains(":") {
298-
let splits: Vec<&str> = their_vk.split(":").collect();
297+
let (their_vk, crypto_type_name) = if their_vk.contains(':') {
298+
let splits: Vec<&str> = their_vk.split(':').collect();
299299
(splits[0], splits[1])
300300
} else {
301301
(their_vk, DEFAULT_CRYPTO_TYPE)
@@ -319,8 +319,8 @@ impl CryptoService {
319319
pub fn decrypt_sealed(&self, my_key: &Key, doc: &[u8]) -> Result<Vec<u8>, CryptoError> {
320320
trace!("decrypt_sealed >>> my_key: {:?}, doc: {:?}", my_key, doc);
321321

322-
let (my_vk, crypto_type_name) = if my_key.verkey.contains(":") {
323-
let splits: Vec<&str> = my_key.verkey.split(":").collect();
322+
let (my_vk, crypto_type_name) = if my_key.verkey.contains(':') {
323+
let splits: Vec<&str> = my_key.verkey.split(':').collect();
324324
(splits[0], splits[1])
325325
} else {
326326
(my_key.verkey.as_str(), DEFAULT_CRYPTO_TYPE)
@@ -348,7 +348,7 @@ impl CryptoService {
348348

349349
let res = match seed {
350350
Some(ref seed) =>
351-
if seed.ends_with("=") {
351+
if seed.ends_with('=') {
352352
Some(base64::decode(&seed)
353353
.map_err(|err| CommonError::InvalidStructure(format!("Can't deserialize Seed from Base64 string: {:?}", err)))?)
354354
} else {
@@ -365,8 +365,8 @@ impl CryptoService {
365365
pub fn validate_key(&self, vk: &str) -> Result<(), CryptoError> {
366366
trace!("validate_key >>> vk: {:?}", vk);
367367

368-
let (vk, crypto_type_name) = if vk.contains(":") {
369-
let splits: Vec<&str> = vk.split(":").collect();
368+
let (vk, crypto_type_name) = if vk.contains(':') {
369+
let splits: Vec<&str> = vk.split(':').collect();
370370
(splits[0], splits[1])
371371
} else {
372372
(vk, DEFAULT_CRYPTO_TYPE)
@@ -378,7 +378,7 @@ impl CryptoService {
378378

379379
let crypto_type = self.crypto_types.get(crypto_type_name).unwrap();
380380

381-
let vk = if vk.starts_with("~") { &vk[1..] } else { vk };
381+
let vk = if vk.starts_with('~') { &vk[1..] } else { vk };
382382
let vk = Base58::decode(vk)?;
383383

384384
let res =crypto_type.validate_key(&vk)?;

libindy/src/services/payments.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ impl PaymentsService {
324324
}
325325

326326
fn _parse_method_from_payment_address(&self, address: &str) -> Option<String> {
327-
let res: Vec<&str> = address.split(":").collect();
327+
let res: Vec<&str> = address.split(':').collect();
328328
match res.len() {
329329
3 => res.get(1).map(|s| s.to_string()),
330330
_ => None
@@ -487,4 +487,4 @@ mod cbs {
487487

488488
Some(_callback)
489489
}
490-
}
490+
}

libindy/src/services/pool/transaction_handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ impl TransactionHandler {
463463
constants::GET_REVOC_REG_DEF => {
464464
if let Some(id) = json_msg["id"].as_str() {
465465
//FIXME
466-
id.splitn(2, ":").next().unwrap()
466+
id.splitn(2, ':').next().unwrap()
467467
.as_bytes().to_vec()
468468
} else {
469469
debug!("TransactionHandler::parse_reply_for_builtin_sp: <<< No dest");

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

libindy/src/utils/crypto/verkey_builder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ use utils::crypto::base58::Base58;
44

55
pub fn build_full_verkey(dest: &str, verkey: Option<&str>) -> Result<String, CommonError> {
66
if let Some(verkey) = verkey {
7-
let (verkey, crypto_type) = if verkey.contains(":") {
8-
let splits: Vec<&str> = verkey.split(":").collect();
7+
let (verkey, crypto_type) = if verkey.contains(':') {
8+
let splits: Vec<&str> = verkey.split(':').collect();
99
(splits[0], Some(splits[1]))
1010
} else {
1111
(verkey, None)
1212
};
1313

14-
let verkey = if verkey.starts_with("~") {
14+
let verkey = if verkey.starts_with('~') {
1515
let mut result = Base58::decode(dest)?;
1616
let mut end = Base58::decode(&verkey[1..])?;
1717
result.append(&mut end);

0 commit comments

Comments
 (0)