Skip to content

Commit f00fffc

Browse files
author
Nikita Khateev
committed
Merge branch 'master' of github.com:hyperledger/indy-sdk into feature/payments
2 parents 02a8c89 + 85623cd commit f00fffc

File tree

16 files changed

+785
-175
lines changed

16 files changed

+785
-175
lines changed

Jenkinsfile.cd

Lines changed: 76 additions & 67 deletions
Large diffs are not rendered by default.

Jenkinsfile.ci

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,34 +51,43 @@ def windowsTesting() {
5151
echo "Windows Libindy Test: Run tests"
5252
withEnv([
5353
"RUST_TEST_THREADS=1",
54-
"RUST_LOG=indy::,zmq=trace",
54+
"RUST_LOG=indy::=debug,zmq=trace",
5555
"TEST_POOL_IP=$INDY_SDK_SERVER_IP"
5656
]) {
5757
bat "cargo test"
5858
}
5959
}
6060
}
6161

62+
dir('libnullpay') {
63+
echo "Windows Libnullpay Test: Build"
64+
withEnv([
65+
"RUST_BACKTRACE=1"
66+
]) {
67+
bat "cargo build"
68+
}
69+
}
70+
71+
bat "copy $WORKSPACE\\libnullpay\\target\\debug\\nullpay.dll $WORKSPACE\\cli"
72+
6273
dir('cli') {
6374
bat "sed -i -e \"s/10\\.0\\.0\\.2/${INDY_SDK_SERVER_IP}/g\" docker_pool_transactions_genesis"
6475

65-
bat "copy $WORKSPACE\\libindy\\target\\debug\\indy.dll $WORKSPACE\\libindy\\prebuilt\\lib"
66-
bat "copy $WORKSPACE\\libindy\\target\\debug\\indy.lib $WORKSPACE\\libindy\\prebuilt\\lib"
76+
def featuresArgs = '--features "nullpay_plugin"'
6777

6878
echo "Windows Indy Cli Test: Build"
6979
withEnv([
70-
"INDY_DIR=$WORKSPACE\\libindy\\prebuilt",
7180
"RUST_BACKTRACE=1"
7281
]) {
73-
bat "cargo test --no-run"
82+
bat "cargo test $featuresArgs --no-run"
7483

7584
echo "Windows Indy Cli Test: Run tests"
7685
withEnv([
7786
"RUST_TEST_THREADS=1",
78-
"RUST_LOG=indy::,zmq=trace",
87+
"RUST_LOG=indy::=debug,zmq=trace",
7988
"TEST_POOL_IP=$INDY_SDK_SERVER_IP"
8089
]) {
81-
bat "cargo test"
90+
bat "cargo test $featuresArgs"
8291
}
8392
}
8493
}
@@ -214,10 +223,23 @@ def linuxTesting(file, env_name, network_name) {
214223
sh "cp libindy/target/debug/libindy.so wrappers/java/lib"
215224
sh "cp libindy/target/debug/libindy.so wrappers/python"
216225
sh "cp libindy/target/debug/libindy.so cli"
226+
sh "cp libindy/target/debug/libindy.so libnullpay"
227+
228+
dir('libnullpay') {
229+
echo "${env_name} Libnullpay Test: Build docker image"
230+
231+
testEnv.inside("--ip=\"10.0.0.3\" --network=${network_name}") {
232+
echo "${env_name} Libnullpay Test: Build"
233+
sh "LIBRARY_PATH=./ cargo build"
234+
}
235+
}
236+
237+
sh "cp libnullpay/target/debug/libnullpay.so cli"
217238

218239
stash includes: 'wrappers/java/lib/libindy.so', name: "LibindyJavaSO${env_name}"
219240
stash includes: 'wrappers/python/libindy.so', name: "LibindyPythonSO${env_name}"
220241
stash includes: 'cli/libindy.so', name: "LibindyCliSO${env_name}"
242+
stash includes: 'cli/libnullpay.so', name: "LibnullpayCliSO${env_name}"
221243

222244
parallel([
223245
"${env_name}-libindy-test": {
@@ -229,7 +251,7 @@ def linuxTesting(file, env_name, network_name) {
229251
sh "RUST_BACKTRACE=1 cargo test --no-run"
230252

231253
echo "${env_name} Libindy Test: Run tests"
232-
sh "RUST_BACKTRACE=1 RUST_LOG=indy::,zmq=trace RUST_TEST_THREADS=1 TEST_POOL_IP=10.0.0.2 cargo test"
254+
sh "RUST_BACKTRACE=1 RUST_LOG=indy::=debug,zmq=trace RUST_TEST_THREADS=1 TEST_POOL_IP=10.0.0.2 cargo test"
233255
}
234256
}
235257
},
@@ -272,7 +294,7 @@ def linuxJavaTesting(env_name, network_name, testEnv) {
272294
testEnv.inside("--network=${network_name}") {
273295
echo "${env_name} Libindy Test: Test java wrapper"
274296

275-
sh "RUST_LOG=indy::,zmq=trace TEST_POOL_IP=10.0.0.2 mvn clean test"
297+
sh "RUST_LOG=indy::=debug,zmq=trace TEST_POOL_IP=10.0.0.2 mvn clean test"
276298
}
277299
}
278300
}
@@ -285,21 +307,27 @@ def linuxPythonTesting(env_name, network_name, testEnv) {
285307

286308
sh '''
287309
python3.5 -m pip install --user -e .
288-
LD_LIBRARY_PATH=./:${LD_LIBRARY_PATH} RUST_LOG=indy::,zmq=trace TEST_POOL_IP=10.0.0.2 python3.5 -m pytest
310+
LD_LIBRARY_PATH=./:${LD_LIBRARY_PATH} RUST_LOG=indy::=debug,zmq=trace TEST_POOL_IP=10.0.0.2 python3.5 -m pytest
289311
'''
290312
}
291313
}
292314
}
293315

294316
def linuxCLITesting(env_name, network_name, testEnv) {
317+
if (env_name == "RedHat"){ // TODO: Delete it IS-702
318+
return;
319+
}
320+
295321
unstash name: "LibindyCliSO${env_name}"
322+
unstash name: "LibnullpayCliSO${env_name}"
323+
296324
dir('cli') {
297325
testEnv.inside("--network=${network_name}") {
298326
echo "${env_name} Indy Cli Test: Build"
299-
sh "LIBRARY_PATH=./ RUST_BACKTRACE=1 cargo test --no-run"
327+
sh 'LIBRARY_PATH=./ RUST_BACKTRACE=1 cargo test --features "nullpay_plugin" --no-run'
300328

301329
echo "${env_name} Indy Cli Test: Run tests"
302-
sh 'LD_LIBRARY_PATH=./:${LD_LIBRARY_PATH} RUST_BACKTRACE=1 RUST_LOG=indy::,zmq=trace RUST_TEST_THREADS=1 TEST_POOL_IP=10.0.0.2 cargo test'
330+
sh 'LD_LIBRARY_PATH=./:${LD_LIBRARY_PATH} RUST_BACKTRACE=1 RUST_LOG=indy::=debug,zmq=trace RUST_TEST_THREADS=1 TEST_POOL_IP=10.0.0.2 cargo test --features "nullpay_plugin"'
303331
}
304332
}
305333
}

cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.1.0"
44
authors = ["Vyacheslav Gudkov <[email protected]>"]
55

66
[features]
7-
payments_cli_tests = []
7+
nullpay_plugin = []
88

99
[dependencies]
1010
ansi_term = "0.10"

cli/build.rs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,33 @@ use std::fs;
33
use std::path::Path;
44

55
fn main() {
6-
println!("cargo:rustc-link-lib=indy");
7-
86
let target = env::var("TARGET").unwrap();
97
println!("target={}", target);
108

119
if target.find("-windows-").is_some() {
12-
println!("cargo:rustc-link-lib=ssleay32");
13-
println!("cargo:rustc-link-lib=zmq");
14-
println!("cargo:rustc-link-lib=sodium");
10+
println!("cargo:rustc-link-lib=indy.dll");
1511

16-
// TODO: FIXME: Provide more reliable dependencies resolving
12+
let profile = env::var("PROFILE").unwrap();
13+
println!("profile={}", profile);
1714

1815
let output_dir = env::var("OUT_DIR").unwrap();
19-
let prebuilt_dir = env::var("INDY_DIR").unwrap();
16+
println!("output_dir={}", output_dir);
17+
let output_dir = Path::new(output_dir.as_str());
2018

21-
let dst = Path::new(&output_dir[..]).join("..\\..\\..");
22-
let prebuilt_lib = Path::new(&prebuilt_dir[..]).join("lib");
19+
let indy_dir = env::var("INDY_DIR").unwrap_or(format!("..\\libindy\\target\\{}", profile));
20+
println!("indy_dir={}", indy_dir);
21+
let indy_dir = Path::new(indy_dir.as_str());
2322

24-
println!("cargo:rustc-link-search=native={}", prebuilt_dir);
25-
println!("cargo:rustc-flags=-L {}\\lib", prebuilt_dir);
26-
println!("cargo:include={}\\include", prebuilt_dir);
23+
let dst = output_dir.join("..\\..\\..");
24+
println!("cargo:rustc-flags=-L {}", indy_dir.as_os_str().to_str().unwrap());
2725

2826
let files = vec!["indy.dll", "libeay32md.dll", "libsodium.dll", "libzmq.dll", "ssleay32md.dll"];
2927
for f in files.iter() {
30-
if let Ok(_) = fs::copy(&prebuilt_lib.join(f), &dst.join(f)) {
31-
println!("copy {} -> {}", &prebuilt_lib.join(f).display(), &dst.join(f).display());
28+
if let Ok(_) = fs::copy(&indy_dir.join(f), &dst.join(f)) {
29+
println!("copy {} -> {}", &indy_dir.join(f).display(), &dst.join(f).display());
3230
}
3331
}
34-
return;
35-
}
32+
} else {
33+
println!("cargo:rustc-link-lib=indy");
34+
}
3635
}

cli/src/commands/common.rs

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ pub mod load_plugin_command {
113113

114114
pub fn load_plugin(ctx: &CommandContext, library: &str, initializer: &str) -> Result<(), ()> {
115115
let lib = libloading::Library::new(library)
116-
.map_err(|_| println_err!("Plugin not found: \"{:?}\"", library))?;
116+
.map_err(|_| println_err!("Plugin not found: {:?}", library))?;
117117

118118
unsafe {
119119
let init_func: libloading::Symbol<unsafe extern fn() -> ErrorCode> = lib.get(initializer.as_bytes())
@@ -152,22 +152,55 @@ pub mod tests {
152152
use super::*;
153153

154154
pub const NULL_PAYMENT_METHOD: &'static str = "null";
155-
pub const NULL_PAYMENT_PLUGIN: &'static str = "libnullpay.so";
156155
pub const NULL_PAYMENT_PLUGIN_INIT_FUNCTION: &'static str = "nullpay_init";
157156

157+
#[cfg(any(unix))]
158+
pub const NULL_PAYMENT_PLUGIN: &'static str = "libnullpay.so";
159+
#[cfg(any(windows))]
160+
pub const NULL_PAYMENT_PLUGIN: &'static str = "nullpay.dll";
161+
158162
mod load {
159163
use super::*;
164+
use utils::test::TestUtils;
160165

161166
#[test]
162-
#[cfg(feature = "payments_cli_tests")]
167+
#[cfg(feature = "nullpay_plugin")]
163168
pub fn load_works() {
169+
TestUtils::cleanup_storage();
170+
164171
let ctx = CommandContext::new();
165172

166173
let cmd = load_plugin_command::new();
167174
let mut params = CommandParams::new();
168175
params.insert("library", NULL_PAYMENT_PLUGIN.to_string());
169176
params.insert("initializer", NULL_PAYMENT_PLUGIN_INIT_FUNCTION.to_string());
170177
cmd.execute(&ctx, &params).unwrap();
178+
179+
TestUtils::cleanup_storage();
180+
}
181+
182+
#[test]
183+
#[cfg(feature = "nullpay_plugin")]
184+
pub fn load_works_for_unknown_plugin() {
185+
let ctx = CommandContext::new();
186+
187+
let cmd = load_plugin_command::new();
188+
let mut params = CommandParams::new();
189+
params.insert("library", "unknown_payment_plugin".to_string());
190+
params.insert("initializer", NULL_PAYMENT_PLUGIN_INIT_FUNCTION.to_string());
191+
cmd.execute(&ctx, &params).unwrap_err();
192+
}
193+
194+
#[test]
195+
#[cfg(feature = "nullpay_plugin")]
196+
pub fn load_works_for_unknown_init_function() {
197+
let ctx = CommandContext::new();
198+
199+
let cmd = load_plugin_command::new();
200+
let mut params = CommandParams::new();
201+
params.insert("library", NULL_PAYMENT_PLUGIN.to_string());
202+
params.insert("initializer", "unknown_init_function".to_string());
203+
cmd.execute(&ctx, &params).unwrap_err();
171204
}
172205
}
173206

0 commit comments

Comments
 (0)