This repository was archived by the owner on Feb 29, 2024. It is now read-only.
File tree 4 files changed +79
-0
lines changed
main/java/org/hyperledger/indy/sdk
test/java/org/hyperledger/indy/sdk/pool
4 files changed +79
-0
lines changed Original file line number Diff line number Diff line change @@ -30,13 +30,19 @@ ARG indy_node_ver=1.12.1~dev1172
30
30
ARG python3_indy_crypto_ver=0.4.5
31
31
ARG indy_crypto_ver=0.4.5
32
32
ARG python3_pyzmq_ver=18.1.0
33
+ ARG python3_orderedset_ver=2.0
34
+ ARG python3_psutil_ver=5.4.3
35
+ ARG python3_pympler_ver=0.5
33
36
34
37
RUN apt-get update -y && apt-get install -y \
35
38
python3-pyzmq=${python3_pyzmq_ver} \
36
39
indy-plenum=${indy_plenum_ver} \
37
40
indy-node=${indy_node_ver} \
38
41
python3-indy-crypto=${python3_indy_crypto_ver} \
39
42
libindy-crypto=${indy_crypto_ver} \
43
+ python3-orderedset=${python3_orderedset_ver} \
44
+ python3-psutil=${python3_psutil_ver} \
45
+ python3-pympler=${python3_pympler_ver} \
40
46
vim
41
47
42
48
RUN echo "[supervisord]\n \
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ public interface API extends Library {
31
31
public int indy_close_pool_ledger (int command_handle , int handle , Callback cb );
32
32
public int indy_delete_pool_ledger_config (int command_handle , String config_name , Callback cb );
33
33
public int indy_set_protocol_version (int command_handle , int protocol_version , Callback cb );
34
+ public int indy_list_pools (int command_handle , Callback cb );
34
35
35
36
// wallet.rs
36
37
Original file line number Diff line number Diff line change @@ -73,6 +73,22 @@ public void callback(int xcommand_handle, int err) {
73
73
future .complete (result );
74
74
}
75
75
};
76
+
77
+ /**
78
+ * Callback used when listPools completes.
79
+ */
80
+ private static Callback listPoolsCb = new Callback () {
81
+
82
+ @ SuppressWarnings ({"unused" , "unchecked" })
83
+ public void callback (int xcommand_handle , int err , String metadata ) {
84
+
85
+ CompletableFuture <String > future = (CompletableFuture <String >) removeFuture (xcommand_handle );
86
+ if (! checkResult (future , err )) return ;
87
+
88
+ String result = metadata ;
89
+ future .complete (result );
90
+ }
91
+ };
76
92
77
93
/*
78
94
* STATIC METHODS
@@ -259,6 +275,28 @@ public static CompletableFuture<Void> setProtocolVersion(
259
275
return future ;
260
276
}
261
277
278
+ /**
279
+ * Lists names of created pool ledgers
280
+ *
281
+ * @return A future resolving to a list of pools: [{
282
+ * "pool": string - Name of pool ledger stored in the wallet.
283
+ * }]
284
+ * @throws IndyException Thrown if an error occurs when calling the underlying SDK.
285
+ */
286
+ public static CompletableFuture <String > listPools () throws IndyException {
287
+
288
+ CompletableFuture <String > future = new CompletableFuture <String >();
289
+ int commandHandle = addFuture (future );
290
+
291
+ int result = LibIndy .api .indy_list_pools (
292
+ commandHandle ,
293
+ listPoolsCb );
294
+
295
+ checkResult (future , result );
296
+
297
+ return future ;
298
+ }
299
+
262
300
/*
263
301
* INSTANCE METHODS
264
302
*/
Original file line number Diff line number Diff line change
1
+ package org .hyperledger .indy .sdk .pool ;
2
+
3
+ import org .hyperledger .indy .sdk .IndyIntegrationTest ;
4
+ import org .hyperledger .indy .sdk .utils .PoolUtils ;
5
+
6
+ import org .junit .Test ;
7
+ import org .json .JSONArray ;
8
+
9
+ import java .io .File ;
10
+
11
+ import static org .junit .Assert .assertTrue ;
12
+ import static org .junit .Assert .assertEquals ;
13
+
14
+ public class ListPoolsTest extends IndyIntegrationTest {
15
+
16
+ @ Test
17
+ public void testListPoolsWorks () throws Exception {
18
+ File file = new File ("testListPoolsWorks.txn" );
19
+ file .deleteOnExit ();
20
+ assertTrue (file .createNewFile ());
21
+ PoolUtils .writeTransactions (file );
22
+
23
+ String testPoolName = "testListPoolsWorks" ;
24
+
25
+ Pool .createPoolLedgerConfig (testPoolName , null ).get ();
26
+ String listPoolsJson = Pool .listPools ().get ();
27
+
28
+ JSONArray listPools = new JSONArray (listPoolsJson );
29
+
30
+ assertEquals (1 , listPools .length ());
31
+ assertEquals (testPoolName , listPools .getJSONObject (0 ).getString ("pool" ));
32
+ }
33
+
34
+ }
You can’t perform that action at this time.
0 commit comments