diff --git a/fabric-chaincode-integration-test/src/contracts/fabric-shim-api/src/main/java/org/hyperledger/fabric/example/EndorsementCC.java b/fabric-chaincode-integration-test/src/contracts/fabric-shim-api/src/main/java/org/hyperledger/fabric/example/EndorsementCC.java index fc4e8157..843bea45 100644 --- a/fabric-chaincode-integration-test/src/contracts/fabric-shim-api/src/main/java/org/hyperledger/fabric/example/EndorsementCC.java +++ b/fabric-chaincode-integration-test/src/contracts/fabric-shim-api/src/main/java/org/hyperledger/fabric/example/EndorsementCC.java @@ -149,4 +149,31 @@ public String getval(Context ctx, String type) { return value; } + @Transaction() + public void deleteval(Context ctx, String type) { + _logger.info("Invoking deleteval"); + + if ("pub".equals(type)) { + ctx.getStub().delState("pub"); + } else if ("priv".equals(type)) { + ctx.getStub().delPrivateData("col", "priv"); + } else { + throw new RuntimeException("Unknown key specified"); + } + } + + @Transaction(intent = Transaction.TYPE.EVALUATE) + public boolean recordExists(Context ctx, String type) { + _logger.info("Invoking recordExists"); + + if ("pub".equals(type)) { + byte[] buffer = ctx.getStub().getState("pub"); + return (buffer != null && buffer.length > 0); + } else if ("priv".equals(type)) { + byte[] buffer = ctx.getStub().getPrivateDataHash("col", "priv"); + return (buffer != null && buffer.length > 0); + } else { + throw new RuntimeException("Unknown key specified"); + } + } } diff --git a/fabric-chaincode-integration-test/src/test/java/org/hyperleder/fabric/shim/integration/shimtests/SBECCIntegrationTest.java b/fabric-chaincode-integration-test/src/test/java/org/hyperleder/fabric/shim/integration/shimtests/SBECCIntegrationTest.java index a6034c4e..abdd2e98 100644 --- a/fabric-chaincode-integration-test/src/test/java/org/hyperleder/fabric/shim/integration/shimtests/SBECCIntegrationTest.java +++ b/fabric-chaincode-integration-test/src/test/java/org/hyperleder/fabric/shim/integration/shimtests/SBECCIntegrationTest.java @@ -89,6 +89,11 @@ public void RunSBE_pub_setget() throws NoSuchAlgorithmException, InvalidKeySpecE assertThat(text, containsString("Org2MSP")); assertThat(text, not(containsString("Org1MSP"))); + text = helper.invoke(new String[] {"EndorsementCC:deleteval", mode}); + assertThat(text, containsString("success")); + text = helper.invoke(new String[] {"EndorsementCC:recordExists", mode}); + assertThat(text, containsString("false")); + } @Test @@ -151,6 +156,11 @@ public void RunSBE_priv() throws NoSuchAlgorithmException, InvalidKeySpecExcepti assertThat(text, containsString("Org2MSP")); assertThat(text, not(containsString("Org1MSP"))); + text = helper.invoke(new String[] {"EndorsementCC:deleteval", mode}); + assertThat(text, containsString("success")); + text = helper.invoke(new String[] {"EndorsementCC:recordExists", mode}); + assertThat(text, containsString("false")); + } }