Skip to content

Commit

Permalink
Merge pull request hyperledger#188 from kemi04/privateTests
Browse files Browse the repository at this point in the history
Integration tests extended
  • Loading branch information
mbwhite authored Jul 13, 2021
2 parents 33d16ae + 6be7a72 commit 6563fb2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
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"));

}

}

0 comments on commit 6563fb2

Please sign in to comment.