mirror of
https://github.com/corda/corda.git
synced 2025-05-02 08:43:15 +00:00
universal: completed example FX Fwd Time Option
This commit is contained in:
parent
f19df50351
commit
66692542bd
@ -31,9 +31,21 @@ class FXFwdTimeOption
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val outContract1 = arrange {
|
||||||
|
highStreetBank.owes(acmeCorp, 1070.K, EUR)
|
||||||
|
}
|
||||||
|
val outContract2 = arrange {
|
||||||
|
acmeCorp.owes(highStreetBank, 1.M, USD)
|
||||||
|
}
|
||||||
|
|
||||||
val TEST_TX_TIME_1: Instant get() = Instant.parse("2017-09-02T12:00:00.00Z")
|
val TEST_TX_TIME_1: Instant get() = Instant.parse("2017-09-02T12:00:00.00Z")
|
||||||
|
val TEST_TX_TIME_BEFORE_MATURITY: Instant get() = Instant.parse("2018-05-01T12:00:00.00Z")
|
||||||
|
val TEST_TX_TIME_AFTER_MATURITY: Instant get() = Instant.parse("2018-06-02T12:00:00.00Z")
|
||||||
|
|
||||||
val inState = UniversalContract.State(listOf(DUMMY_NOTARY.owningKey), initialContract)
|
val inState = UniversalContract.State(listOf(DUMMY_NOTARY.owningKey), initialContract)
|
||||||
|
val outState1 = UniversalContract.State(listOf(DUMMY_NOTARY.owningKey), outContract1)
|
||||||
|
val outState2 = UniversalContract.State(listOf(DUMMY_NOTARY.owningKey), outContract2)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `issue - signature`() {
|
fun `issue - signature`() {
|
||||||
transaction {
|
transaction {
|
||||||
@ -56,4 +68,68 @@ class FXFwdTimeOption
|
|||||||
this.verifies()
|
this.verifies()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `maturity, bank exercise`() {
|
||||||
|
transaction {
|
||||||
|
input { inState }
|
||||||
|
output { outState1 }
|
||||||
|
output { outState2 }
|
||||||
|
|
||||||
|
timestamp(TEST_TX_TIME_AFTER_MATURITY)
|
||||||
|
|
||||||
|
tweak {
|
||||||
|
command(highStreetBank.owningKey) { UniversalContract.Commands.Action("some undefined name") }
|
||||||
|
this `fails with` "action must be defined"
|
||||||
|
}
|
||||||
|
tweak {
|
||||||
|
command(highStreetBank.owningKey) { UniversalContract.Commands.Action("exercise") }
|
||||||
|
this `fails with` "condition must be met"
|
||||||
|
}
|
||||||
|
tweak {
|
||||||
|
command(acmeCorp.owningKey) { UniversalContract.Commands.Action("exercise") }
|
||||||
|
this `fails with` "condition must be met"
|
||||||
|
}
|
||||||
|
tweak {
|
||||||
|
command(acmeCorp.owningKey) { UniversalContract.Commands.Action("expire") }
|
||||||
|
this `fails with` "condition must be met"
|
||||||
|
}
|
||||||
|
|
||||||
|
command(highStreetBank.owningKey) { UniversalContract.Commands.Action("expire") }
|
||||||
|
|
||||||
|
this.verifies()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `maturity, corp exercise`() {
|
||||||
|
transaction {
|
||||||
|
input { inState }
|
||||||
|
output { outState1 }
|
||||||
|
output { outState2 }
|
||||||
|
|
||||||
|
timestamp(TEST_TX_TIME_BEFORE_MATURITY)
|
||||||
|
|
||||||
|
tweak {
|
||||||
|
command(acmeCorp.owningKey) { UniversalContract.Commands.Action("some undefined name") }
|
||||||
|
this `fails with` "action must be defined"
|
||||||
|
}
|
||||||
|
tweak {
|
||||||
|
command(acmeCorp.owningKey) { UniversalContract.Commands.Action("expire") }
|
||||||
|
this `fails with` "condition must be met"
|
||||||
|
}
|
||||||
|
tweak {
|
||||||
|
command(highStreetBank.owningKey) { UniversalContract.Commands.Action("expire") }
|
||||||
|
this `fails with` "condition must be met"
|
||||||
|
}
|
||||||
|
tweak {
|
||||||
|
command(highStreetBank.owningKey) { UniversalContract.Commands.Action("exercise") }
|
||||||
|
this `fails with` "condition must be met"
|
||||||
|
}
|
||||||
|
|
||||||
|
command(acmeCorp.owningKey) { UniversalContract.Commands.Action("exercise") }
|
||||||
|
|
||||||
|
this.verifies()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user