Skip to content

Commit

Permalink
FABJ-364 Dependencies update and misc changes
Browse files Browse the repository at this point in the history
PS
03 Added example of specifying meta-inf index.

Change-Id: I098def07f631097787aec24726a2376bf4aa66e0
Signed-off-by: rickr <cr22rc@gmail.com>
  • Loading branch information
cr22rc committed Sep 20, 2018
1 parent e4a9313 commit f06b9ef
Show file tree
Hide file tree
Showing 13 changed files with 130 additions and 59 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<tag>fabric-sdk-java-1.0</tag>
</scm>
<properties>
<grpc.version>1.14.0</grpc.version><!-- CURRENT_GRPC_VERSION -->
<grpc.version>1.15.0</grpc.version><!-- CURRENT_GRPC_VERSION -->
<protobuf.version>3.6.1</protobuf.version>
<bouncycastle.version>1.60</bouncycastle.version>
<httpclient.version>4.5.6</httpclient.version>
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/hyperledger/fabric/sdk/Channel.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ public class Channel implements Serializable {
private static final long serialVersionUID = -3266164166893832538L;
private static final Log logger = LogFactory.getLog(Channel.class);
private static final boolean IS_DEBUG_LEVEL = logger.isDebugEnabled();
private static final boolean IS_WARN_LEVEL = logger.isWarnEnabled();
private static final boolean IS_TRACE_LEVEL = logger.isTraceEnabled();

private static final Config config = Config.getConfig();
Expand Down Expand Up @@ -5663,7 +5664,7 @@ boolean sweepMe() { // Sweeps DO NOT fire future. user needs to put timeout on t

final boolean ret = sweepTime < System.currentTimeMillis() || fired.get() || future.isDone();

if (IS_DEBUG_LEVEL && ret) {
if (IS_WARN_LEVEL && ret) {

StringBuilder sb = new StringBuilder(10000);
sb.append("Non reporting event hubs:");
Expand All @@ -5683,11 +5684,10 @@ boolean sweepMe() { // Sweeps DO NOT fire future. user needs to put timeout on t
sep = ",";
}

logger.debug(format("Force removing transaction listener after %d ms for transaction %s. %s" +
logger.warn(format("Force removing transaction listener after %d ms for transaction %s. %s" +
". sweep timeout: %b, fired: %b, future done:%b",
System.currentTimeMillis() - createTime, txID, sb.toString(),
sweepTime < System.currentTimeMillis(), fired.get(), future.isDone()));

}

return ret;
Expand Down
39 changes: 33 additions & 6 deletions src/main/java/org/hyperledger/fabric/sdk/ChannelConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,19 @@
import java.io.InputStream;

import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hyperledger.fabric.sdk.exception.InvalidArgumentException;

import static java.lang.String.format;
import static org.hyperledger.fabric.sdk.helper.Utils.toHexString;

/**
* A wrapper for the Hyperledger Channel configuration
*/
public class ChannelConfiguration {
private static final Log logger = LogFactory.getLog(ChannelConfiguration.class);
private static final boolean IS_TRACE_LEVEL = logger.isTraceEnabled();
private byte[] configBytes = null;

/**
Expand All @@ -41,17 +49,27 @@ public ChannelConfiguration() {
* @param configFile The file containing the channel configuration.
* @throws IOException
*/
public ChannelConfiguration(File configFile) throws IOException {
InputStream is = new FileInputStream(configFile);
configBytes = IOUtils.toByteArray(is);
public ChannelConfiguration(File configFile) throws IOException, InvalidArgumentException {
if (configFile == null) {
throw new InvalidArgumentException("ChannelConfiguration configFile must be non-null");
}
logger.trace(format("Creating ChannelConfiguration from file %s", configFile.getAbsolutePath()));

try (InputStream is = new FileInputStream(configFile)) {
configBytes = IOUtils.toByteArray(is);
}
}

/**
* constructs a ChannelConfiguration object
*
* @param configAsBytes the byte array containing the serialized channel configuration
*/
public ChannelConfiguration(byte[] configAsBytes) {
public ChannelConfiguration(byte[] configAsBytes) throws InvalidArgumentException {
if (configAsBytes == null) {
throw new InvalidArgumentException("ChannelConfiguration configAsBytes must be non-null");
}
logger.trace("Creating ChannelConfiguration from bytes");
this.configBytes = configAsBytes;
}

Expand All @@ -60,14 +78,23 @@ public ChannelConfiguration(byte[] configAsBytes) {
*
* @param channelConfigurationAsBytes the byte array containing the serialized channel configuration
*/
public void setChannelConfiguration(byte[] channelConfigurationAsBytes) {
public void setChannelConfiguration(byte[] channelConfigurationAsBytes) throws InvalidArgumentException {
if (channelConfigurationAsBytes == null) {
throw new InvalidArgumentException("ChannelConfiguration channelConfigurationAsBytes must be non-null");
}
logger.trace("Creating setChannelConfiguration from bytes");
this.configBytes = channelConfigurationAsBytes;
}

/**
* @return the channel configuration serialized per protobuf and ready for inclusion into channel configuration
*/
public byte[] getChannelConfigurationAsBytes() {
return this.configBytes;
if (configBytes == null) {
logger.error("ChannelConfiguration configBytes is null!");
} else if (IS_TRACE_LEVEL) {
logger.trace(format("getChannelConfigurationAsBytes: %s", toHexString(configBytes)));
}
return configBytes;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,20 @@
import java.io.InputStream;

import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hyperledger.fabric.sdk.exception.InvalidArgumentException;

import static java.lang.String.format;
import static org.hyperledger.fabric.sdk.helper.Utils.toHexString;

/**
* A wrapper for the Hyperledger Channel update configuration
*/
public class UpdateChannelConfiguration {
private static final Log logger = LogFactory.getLog(UpdateChannelConfiguration.class);
private static final boolean IS_TRACE_LEVEL = logger.isTraceEnabled();

private byte[] configBytes = null;

/**
Expand All @@ -43,33 +52,52 @@ public UpdateChannelConfiguration() {
* @param configFile The file containing the channel configuration.
* @throws IOException
*/
public UpdateChannelConfiguration(File configFile) throws IOException {
InputStream is = new FileInputStream(configFile);
configBytes = IOUtils.toByteArray(is);
public UpdateChannelConfiguration(File configFile) throws IOException, InvalidArgumentException {
if (configFile == null) {
throw new InvalidArgumentException("UpdateChannelConfiguration configFile must be non-null");
}
logger.trace(format("Creating UpdateChannelConfiguration from file %s", configFile.getAbsolutePath()));

try (InputStream is = new FileInputStream(configFile)) {
configBytes = IOUtils.toByteArray(is);
}
}

/**
* constructs a UpdateChannelConfiguration object
*
* @param configAsBytes the byte array containing the serialized channel configuration
*/
public UpdateChannelConfiguration(byte[] configAsBytes) {
this.configBytes = configAsBytes;
public UpdateChannelConfiguration(byte[] configAsBytes) throws InvalidArgumentException {
if (configAsBytes == null) {
throw new InvalidArgumentException("UpdateChannelConfiguration configAsBytes must be non-null");
}
logger.trace("Creating UpdateChannelConfiguration from bytes");
configBytes = configAsBytes;
}

/**
* sets the UpdateChannelConfiguration from a byte array
*
* @param updateChannelConfigurationAsBytes the byte array containing the serialized channel configuration
*/
public void setUpdateChannelConfiguration(byte[] updateChannelConfigurationAsBytes) {
this.configBytes = updateChannelConfigurationAsBytes;
public void setUpdateChannelConfiguration(byte[] updateChannelConfigurationAsBytes) throws InvalidArgumentException {
if (updateChannelConfigurationAsBytes == null) {
throw new InvalidArgumentException("UpdateChannelConfiguration updateChannelConfigurationAsBytes must be non-null");
}
logger.trace("Creating setUpdateChannelConfiguration from bytes");
configBytes = updateChannelConfigurationAsBytes;
}

/**
* @return the channel configuration serialized per protobuf and ready for inclusion into channel configuration
*/
public byte[] getUpdateChannelConfigurationAsBytes() {
return this.configBytes;
if (configBytes == null) {
logger.error("UpdateChannelConfiguration configBytes is null!");
} else if (IS_TRACE_LEVEL) {
logger.trace(format("getUpdateChannelConfigurationAsBytes: %s", toHexString(configBytes)));
}
return configBytes;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public static ByteString getSignatureHeaderAsByteString(User user, TransactionCo

Enrollment enrollment = user.getEnrollment();
String cert = enrollment.getCert();
logger.debug(format(" User: %s Certificate:\n%s", user.getName(), cert));
logger.debug(format(" User: %s Certificate: %s", user.getName(), cert == null ? "null" : toHexString(cert.getBytes(UTF_8))));

if (enrollment instanceof X509Enrollment) {
if (null == suite) {
Expand Down
2 changes: 2 additions & 0 deletions src/test/cirun.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export ORG_HYPERLEDGER_FABRIC_SDKTEST_INVOKEWAITTIME=300000
export ORG_HYPERLEDGER_FABRIC_SDKTEST_DEPLOYWAITTIME=1300000
export ORG_HYPERLEDGER_FABRIC_SDKTEST_PROPOSALWAITTIME=300000

export ORG_HYPERLEDGER_FABRIC_SDKTEST_RUNIDEMIXMTTEST=true

ORG_HYPERLEDGER_FABRIC_SDKTEST_VERSION=${ORG_HYPERLEDGER_FABRIC_SDKTEST_VERSION:-}

if [ "$ORG_HYPERLEDGER_FABRIC_SDKTEST_VERSION" == "1.0.0" ]; then
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"ddoc": "indexADDoc",
"index": {
"fields": [
"a"
]
},
"name": "indexA",
"type": "json"
}

This file was deleted.

12 changes: 0 additions & 12 deletions src/test/fixture/sdkintegration/e2e-2Orgs/v1.3/configtx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,6 @@ Organizations:
msptype: idemix
mspdir: crypto-config/peerOrganizations/org3.example.com

anchorpeers:
# anchorpeers defines the location of peers which can be used
# for cross org gossip communication. note, this value is only
# encoded in the genesis block in the application section context
- host: peer0.org3.example.com
port: 7051

- &Org2Idemix
# defaultorg defines the organization which is used in the sampleconfig
Expand All @@ -96,12 +90,6 @@ Organizations:
msptype: idemix
mspdir: crypto-config/peerOrganizations/org4.example.com

anchorpeers:
# anchorpeers defines the location of peers which can be used
# for cross org gossip communication. note, this value is only
# encoded in the genesis block in the application section context
- host: peer0.org4.example.com
port: 8051
################################################################################
#
# ORDERER
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class ChannelConfigurationTest {
private static final String TEST_BYTES_2 = "00112233445566778899";

@Test
public void testChannelConfigurationByeArray() {
public void testChannelConfigurationByeArray() throws Exception {
// Test empty constructor
new ChannelConfiguration();

Expand Down
13 changes: 9 additions & 4 deletions src/test/java/org/hyperledger/fabric/sdk/idemix/IdemixTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

import org.apache.milagro.amcl.FP256BN.BIG;
import org.apache.milagro.amcl.FP256BN.ECP;
import org.apache.milagro.amcl.RAND;
import org.hyperledger.fabric.protos.idemix.Idemix;
import org.hyperledger.fabric.sdk.exception.CryptoException;
import org.hyperledger.fabric.sdk.testutils.TestConfig;
import org.junit.Test;

import static org.junit.Assert.assertFalse;
Expand All @@ -46,8 +48,11 @@ public class IdemixTest {

@Test
public void idemixTest() throws ExecutionException, InterruptedException {
ExecutorService serviceSingleTask = Executors.newFixedThreadPool(THREAD_POOL);
ExecutorService serviceMultiTask = Executors.newFixedThreadPool(THREAD_POOL);
if (!TestConfig.getConfig().getRunIdemixMTTest()) {
return;
}
ExecutorService serviceSingleTask = Executors.newFixedThreadPool(THREAD_POOL);
ExecutorService serviceMultiTask = Executors.newFixedThreadPool(THREAD_POOL);

// Select attribute names and generate a Idemix Setup
String[] attributeNames = {"Attr1", "Attr2", "Attr3", "Attr4", "Attr5"};
Expand All @@ -64,7 +69,7 @@ public void idemixTest() throws ExecutionException, InterruptedException {
IdemixTask taskM = new IdemixTask(setup);
results.add(serviceMultiTask.submit(taskM));
}
for (Future<Boolean> f: results) {
for (Future<Boolean> f : results) {
assertTrue(f.get());
}
}
Expand Down Expand Up @@ -190,7 +195,7 @@ private void test() throws CryptoException {
assertFalse(signature.verify(disclosure, setup.key.getIpk(), msg, setup.attrs, 0, setup.revocationKeyPair.getPublic(), epoch));

// test signature verification with different issuer public key
assertFalse(signature.verify(disclosure2, new IdemixIssuerKey(new String[]{"Attr1, Attr2, Attr3, Attr4, Attr5"}).getIpk(), msg, setup.attrs, 0, setup.revocationKeyPair.getPublic(), epoch));
assertFalse(signature.verify(disclosure2, new IdemixIssuerKey(new String[] {"Attr1, Attr2, Attr3, Attr4, Attr5"}).getIpk(), msg, setup.attrs, 0, setup.revocationKeyPair.getPublic(), epoch));

// test signature verification with different message
byte[] msg2 = {1, 1, 1};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class TestConfig {
private static final String INVOKEWAITTIME = PROPBASE + "InvokeWaitTime";
private static final String DEPLOYWAITTIME = PROPBASE + "DeployWaitTime";
private static final String PROPOSALWAITTIME = PROPBASE + "ProposalWaitTime";
private static final String RUNIDEMIXMTTEST = PROPBASE + "RunIdemixMTTest"; // org.hyperledger.fabric.sdktest.RunIdemixMTTest ORG_HYPERLEDGER_FABRIC_SDKTEST_RUNIDEMIXMTTEST

private static final String INTEGRATIONTESTS_ORG = PROPBASE + "integrationTests.org.";
private static final Pattern orgPat = Pattern.compile("^" + Pattern.quote(INTEGRATIONTESTS_ORG) + "([^\\.]+)\\.mspid$");
Expand Down Expand Up @@ -120,6 +121,7 @@ private TestConfig() {
defaultProperty(INVOKEWAITTIME, "32000");
defaultProperty(DEPLOYWAITTIME, "120000");
defaultProperty(PROPOSALWAITTIME, "120000");
defaultProperty(RUNIDEMIXMTTEST, "false");

//////
defaultProperty(INTEGRATIONTESTS_ORG + "peerOrg1.mspid", "Org1MSP");
Expand Down Expand Up @@ -328,6 +330,10 @@ public long getProposalWaitTime() {
return Integer.parseInt(getProperty(PROPOSALWAITTIME));
}

public boolean getRunIdemixMTTest() {
return Boolean.valueOf(getProperty(RUNIDEMIXMTTEST));
}

public Collection<SampleOrg> getIntegrationTestsSampleOrgs() {
return Collections.unmodifiableCollection(sampleOrgs.values());
}
Expand Down
Loading

0 comments on commit f06b9ef

Please sign in to comment.