This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Multiple Commands not permitted | |
results["Multiple Commands not permitted"] = try { | |
val iouState = IOUState( | |
amount = 10, | |
paid = 3, | |
lender = myInfo.name, | |
borrower = otherMember.name, | |
linearId = UUID.randomUUID(), | |
participants = listOf(myInfo.ledgerKeys.first(), otherMember.ledgerKeys.first()) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Suspendable | |
private String testMultipleCommandsNotPermitted(MemberInfo myInfo, MemberInfo otherMember, NotaryInfo notary) { | |
try { | |
IOUState iouState = new IOUState( //create sample output state for the test | |
10, | |
myInfo.getName(), | |
otherMember.getName(), | |
3, | |
UUID.randomUUID(), | |
Arrays.asList(myInfo.getLedgerKeys().get(0), otherMember.getLedgerKeys().get(0)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IOUState iouState = new IOUState( //create sample output state for the test | |
10, | |
myInfo.getName(), | |
otherMember.getName(), | |
3, | |
UUID.randomUUID(), | |
Arrays.asList(myInfo.getLedgerKeys().get(0), otherMember.getLedgerKeys().get(0)) | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val iouState = IOUState( | |
amount = 10, | |
paid = 3, | |
lender = myInfo.name, | |
borrower = otherMember.name, | |
linearId = UUID.randomUUID(), | |
participants = listOf(myInfo.ledgerKeys.first(), otherMember.ledgerKeys.first()) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var txBuilder = ledgerService.createTransactionBuilder() //build sample transaction to test | |
.setNotary(notary.getName()) | |
.setTimeWindowBetween(Instant.now(), Instant.now().plusMillis(Duration.ofDays(1).toMillis())) | |
.addOutputState(iouState) | |
.addInputState(inputStateRef) | |
.addCommand(new IOUContract.Issue()) | |
.addCommand(new IOUContract.Transfer()) | |
.addSignatories(iouState.getParticipants()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val txBuilder = ledgerService.createTransactionBuilder() | |
.setNotary(notary.name) | |
.setTimeWindowBetween(Instant.now(), Instant.now().plusMillis(Duration.ofDays(1).toMillis())) | |
.addOutputState(iouState) | |
.addInputState(inputStateRef) | |
.addCommand(IOUContract.Issue()) | |
.addCommand(IOUContract.Transfer()) | |
.addSignatories(iouState.participants) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return "Fail";//no error found. Contract failed. | |
} catch (Exception e) {//catching the error to see if the contract passed | |
//check if gotten the expected error | |
String exceptionMessage = e.getMessage() != null ? e.getMessage() : "No exception message"; | |
if (exceptionMessage.contains("Require a single command")) { | |
return "Pass"; //expected error found so the contract passes the test | |
} else { | |
return "Contract failed but with a different Exception: " + e.getMessage();//different error thrown. Contract failed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Fail" | |
} catch (e:Exception) { | |
val exceptionMessage = e.message ?: "No exception message" | |
if (exceptionMessage.contains("Requires a single command.")) { | |
"Pass" } | |
else { | |
"Contract failed but with a different Exception: ${e.message}" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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()) | |
) |
OlderNewer