Skip to content

Commit

Permalink
Explicit dependencies in integration test chaincode
Browse files Browse the repository at this point in the history
Resolves breakages with latest releases of the chaincode shim, where more recent Gradle versions are more strict in requiring dependencies to be specified rather than picked up as transient dependencies.

Also update commons-compress dependency to address security vulnerability.

Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>
  • Loading branch information
bestbeforetoday authored and denyeart committed Aug 18, 2021
1 parent e181ceb commit fc05ef2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.20</version>
<version>1.21</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ repositories {

dependencies {
implementation group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '2.+'
implementation 'commons-logging:commons-logging:1.2'
}

shadowJar {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
package org.hyperledger.fabric.example;

import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;

import com.google.protobuf.ByteString;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hyperledger.fabric.shim.ChaincodeBase;
import org.hyperledger.fabric.shim.ChaincodeStub;
import org.hyperledger.fabric.shim.ResponseUtils;

import static java.nio.charset.StandardCharsets.UTF_8;

public class SimpleChaincode extends ChaincodeBase {

private static Log _logger = LogFactory.getLog(SimpleChaincode.class);

@Override
Expand Down Expand Up @@ -112,9 +109,6 @@ private Response move(ChaincodeStub stub, List<String> args) {
}
}
return ResponseUtils.newSuccessResponse();
// return newSuccessResponse("invoke finished successfully", ByteString.copyFrom(accountFromKey + ": " + accountFromValue + " " + accountToKey + ": " + accountToValue, UTF_8).
//
// toByteArray());
}

// Deletes an entity from state
Expand All @@ -140,11 +134,10 @@ private Response query(ChaincodeStub stub, List<String> args) {
return ResponseUtils.newErrorResponse(String.format("Error: state for %s is null", key));
}
_logger.info(String.format("Query Response:\nName: %s, Amount: %s\n", key, val));
return ResponseUtils.newSuccessResponse(val, ByteString.copyFrom(val, UTF_8).toByteArray());
return ResponseUtils.newSuccessResponse(val, val.getBytes(StandardCharsets.UTF_8));
}

public static void main(String[] args) {
new SimpleChaincode().start(args);
}

}

0 comments on commit fc05ef2

Please sign in to comment.