Skip to content

Instantly share code, notes, and snippets.

@parisyup
Created June 4, 2024 06:54
Show Gist options
  • Save parisyup/9cff6f683f9159ae560e2347ee82313f to your computer and use it in GitHub Desktop.
Save parisyup/9cff6f683f9159ae560e2347ee82313f to your computer and use it in GitHub Desktop.
@Suspendable
private String testOnlyTwoParticipants(MemberInfo myInfo, MemberInfo otherMember, NotaryInfo notary) {
try {
IOUState iouState = new IOUState(
10,
myInfo.getName(),
otherMember.getName(),
3,
UUID.randomUUID(),
Collections.singletonList(myInfo.getLedgerKeys().get(0))
);
var txBuilder = ledgerService.createTransactionBuilder()
.setNotary(notary.getName())
.setTimeWindowBetween(Instant.now(), Instant.now().plusMillis(Duration.ofDays(1).toMillis()))
.addOutputState(iouState)
.addCommand(new IOUContract.Issue())
.addSignatories(iouState.getParticipants());
var signedTransaction = txBuilder.toSignedTransaction();
return "Fail";
} catch (Exception e) {
String exceptionMessage = e.getMessage() != null ? e.getMessage() : "No exception message";
if (exceptionMessage.contains("only two participants")) {
return "Pass";
} else {
return "Contract failed but with a different Exception: " + e.getMessage();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment