Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"));

}

}