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

Merge latest master, including indy node dockerfile updates #2335

Merged
merged 8 commits into from
Dec 23, 2020
Merged
Original file line number Diff line number Diff line change
@@ -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

Original file line number Diff line number Diff line change
@@ -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
@@ -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
*/
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"));
}

}