mirror of
https://github.com/corda/corda.git
synced 2025-01-18 10:46:38 +00:00
Minor: in CashTests make editIssuedBy into an infix fun with a space in the name, like owned by
.
Makes the code read a bit more like English.
This commit is contained in:
parent
bd8d056466
commit
28daae5bd4
@ -28,7 +28,6 @@ class CashTests {
|
|||||||
)
|
)
|
||||||
val outState = inState.copy(owner = DUMMY_PUBKEY_2)
|
val outState = inState.copy(owner = DUMMY_PUBKEY_2)
|
||||||
|
|
||||||
fun Cash.State.editInstitution(party: Party) = copy(deposit = deposit.copy(party = party))
|
|
||||||
fun Cash.State.editDepositRef(ref: Byte) = copy(deposit = deposit.copy(reference = OpaqueBytes.of(ref)))
|
fun Cash.State.editDepositRef(ref: Byte) = copy(deposit = deposit.copy(reference = OpaqueBytes.of(ref)))
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -53,7 +52,7 @@ class CashTests {
|
|||||||
}
|
}
|
||||||
tweak {
|
tweak {
|
||||||
output { outState }
|
output { outState }
|
||||||
output { outState.editInstitution(MINI_CORP) }
|
output { outState `issued by` MINI_CORP }
|
||||||
arg(DUMMY_PUBKEY_1) { Cash.Commands.Move() }
|
arg(DUMMY_PUBKEY_1) { Cash.Commands.Move() }
|
||||||
this `fails requirement` "at least one cash input"
|
this `fails requirement` "at least one cash input"
|
||||||
}
|
}
|
||||||
@ -153,7 +152,7 @@ class CashTests {
|
|||||||
// Can't change issuer.
|
// Can't change issuer.
|
||||||
transaction {
|
transaction {
|
||||||
input { inState }
|
input { inState }
|
||||||
output { outState.editInstitution(MINI_CORP) }
|
output { outState `issued by` MINI_CORP }
|
||||||
this `fails requirement` "at issuer MegaCorp the amounts balance"
|
this `fails requirement` "at issuer MegaCorp the amounts balance"
|
||||||
}
|
}
|
||||||
// Can't change deposit reference when splitting.
|
// Can't change deposit reference when splitting.
|
||||||
@ -184,7 +183,7 @@ class CashTests {
|
|||||||
// Can't have superfluous input states from different issuers.
|
// Can't have superfluous input states from different issuers.
|
||||||
transaction {
|
transaction {
|
||||||
input { inState }
|
input { inState }
|
||||||
input { inState.editInstitution(MINI_CORP) }
|
input { inState `issued by` MINI_CORP }
|
||||||
output { outState }
|
output { outState }
|
||||||
arg(DUMMY_PUBKEY_1) { Cash.Commands.Move() }
|
arg(DUMMY_PUBKEY_1) { Cash.Commands.Move() }
|
||||||
this `fails requirement` "at issuer MiniCorp the amounts balance"
|
this `fails requirement` "at issuer MiniCorp the amounts balance"
|
||||||
@ -224,9 +223,9 @@ class CashTests {
|
|||||||
// Multi-issuer case.
|
// Multi-issuer case.
|
||||||
transaction {
|
transaction {
|
||||||
input { inState }
|
input { inState }
|
||||||
input { inState.editInstitution(MINI_CORP) }
|
input { inState `issued by` MINI_CORP }
|
||||||
|
|
||||||
output { inState.copy(amount = inState.amount - 200.DOLLARS).editInstitution(MINI_CORP) }
|
output { inState.copy(amount = inState.amount - 200.DOLLARS) `issued by` MINI_CORP }
|
||||||
output { inState.copy(amount = inState.amount - 200.DOLLARS) }
|
output { inState.copy(amount = inState.amount - 200.DOLLARS) }
|
||||||
|
|
||||||
arg(DUMMY_PUBKEY_1) { Cash.Commands.Move() }
|
arg(DUMMY_PUBKEY_1) { Cash.Commands.Move() }
|
||||||
@ -246,7 +245,7 @@ class CashTests {
|
|||||||
transaction {
|
transaction {
|
||||||
// Gather 2000 dollars from two different issuers.
|
// Gather 2000 dollars from two different issuers.
|
||||||
input { inState }
|
input { inState }
|
||||||
input { inState.editInstitution(MINI_CORP) }
|
input { inState `issued by` MINI_CORP }
|
||||||
|
|
||||||
// Can't merge them together.
|
// Can't merge them together.
|
||||||
tweak {
|
tweak {
|
||||||
@ -262,7 +261,7 @@ class CashTests {
|
|||||||
|
|
||||||
// This works.
|
// This works.
|
||||||
output { inState.copy(owner = DUMMY_PUBKEY_2) }
|
output { inState.copy(owner = DUMMY_PUBKEY_2) }
|
||||||
output { inState.copy(owner = DUMMY_PUBKEY_2).editInstitution(MINI_CORP) }
|
output { inState.copy(owner = DUMMY_PUBKEY_2) `issued by` MINI_CORP }
|
||||||
arg(DUMMY_PUBKEY_1) { Cash.Commands.Move() }
|
arg(DUMMY_PUBKEY_1) { Cash.Commands.Move() }
|
||||||
this.accepts()
|
this.accepts()
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,9 @@ val TEST_PROGRAM_MAP: Map<SecureHash, Contract> = mapOf(
|
|||||||
//
|
//
|
||||||
// TODO: Make it impossible to forget to test either a failure or an accept for each transaction{} block
|
// TODO: Make it impossible to forget to test either a failure or an accept for each transaction{} block
|
||||||
|
|
||||||
infix fun Cash.State.`owned by`(owner: PublicKey) = this.copy(owner = owner)
|
infix fun Cash.State.`owned by`(owner: PublicKey) = copy(owner = owner)
|
||||||
|
infix fun Cash.State.`issued by`(party: Party) = copy(deposit = deposit.copy(party = party))
|
||||||
|
infix fun CommercialPaper.State.`owned by`(owner: PublicKey) = this.copy(owner = owner)
|
||||||
infix fun ICommercialPaperState.`owned by`(new_owner: PublicKey) = this.withOwner(new_owner)
|
infix fun ICommercialPaperState.`owned by`(new_owner: PublicKey) = this.withOwner(new_owner)
|
||||||
|
|
||||||
// Allows you to write 100.DOLLARS.CASH
|
// Allows you to write 100.DOLLARS.CASH
|
||||||
@ -320,4 +322,4 @@ class TransactionGroupDSL<T : ContractState>(private val stateType: Class<T>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline fun <reified T : ContractState> transactionGroupFor(body: TransactionGroupDSL<T>.() -> Unit) = TransactionGroupDSL<T>(T::class.java).apply { this.body() }
|
inline fun <reified T : ContractState> transactionGroupFor(body: TransactionGroupDSL<T>.() -> Unit) = TransactionGroupDSL<T>(T::class.java).apply { this.body() }
|
||||||
fun transactionGroup(body: TransactionGroupDSL<ContractState>.() -> Unit) = TransactionGroupDSL(ContractState::class.java).apply { this.body() }
|
fun transactionGroup(body: TransactionGroupDSL<ContractState>.() -> Unit) = TransactionGroupDSL(ContractState::class.java).apply { this.body() }
|
||||||
|
Loading…
Reference in New Issue
Block a user