Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2335 from ianco/rc
Browse files Browse the repository at this point in the history
Merge latest master, including indy node dockerfile updates
  • Loading branch information
jovfer authored Dec 23, 2020
2 parents 114f43b + 76d02dd commit b4b330e
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ci/indy-pool.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,19 @@ 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} \
indy-plenum=${indy_plenum_ver} \
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\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> future = (CompletableFuture<String>) removeFuture(xcommand_handle);
if (! checkResult(future, err)) return;

String result = metadata;
future.complete(result);
}
};

/*
* STATIC METHODS
Expand Down Expand Up @@ -259,6 +275,28 @@ public static CompletableFuture<Void> setProtocolVersion(
return future;
}

/**
* Lists names of created pool ledgers
*
* @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<String> listPools() throws IndyException {

CompletableFuture<String> future = new CompletableFuture<String>();
int commandHandle = addFuture(future);

int result = LibIndy.api.indy_list_pools(
commandHandle,
listPoolsCb);

checkResult(future, result);

return future;
}

/*
* INSTANCE METHODS
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -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 testListPoolsWorks() throws Exception {
File file = new File("testListPoolsWorks.txn");
file.deleteOnExit();
assertTrue(file.createNewFile());
PoolUtils.writeTransactions(file);

String testPoolName = "testListPoolsWorks";

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"));
}

}

0 comments on commit b4b330e

Please sign in to comment.