From 356ba750bbe65f31e23ee79d901a9e5535a1c803 Mon Sep 17 00:00:00 2001 From: George J Padayatti Date: Thu, 26 Nov 2020 20:52:22 +0530 Subject: [PATCH 1/5] Java wrapper function to list pools Signed-off-by: George J Padayatti --- .../org/hyperledger/indy/sdk/LibIndy.java | 1 + .../org/hyperledger/indy/sdk/pool/Pool.java | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/wrappers/java/src/main/java/org/hyperledger/indy/sdk/LibIndy.java b/wrappers/java/src/main/java/org/hyperledger/indy/sdk/LibIndy.java index 045e7f7bcc..50d9619f9b 100644 --- a/wrappers/java/src/main/java/org/hyperledger/indy/sdk/LibIndy.java +++ b/wrappers/java/src/main/java/org/hyperledger/indy/sdk/LibIndy.java @@ -31,6 +31,7 @@ public interface API extends Library { public int indy_close_pool_ledger(int command_handle, int handle, Callback cb); public int indy_delete_pool_ledger_config(int command_handle, String config_name, Callback cb); public int indy_set_protocol_version(int command_handle, int protocol_version, Callback cb); + public int indy_list_pools(int command_handle, Callback cb); // wallet.rs diff --git a/wrappers/java/src/main/java/org/hyperledger/indy/sdk/pool/Pool.java b/wrappers/java/src/main/java/org/hyperledger/indy/sdk/pool/Pool.java index e5a6eaa4da..06c8f7f7bc 100644 --- a/wrappers/java/src/main/java/org/hyperledger/indy/sdk/pool/Pool.java +++ b/wrappers/java/src/main/java/org/hyperledger/indy/sdk/pool/Pool.java @@ -73,6 +73,22 @@ public void callback(int xcommand_handle, int err) { future.complete(result); } }; + + /** + * Callback used when listPools completes. + */ + private static Callback listPoolsCb = new Callback() { + + @SuppressWarnings({"unused", "unchecked"}) + public void callback(int xcommand_handle, int err, String metadata) { + + CompletableFuture future = (CompletableFuture) removeFuture(xcommand_handle); + if (! checkResult(future, err)) return; + + String result = metadata; + future.complete(result); + } + }; /* * STATIC METHODS @@ -259,6 +275,26 @@ public static CompletableFuture setProtocolVersion( return future; } + /** + * Lists names of created pool ledgers + * + * @return A future that does not resolve a value. + * @throws IndyException Thrown if an error occurs when calling the underlying SDK. + */ + public static CompletableFuture listPools() throws IndyException { + + CompletableFuture future = new CompletableFuture(); + int commandHandle = addFuture(future); + + int result = LibIndy.api.indy_list_pools( + commandHandle, + listPoolsCb); + + checkResult(future, result); + + return future; + } + /* * INSTANCE METHODS */ From 6e1f283299ba081ba2602a71f855f27122fac48e Mon Sep 17 00:00:00 2001 From: George J Padayatti Date: Thu, 26 Nov 2020 20:55:39 +0530 Subject: [PATCH 2/5] Unit test for list pools java wrapper function Signed-off-by: George J Padayatti --- .../indy/sdk/pool/ListPoolsTest.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 wrappers/java/src/test/java/org/hyperledger/indy/sdk/pool/ListPoolsTest.java diff --git a/wrappers/java/src/test/java/org/hyperledger/indy/sdk/pool/ListPoolsTest.java b/wrappers/java/src/test/java/org/hyperledger/indy/sdk/pool/ListPoolsTest.java new file mode 100644 index 0000000000..f1a0155378 --- /dev/null +++ b/wrappers/java/src/test/java/org/hyperledger/indy/sdk/pool/ListPoolsTest.java @@ -0,0 +1,34 @@ +package org.hyperledger.indy.sdk.pool; + +import org.hyperledger.indy.sdk.IndyIntegrationTest; +import org.hyperledger.indy.sdk.utils.PoolUtils; + +import org.junit.Test; +import org.json.JSONArray; + +import java.io.File; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; + +public class ListPoolsTest extends IndyIntegrationTest { + + @Test + public void testCreatePoolWorksForNullConfig() throws Exception { + File file = new File("testCreatePoolWorks.txn"); + file.deleteOnExit(); + assertTrue(file.createNewFile()); + PoolUtils.writeTransactions(file); + + String testPoolName = "testCreatePoolWorks"; + + Pool.createPoolLedgerConfig(testPoolName, null).get(); + String listPoolsJson = Pool.listPools().get(); + + JSONArray listPools = new JSONArray(listPoolsJson); + + assertEquals(1, listPools.length()); + assertEquals(testPoolName, listPools.getJSONObject(0).getString("pool")); + } + +} From f8583cef0971603f170fa8c2a6c273ecdfc2c4eb Mon Sep 17 00:00:00 2001 From: George J Padayatti Date: Thu, 26 Nov 2020 21:33:24 +0530 Subject: [PATCH 3/5] Fix Return type documentation in listPools function Signed-off-by: George J Padayatti --- .../src/main/java/org/hyperledger/indy/sdk/pool/Pool.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wrappers/java/src/main/java/org/hyperledger/indy/sdk/pool/Pool.java b/wrappers/java/src/main/java/org/hyperledger/indy/sdk/pool/Pool.java index 06c8f7f7bc..333699c973 100644 --- a/wrappers/java/src/main/java/org/hyperledger/indy/sdk/pool/Pool.java +++ b/wrappers/java/src/main/java/org/hyperledger/indy/sdk/pool/Pool.java @@ -278,7 +278,9 @@ public static CompletableFuture setProtocolVersion( /** * Lists names of created pool ledgers * - * @return A future that does not resolve a value. + * @return A future resolving to a list of pools: [{ + * "pool": string - Name of pool ledger stored in the wallet. + * }] * @throws IndyException Thrown if an error occurs when calling the underlying SDK. */ public static CompletableFuture listPools() throws IndyException { From e026e1d67af7f6f300e644f228225c4fba6e8837 Mon Sep 17 00:00:00 2001 From: George J Padayatti Date: Fri, 27 Nov 2020 22:33:40 +0530 Subject: [PATCH 4/5] Fix Unit test for list pools wrapper function Signed-off-by: George J Padayatti --- .../java/org/hyperledger/indy/sdk/pool/ListPoolsTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wrappers/java/src/test/java/org/hyperledger/indy/sdk/pool/ListPoolsTest.java b/wrappers/java/src/test/java/org/hyperledger/indy/sdk/pool/ListPoolsTest.java index f1a0155378..635c849fc3 100644 --- a/wrappers/java/src/test/java/org/hyperledger/indy/sdk/pool/ListPoolsTest.java +++ b/wrappers/java/src/test/java/org/hyperledger/indy/sdk/pool/ListPoolsTest.java @@ -14,13 +14,13 @@ public class ListPoolsTest extends IndyIntegrationTest { @Test - public void testCreatePoolWorksForNullConfig() throws Exception { - File file = new File("testCreatePoolWorks.txn"); + public void testListPoolsWorks() throws Exception { + File file = new File("testListPoolsWorks.txn"); file.deleteOnExit(); assertTrue(file.createNewFile()); PoolUtils.writeTransactions(file); - String testPoolName = "testCreatePoolWorks"; + String testPoolName = "testListPoolsWorks"; Pool.createPoolLedgerConfig(testPoolName, null).get(); String listPoolsJson = Pool.listPools().get(); From a6fa6834612bddfaa51effdb3096ad8cc7d35899 Mon Sep 17 00:00:00 2001 From: Sergey Minaev Date: Thu, 17 Dec 2020 16:39:02 +0300 Subject: [PATCH 5/5] Pin versions of dependencies Indy Node and Plenum. Signed-off-by: Sergey Minaev --- ci/indy-pool.dockerfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ci/indy-pool.dockerfile b/ci/indy-pool.dockerfile index 94ac766b3f..bf5a23908e 100644 --- a/ci/indy-pool.dockerfile +++ b/ci/indy-pool.dockerfile @@ -30,6 +30,9 @@ ARG indy_node_ver=1.12.1~dev1172 ARG python3_indy_crypto_ver=0.4.5 ARG indy_crypto_ver=0.4.5 ARG python3_pyzmq_ver=18.1.0 +ARG python3_orderedset_ver=2.0 +ARG python3_psutil_ver=5.4.3 +ARG python3_pympler_ver=0.5 RUN apt-get update -y && apt-get install -y \ python3-pyzmq=${python3_pyzmq_ver} \ @@ -37,6 +40,9 @@ RUN apt-get update -y && apt-get install -y \ indy-node=${indy_node_ver} \ python3-indy-crypto=${python3_indy_crypto_ver} \ libindy-crypto=${indy_crypto_ver} \ + python3-orderedset=${python3_orderedset_ver} \ + python3-psutil=${python3_psutil_ver} \ + python3-pympler=${python3_pympler_ver} \ vim RUN echo "[supervisord]\n\