Skip to content

Instantly share code, notes, and snippets.

@parisyup
Created June 4, 2024 06:57
Show Gist options
  • Save parisyup/9e5a556bbf399f9234bdfae17736d2b0 to your computer and use it in GitHub Desktop.
Save parisyup/9e5a556bbf399f9234bdfae17736d2b0 to your computer and use it in GitHub Desktop.
// Only Two Participants
results["Only Two Participants"] = try {
val iouState = IOUState(
amount = 10,
paid = 3,
lender = myInfo.name,
borrower = otherMember.name,
linearId = UUID.randomUUID(),
participants = listOf(myInfo.ledgerKeys.first())
)
val txBuilder = ledgerService.createTransactionBuilder()
.setNotary(notary.name)
.setTimeWindowBetween(Instant.now(), Instant.now().plusMillis(Duration.ofDays(1).toMillis()))
.addOutputState(iouState)
.addCommand(IOUContract.Issue())
.addSignatories(iouState.participants)
@Suppress("DEPRECATION", "UNUSED_VARIABLE")
val signedTransaction = txBuilder.toSignedTransaction()
"Fail"
} catch (e:Exception) {
val exceptionMessage = e.message ?: "No exception message"
if (exceptionMessage.contains("only two participants")) {
"Pass" }
else {
"Contract failed but with a different Exception: ${e.message}"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment