mirror of
https://github.com/corda/corda.git
synced 2025-06-21 08:40:03 +00:00
CORDA-654 Simplify TransactionDSL API (#2152)
This commit is contained in:
@ -172,16 +172,14 @@ class Cap {
|
||||
@Test
|
||||
fun issue() {
|
||||
transaction {
|
||||
output(UNIVERSAL_PROGRAM_ID) { stateInitial }
|
||||
output(UNIVERSAL_PROGRAM_ID, stateInitial)
|
||||
timeWindow(TEST_TX_TIME_1)
|
||||
|
||||
tweak {
|
||||
command(acmeCorp.owningKey) { UniversalContract.Commands.Issue() }
|
||||
command(acmeCorp.owningKey, UniversalContract.Commands.Issue())
|
||||
this `fails with` "the transaction is signed by all liable parties"
|
||||
}
|
||||
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Issue() }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Issue())
|
||||
this.verifies()
|
||||
}
|
||||
}
|
||||
@ -189,44 +187,38 @@ class Cap {
|
||||
@Test
|
||||
fun `first fixing`() {
|
||||
transaction {
|
||||
input(UNIVERSAL_PROGRAM_ID) { stateInitial }
|
||||
output(UNIVERSAL_PROGRAM_ID) { stateAfterFixingFirst }
|
||||
input(UNIVERSAL_PROGRAM_ID, stateInitial)
|
||||
output(UNIVERSAL_PROGRAM_ID, stateAfterFixingFirst)
|
||||
timeWindow(TEST_TX_TIME_1)
|
||||
|
||||
tweak {
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Action("some undefined name") }
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Action("some undefined name"))
|
||||
this `fails with` "action must be defined"
|
||||
}
|
||||
|
||||
tweak {
|
||||
// wrong source
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBORx", tradeDate, Tenor("3M")), 1.0.bd))) }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBORx", tradeDate, Tenor("3M")), 1.0.bd))))
|
||||
this `fails with` "relevant fixing must be included"
|
||||
}
|
||||
|
||||
tweak {
|
||||
// wrong date
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBOR", tradeDate.plusYears(1), Tenor("3M")), 1.0.bd))) }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBOR", tradeDate.plusYears(1), Tenor("3M")), 1.0.bd))))
|
||||
this `fails with` "relevant fixing must be included"
|
||||
}
|
||||
|
||||
tweak {
|
||||
// wrong tenor
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBOR", tradeDate, Tenor("9M")), 1.0.bd))) }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBOR", tradeDate, Tenor("9M")), 1.0.bd))))
|
||||
this `fails with` "relevant fixing must be included"
|
||||
}
|
||||
|
||||
tweak {
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBOR", tradeDate, Tenor("3M")), 1.5.bd))) }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBOR", tradeDate, Tenor("3M")), 1.5.bd))))
|
||||
this `fails with` "output state does not reflect fix command"
|
||||
}
|
||||
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBOR", tradeDate, Tenor("3M")), 1.0.bd))) }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBOR", tradeDate, Tenor("3M")), 1.0.bd))))
|
||||
this.verifies()
|
||||
}
|
||||
}
|
||||
@ -234,19 +226,16 @@ class Cap {
|
||||
@Test
|
||||
fun `first execute`() {
|
||||
transaction {
|
||||
input(UNIVERSAL_PROGRAM_ID) { stateAfterFixingFirst }
|
||||
output(UNIVERSAL_PROGRAM_ID) { stateAfterExecutionFirst }
|
||||
output(UNIVERSAL_PROGRAM_ID) { statePaymentFirst }
|
||||
|
||||
input(UNIVERSAL_PROGRAM_ID, stateAfterFixingFirst)
|
||||
output(UNIVERSAL_PROGRAM_ID, stateAfterExecutionFirst)
|
||||
output(UNIVERSAL_PROGRAM_ID, statePaymentFirst)
|
||||
timeWindow(TEST_TX_TIME_1)
|
||||
|
||||
tweak {
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Action("some undefined name") }
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Action("some undefined name"))
|
||||
this `fails with` "action must be defined"
|
||||
}
|
||||
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Action("exercise") }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Action("exercise"))
|
||||
this.verifies()
|
||||
}
|
||||
}
|
||||
@ -254,18 +243,15 @@ class Cap {
|
||||
@Test
|
||||
fun `final execute`() {
|
||||
transaction {
|
||||
input(UNIVERSAL_PROGRAM_ID) { stateAfterFixingFinal }
|
||||
output(UNIVERSAL_PROGRAM_ID) { statePaymentFinal }
|
||||
|
||||
input(UNIVERSAL_PROGRAM_ID, stateAfterFixingFinal)
|
||||
output(UNIVERSAL_PROGRAM_ID, statePaymentFinal)
|
||||
timeWindow(TEST_TX_TIME_1)
|
||||
|
||||
tweak {
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Action("some undefined name") }
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Action("some undefined name"))
|
||||
this `fails with` "action must be defined"
|
||||
}
|
||||
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Action("exercise") }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Action("exercise"))
|
||||
this.verifies()
|
||||
}
|
||||
}
|
||||
@ -273,44 +259,38 @@ class Cap {
|
||||
@Test
|
||||
fun `second fixing`() {
|
||||
transaction {
|
||||
input(UNIVERSAL_PROGRAM_ID) { stateAfterExecutionFirst }
|
||||
output(UNIVERSAL_PROGRAM_ID) { stateAfterFixingFinal }
|
||||
input(UNIVERSAL_PROGRAM_ID, stateAfterExecutionFirst)
|
||||
output(UNIVERSAL_PROGRAM_ID, stateAfterFixingFinal)
|
||||
timeWindow(TEST_TX_TIME_1)
|
||||
|
||||
tweak {
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Action("some undefined name") }
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Action("some undefined name"))
|
||||
this `fails with` "action must be defined"
|
||||
}
|
||||
|
||||
tweak {
|
||||
// wrong source
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBORx", BusinessCalendar.parseDateFromString("2017-03-01"), Tenor("3M")), 1.0.bd))) }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBORx", BusinessCalendar.parseDateFromString("2017-03-01"), Tenor("3M")), 1.0.bd))))
|
||||
this `fails with` "relevant fixing must be included"
|
||||
}
|
||||
|
||||
tweak {
|
||||
// wrong date
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBOR", BusinessCalendar.parseDateFromString("2017-03-01").plusYears(1), Tenor("3M")), 1.0.bd))) }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBOR", BusinessCalendar.parseDateFromString("2017-03-01").plusYears(1), Tenor("3M")), 1.0.bd))))
|
||||
this `fails with` "relevant fixing must be included"
|
||||
}
|
||||
|
||||
tweak {
|
||||
// wrong tenor
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBOR", BusinessCalendar.parseDateFromString("2017-03-01"), Tenor("9M")), 1.0.bd))) }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBOR", BusinessCalendar.parseDateFromString("2017-03-01"), Tenor("9M")), 1.0.bd))))
|
||||
this `fails with` "relevant fixing must be included"
|
||||
}
|
||||
|
||||
tweak {
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBOR", BusinessCalendar.parseDateFromString("2017-03-01"), Tenor("3M")), 1.5.bd))) }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBOR", BusinessCalendar.parseDateFromString("2017-03-01"), Tenor("3M")), 1.5.bd))))
|
||||
this `fails with` "output state does not reflect fix command"
|
||||
}
|
||||
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBOR", BusinessCalendar.parseDateFromString("2017-03-01"), Tenor("3M")), 1.0.bd))) }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBOR", BusinessCalendar.parseDateFromString("2017-03-01"), Tenor("3M")), 1.0.bd))))
|
||||
this.verifies()
|
||||
}
|
||||
}
|
||||
|
@ -55,16 +55,14 @@ class Caplet {
|
||||
@Test
|
||||
fun issue() {
|
||||
transaction {
|
||||
output(UNIVERSAL_PROGRAM_ID) { stateStart }
|
||||
output(UNIVERSAL_PROGRAM_ID, stateStart)
|
||||
timeWindow(TEST_TX_TIME_1)
|
||||
|
||||
tweak {
|
||||
command(acmeCorp.owningKey) { UniversalContract.Commands.Issue() }
|
||||
command(acmeCorp.owningKey, UniversalContract.Commands.Issue())
|
||||
this `fails with` "the transaction is signed by all liable parties"
|
||||
}
|
||||
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Issue() }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Issue())
|
||||
this.verifies()
|
||||
}
|
||||
}
|
||||
@ -72,17 +70,15 @@ class Caplet {
|
||||
@Test
|
||||
fun `execute`() {
|
||||
transaction {
|
||||
input(UNIVERSAL_PROGRAM_ID) { stateFixed }
|
||||
output(UNIVERSAL_PROGRAM_ID) { stateFinal }
|
||||
input(UNIVERSAL_PROGRAM_ID, stateFixed)
|
||||
output(UNIVERSAL_PROGRAM_ID, stateFinal)
|
||||
timeWindow(TEST_TX_TIME_1)
|
||||
|
||||
tweak {
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Action("some undefined name") }
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Action("some undefined name"))
|
||||
this `fails with` "action must be defined"
|
||||
}
|
||||
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Action("exercise") }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Action("exercise"))
|
||||
this.verifies()
|
||||
}
|
||||
}
|
||||
@ -90,44 +86,38 @@ class Caplet {
|
||||
@Test
|
||||
fun `fixing`() {
|
||||
transaction {
|
||||
input(UNIVERSAL_PROGRAM_ID) { stateStart }
|
||||
output(UNIVERSAL_PROGRAM_ID) { stateFixed }
|
||||
input(UNIVERSAL_PROGRAM_ID, stateStart)
|
||||
output(UNIVERSAL_PROGRAM_ID, stateFixed)
|
||||
timeWindow(TEST_TX_TIME_1)
|
||||
|
||||
tweak {
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Action("some undefined name") }
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Action("some undefined name"))
|
||||
this `fails with` "action must be defined"
|
||||
}
|
||||
|
||||
tweak {
|
||||
// wrong source
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBORx", tradeDate, Tenor("6M")), 1.0.bd))) }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBORx", tradeDate, Tenor("6M")), 1.0.bd))))
|
||||
this `fails with` "relevant fixing must be included"
|
||||
}
|
||||
|
||||
tweak {
|
||||
// wrong date
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBOR", tradeDate.plusYears(1), Tenor("6M")), 1.0.bd))) }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBOR", tradeDate.plusYears(1), Tenor("6M")), 1.0.bd))))
|
||||
this `fails with` "relevant fixing must be included"
|
||||
}
|
||||
|
||||
tweak {
|
||||
// wrong tenor
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBOR", tradeDate, Tenor("3M")), 1.0.bd))) }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBOR", tradeDate, Tenor("3M")), 1.0.bd))))
|
||||
this `fails with` "relevant fixing must be included"
|
||||
}
|
||||
|
||||
tweak {
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBOR", tradeDate, Tenor("6M")), 1.5.bd))) }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBOR", tradeDate, Tenor("6M")), 1.5.bd))))
|
||||
this `fails with` "output state does not reflect fix command"
|
||||
}
|
||||
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBOR", tradeDate, Tenor("6M")), 1.0.bd))) }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBOR", tradeDate, Tenor("6M")), 1.0.bd))))
|
||||
this.verifies()
|
||||
}
|
||||
}
|
||||
|
@ -52,20 +52,18 @@ class FXFwdTimeOption {
|
||||
@Test
|
||||
fun `issue - signature`() {
|
||||
transaction {
|
||||
output(UNIVERSAL_PROGRAM_ID) { inState }
|
||||
output(UNIVERSAL_PROGRAM_ID, inState)
|
||||
timeWindow(TEST_TX_TIME_1)
|
||||
|
||||
tweak {
|
||||
command(acmeCorp.owningKey) { UniversalContract.Commands.Issue() }
|
||||
command(acmeCorp.owningKey, UniversalContract.Commands.Issue())
|
||||
this `fails with` "the transaction is signed by all liable parties"
|
||||
}
|
||||
tweak {
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Issue() }
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Issue())
|
||||
this `fails with` "the transaction is signed by all liable parties"
|
||||
}
|
||||
|
||||
command(highStreetBank.owningKey, acmeCorp.owningKey) { UniversalContract.Commands.Issue() }
|
||||
|
||||
command(listOf(highStreetBank.owningKey, acmeCorp.owningKey), UniversalContract.Commands.Issue())
|
||||
this.verifies()
|
||||
}
|
||||
}
|
||||
@ -73,31 +71,28 @@ class FXFwdTimeOption {
|
||||
@Test
|
||||
fun `maturity, bank exercise`() {
|
||||
transaction {
|
||||
input(UNIVERSAL_PROGRAM_ID) { inState }
|
||||
output(UNIVERSAL_PROGRAM_ID) { outState1 }
|
||||
output(UNIVERSAL_PROGRAM_ID) { outState2 }
|
||||
|
||||
input(UNIVERSAL_PROGRAM_ID, inState)
|
||||
output(UNIVERSAL_PROGRAM_ID, outState1)
|
||||
output(UNIVERSAL_PROGRAM_ID, outState2)
|
||||
timeWindow(TEST_TX_TIME_AFTER_MATURITY)
|
||||
|
||||
tweak {
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Action("some undefined name") }
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Action("some undefined name"))
|
||||
this `fails with` "action must be defined"
|
||||
}
|
||||
tweak {
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Action("exercise") }
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Action("exercise"))
|
||||
this `fails with` "condition must be met"
|
||||
}
|
||||
tweak {
|
||||
command(acmeCorp.owningKey) { UniversalContract.Commands.Action("exercise") }
|
||||
command(acmeCorp.owningKey, UniversalContract.Commands.Action("exercise"))
|
||||
this `fails with` "condition must be met"
|
||||
}
|
||||
tweak {
|
||||
command(acmeCorp.owningKey) { UniversalContract.Commands.Action("expire") }
|
||||
command(acmeCorp.owningKey, UniversalContract.Commands.Action("expire"))
|
||||
this `fails with` "condition must be met"
|
||||
}
|
||||
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Action("expire") }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Action("expire"))
|
||||
this.verifies()
|
||||
}
|
||||
}
|
||||
@ -105,31 +100,28 @@ class FXFwdTimeOption {
|
||||
@Test
|
||||
fun `maturity, corp exercise`() {
|
||||
transaction {
|
||||
input(UNIVERSAL_PROGRAM_ID) { inState }
|
||||
output(UNIVERSAL_PROGRAM_ID) { outState1 }
|
||||
output(UNIVERSAL_PROGRAM_ID) { outState2 }
|
||||
|
||||
input(UNIVERSAL_PROGRAM_ID, inState)
|
||||
output(UNIVERSAL_PROGRAM_ID, outState1)
|
||||
output(UNIVERSAL_PROGRAM_ID, outState2)
|
||||
timeWindow(TEST_TX_TIME_BEFORE_MATURITY)
|
||||
|
||||
tweak {
|
||||
command(acmeCorp.owningKey) { UniversalContract.Commands.Action("some undefined name") }
|
||||
command(acmeCorp.owningKey, UniversalContract.Commands.Action("some undefined name"))
|
||||
this `fails with` "action must be defined"
|
||||
}
|
||||
tweak {
|
||||
command(acmeCorp.owningKey) { UniversalContract.Commands.Action("expire") }
|
||||
command(acmeCorp.owningKey, UniversalContract.Commands.Action("expire"))
|
||||
this `fails with` "condition must be met"
|
||||
}
|
||||
tweak {
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Action("expire") }
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Action("expire"))
|
||||
this `fails with` "condition must be met"
|
||||
}
|
||||
tweak {
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Action("exercise") }
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Action("exercise"))
|
||||
this `fails with` "condition must be met"
|
||||
}
|
||||
|
||||
command(acmeCorp.owningKey) { UniversalContract.Commands.Action("exercise") }
|
||||
|
||||
command(acmeCorp.owningKey, UniversalContract.Commands.Action("exercise"))
|
||||
this.verifies()
|
||||
}
|
||||
}
|
||||
|
@ -44,20 +44,18 @@ class FXSwap {
|
||||
fun `issue - signature`() {
|
||||
|
||||
transaction {
|
||||
output(UNIVERSAL_PROGRAM_ID) { inState }
|
||||
output(UNIVERSAL_PROGRAM_ID, inState)
|
||||
timeWindow(TEST_TX_TIME_1)
|
||||
|
||||
tweak {
|
||||
command(acmeCorp.owningKey) { UniversalContract.Commands.Issue() }
|
||||
command(acmeCorp.owningKey, UniversalContract.Commands.Issue())
|
||||
this `fails with` "the transaction is signed by all liable parties"
|
||||
}
|
||||
tweak {
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Issue() }
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Issue())
|
||||
this `fails with` "the transaction is signed by all liable parties"
|
||||
}
|
||||
|
||||
command(highStreetBank.owningKey, acmeCorp.owningKey) { UniversalContract.Commands.Issue() }
|
||||
|
||||
command(listOf(highStreetBank.owningKey, acmeCorp.owningKey), UniversalContract.Commands.Issue())
|
||||
this.verifies()
|
||||
}
|
||||
}
|
||||
@ -65,18 +63,16 @@ class FXSwap {
|
||||
@Test
|
||||
fun `execute`() {
|
||||
transaction {
|
||||
input(UNIVERSAL_PROGRAM_ID) { inState }
|
||||
output(UNIVERSAL_PROGRAM_ID) { outState1 }
|
||||
output(UNIVERSAL_PROGRAM_ID) { outState2 }
|
||||
input(UNIVERSAL_PROGRAM_ID, inState)
|
||||
output(UNIVERSAL_PROGRAM_ID, outState1)
|
||||
output(UNIVERSAL_PROGRAM_ID, outState2)
|
||||
timeWindow(TEST_TX_TIME_1)
|
||||
|
||||
tweak {
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Action("some undefined name") }
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Action("some undefined name"))
|
||||
this `fails with` "action must be defined"
|
||||
}
|
||||
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Action("execute") }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Action("execute"))
|
||||
this.verifies()
|
||||
}
|
||||
}
|
||||
@ -84,18 +80,16 @@ class FXSwap {
|
||||
@Test
|
||||
fun `execute - reversed order`() {
|
||||
transaction {
|
||||
input(UNIVERSAL_PROGRAM_ID) { inState }
|
||||
output(UNIVERSAL_PROGRAM_ID) { outState2 }
|
||||
output(UNIVERSAL_PROGRAM_ID) { outState1 }
|
||||
input(UNIVERSAL_PROGRAM_ID, inState)
|
||||
output(UNIVERSAL_PROGRAM_ID, outState2)
|
||||
output(UNIVERSAL_PROGRAM_ID, outState1)
|
||||
timeWindow(TEST_TX_TIME_1)
|
||||
|
||||
tweak {
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Action("some undefined name") }
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Action("some undefined name"))
|
||||
this `fails with` "action must be defined"
|
||||
}
|
||||
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Action("execute") }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Action("execute"))
|
||||
this.verifies()
|
||||
}
|
||||
}
|
||||
@ -103,12 +97,11 @@ class FXSwap {
|
||||
@Test
|
||||
fun `execute - not authorized`() {
|
||||
transaction {
|
||||
input(UNIVERSAL_PROGRAM_ID) { inState }
|
||||
output(UNIVERSAL_PROGRAM_ID) { outState1 }
|
||||
output(UNIVERSAL_PROGRAM_ID) { outState2 }
|
||||
input(UNIVERSAL_PROGRAM_ID, inState)
|
||||
output(UNIVERSAL_PROGRAM_ID, outState1)
|
||||
output(UNIVERSAL_PROGRAM_ID, outState2)
|
||||
timeWindow(TEST_TX_TIME_1)
|
||||
|
||||
command(momAndPop.owningKey) { UniversalContract.Commands.Action("execute") }
|
||||
command(momAndPop.owningKey, UniversalContract.Commands.Action("execute"))
|
||||
this `fails with` "condition must be met"
|
||||
}
|
||||
}
|
||||
@ -116,12 +109,11 @@ class FXSwap {
|
||||
@Test
|
||||
fun `execute - before maturity`() {
|
||||
transaction {
|
||||
input(UNIVERSAL_PROGRAM_ID) { inState }
|
||||
output(UNIVERSAL_PROGRAM_ID) { outState1 }
|
||||
output(UNIVERSAL_PROGRAM_ID) { outState2 }
|
||||
input(UNIVERSAL_PROGRAM_ID, inState)
|
||||
output(UNIVERSAL_PROGRAM_ID, outState1)
|
||||
output(UNIVERSAL_PROGRAM_ID, outState2)
|
||||
timeWindow(TEST_TX_TIME_TOO_EARLY)
|
||||
|
||||
command(acmeCorp.owningKey) { UniversalContract.Commands.Action("execute") }
|
||||
command(acmeCorp.owningKey, UniversalContract.Commands.Action("execute"))
|
||||
this `fails with` "condition must be met"
|
||||
}
|
||||
}
|
||||
@ -129,11 +121,10 @@ class FXSwap {
|
||||
@Test
|
||||
fun `execute - outState mismatch 1`() {
|
||||
transaction {
|
||||
input(UNIVERSAL_PROGRAM_ID) { inState }
|
||||
output(UNIVERSAL_PROGRAM_ID) { outState1 }
|
||||
input(UNIVERSAL_PROGRAM_ID, inState)
|
||||
output(UNIVERSAL_PROGRAM_ID, outState1)
|
||||
timeWindow(TEST_TX_TIME_1)
|
||||
|
||||
command(acmeCorp.owningKey) { UniversalContract.Commands.Action("execute") }
|
||||
command(acmeCorp.owningKey, UniversalContract.Commands.Action("execute"))
|
||||
this `fails with` "output state must match action result state"
|
||||
}
|
||||
}
|
||||
@ -141,12 +132,11 @@ class FXSwap {
|
||||
@Test
|
||||
fun `execute - outState mismatch 2`() {
|
||||
transaction {
|
||||
input(UNIVERSAL_PROGRAM_ID) { inState }
|
||||
output(UNIVERSAL_PROGRAM_ID) { outState1 }
|
||||
output(UNIVERSAL_PROGRAM_ID) { outStateBad2 }
|
||||
input(UNIVERSAL_PROGRAM_ID, inState)
|
||||
output(UNIVERSAL_PROGRAM_ID, outState1)
|
||||
output(UNIVERSAL_PROGRAM_ID, outStateBad2)
|
||||
timeWindow(TEST_TX_TIME_1)
|
||||
|
||||
command(acmeCorp.owningKey) { UniversalContract.Commands.Action("execute") }
|
||||
command(acmeCorp.owningKey, UniversalContract.Commands.Action("execute"))
|
||||
this `fails with` "output states must match action result state"
|
||||
}
|
||||
}
|
||||
@ -154,12 +144,11 @@ class FXSwap {
|
||||
@Test
|
||||
fun `execute - outState mismatch 3`() {
|
||||
transaction {
|
||||
input(UNIVERSAL_PROGRAM_ID) { inState }
|
||||
output(UNIVERSAL_PROGRAM_ID) { outStateBad1 }
|
||||
output(UNIVERSAL_PROGRAM_ID) { outState2 }
|
||||
input(UNIVERSAL_PROGRAM_ID, inState)
|
||||
output(UNIVERSAL_PROGRAM_ID, outStateBad1)
|
||||
output(UNIVERSAL_PROGRAM_ID, outState2)
|
||||
timeWindow(TEST_TX_TIME_1)
|
||||
|
||||
command(acmeCorp.owningKey) { UniversalContract.Commands.Action("execute") }
|
||||
command(acmeCorp.owningKey, UniversalContract.Commands.Action("execute"))
|
||||
this `fails with` "output states must match action result state"
|
||||
}
|
||||
}
|
||||
@ -167,12 +156,11 @@ class FXSwap {
|
||||
@Test
|
||||
fun `execute - outState mismatch 4`() {
|
||||
transaction {
|
||||
input(UNIVERSAL_PROGRAM_ID) { inState }
|
||||
output(UNIVERSAL_PROGRAM_ID) { outState1 }
|
||||
output(UNIVERSAL_PROGRAM_ID) { outStateBad3 }
|
||||
input(UNIVERSAL_PROGRAM_ID, inState)
|
||||
output(UNIVERSAL_PROGRAM_ID, outState1)
|
||||
output(UNIVERSAL_PROGRAM_ID, outStateBad3)
|
||||
timeWindow(TEST_TX_TIME_1)
|
||||
|
||||
command(acmeCorp.owningKey) { UniversalContract.Commands.Action("execute") }
|
||||
command(acmeCorp.owningKey, UniversalContract.Commands.Action("execute"))
|
||||
this `fails with` "output states must match action result state"
|
||||
}
|
||||
}
|
||||
|
@ -134,16 +134,14 @@ class IRS {
|
||||
@Test
|
||||
fun issue() {
|
||||
transaction {
|
||||
output(UNIVERSAL_PROGRAM_ID) { stateInitial }
|
||||
output(UNIVERSAL_PROGRAM_ID, stateInitial)
|
||||
timeWindow(TEST_TX_TIME_1)
|
||||
|
||||
tweak {
|
||||
command(acmeCorp.owningKey) { UniversalContract.Commands.Issue() }
|
||||
command(acmeCorp.owningKey, UniversalContract.Commands.Issue())
|
||||
this `fails with` "the transaction is signed by all liable parties"
|
||||
}
|
||||
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Issue() }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Issue())
|
||||
this.verifies()
|
||||
}
|
||||
}
|
||||
@ -151,44 +149,38 @@ class IRS {
|
||||
@Test
|
||||
fun `first fixing`() {
|
||||
transaction {
|
||||
input(UNIVERSAL_PROGRAM_ID) { stateInitial }
|
||||
output(UNIVERSAL_PROGRAM_ID) { stateAfterFixingFirst }
|
||||
input(UNIVERSAL_PROGRAM_ID, stateInitial)
|
||||
output(UNIVERSAL_PROGRAM_ID, stateAfterFixingFirst)
|
||||
timeWindow(TEST_TX_TIME_1)
|
||||
|
||||
tweak {
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Action("some undefined name") }
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Action("some undefined name"))
|
||||
this `fails with` "action must be defined"
|
||||
}
|
||||
|
||||
tweak {
|
||||
// wrong source
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBORx", tradeDate, Tenor("3M")), 1.0.bd))) }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBORx", tradeDate, Tenor("3M")), 1.0.bd))))
|
||||
this `fails with` "relevant fixing must be included"
|
||||
}
|
||||
|
||||
tweak {
|
||||
// wrong date
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBOR", tradeDate.plusYears(1), Tenor("3M")), 1.0.bd))) }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBOR", tradeDate.plusYears(1), Tenor("3M")), 1.0.bd))))
|
||||
this `fails with` "relevant fixing must be included"
|
||||
}
|
||||
|
||||
tweak {
|
||||
// wrong tenor
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBOR", tradeDate, Tenor("9M")), 1.0.bd))) }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBOR", tradeDate, Tenor("9M")), 1.0.bd))))
|
||||
this `fails with` "relevant fixing must be included"
|
||||
}
|
||||
|
||||
tweak {
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBOR", tradeDate, Tenor("3M")), 1.5.bd))) }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBOR", tradeDate, Tenor("3M")), 1.5.bd))))
|
||||
this `fails with` "output state does not reflect fix command"
|
||||
}
|
||||
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBOR", tradeDate, Tenor("3M")), 1.0.bd))) }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Fix(listOf(net.corda.finance.contracts.Fix(FixOf("LIBOR", tradeDate, Tenor("3M")), 1.0.bd))))
|
||||
this.verifies()
|
||||
}
|
||||
}
|
||||
@ -196,19 +188,16 @@ class IRS {
|
||||
@Test
|
||||
fun `first execute`() {
|
||||
transaction {
|
||||
input(UNIVERSAL_PROGRAM_ID) { stateAfterFixingFirst }
|
||||
output(UNIVERSAL_PROGRAM_ID) { stateAfterExecutionFirst }
|
||||
output(UNIVERSAL_PROGRAM_ID) { statePaymentFirst }
|
||||
|
||||
input(UNIVERSAL_PROGRAM_ID, stateAfterFixingFirst)
|
||||
output(UNIVERSAL_PROGRAM_ID, stateAfterExecutionFirst)
|
||||
output(UNIVERSAL_PROGRAM_ID, statePaymentFirst)
|
||||
timeWindow(TEST_TX_TIME_1)
|
||||
|
||||
tweak {
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Action("some undefined name") }
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Action("some undefined name"))
|
||||
this `fails with` "action must be defined"
|
||||
}
|
||||
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Action("pay floating") }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Action("pay floating"))
|
||||
this.verifies()
|
||||
}
|
||||
}
|
||||
|
@ -145,16 +145,14 @@ class RollOutTests {
|
||||
@Test
|
||||
fun issue() {
|
||||
transaction {
|
||||
output(UNIVERSAL_PROGRAM_ID) { stateStart }
|
||||
output(UNIVERSAL_PROGRAM_ID, stateStart)
|
||||
timeWindow(TEST_TX_TIME_1)
|
||||
|
||||
tweak {
|
||||
command(acmeCorp.owningKey) { UniversalContract.Commands.Issue() }
|
||||
command(acmeCorp.owningKey, UniversalContract.Commands.Issue())
|
||||
this `fails with` "the transaction is signed by all liable parties"
|
||||
}
|
||||
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Issue() }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Issue())
|
||||
this.verifies()
|
||||
}
|
||||
}
|
||||
@ -162,18 +160,16 @@ class RollOutTests {
|
||||
@Test
|
||||
fun `execute`() {
|
||||
transaction {
|
||||
input(UNIVERSAL_PROGRAM_ID) { stateStart }
|
||||
output(UNIVERSAL_PROGRAM_ID) { stateStep1a }
|
||||
output(UNIVERSAL_PROGRAM_ID) { stateStep1b }
|
||||
input(UNIVERSAL_PROGRAM_ID, stateStart)
|
||||
output(UNIVERSAL_PROGRAM_ID, stateStep1a)
|
||||
output(UNIVERSAL_PROGRAM_ID, stateStep1b)
|
||||
timeWindow(TEST_TX_TIME_1)
|
||||
|
||||
/* tweak {
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Action("some undefined name") }
|
||||
this `fails with` "action must be defined"
|
||||
}*/
|
||||
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Action("transfer") }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Action("transfer"))
|
||||
this.verifies()
|
||||
}
|
||||
}
|
||||
|
@ -61,16 +61,14 @@ class Swaption {
|
||||
@Test
|
||||
fun issue() {
|
||||
transaction {
|
||||
output(UNIVERSAL_PROGRAM_ID) { stateInitial }
|
||||
output(UNIVERSAL_PROGRAM_ID, stateInitial)
|
||||
timeWindow(TEST_TX_TIME_1)
|
||||
|
||||
tweak {
|
||||
command(acmeCorp.owningKey) { UniversalContract.Commands.Issue() }
|
||||
command(acmeCorp.owningKey, UniversalContract.Commands.Issue())
|
||||
this `fails with` "the transaction is signed by all liable parties"
|
||||
}
|
||||
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Issue() }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Issue())
|
||||
this.verifies()
|
||||
}
|
||||
}
|
||||
|
@ -51,15 +51,12 @@ class ZeroCouponBond {
|
||||
@Test
|
||||
fun `issue - signature`() {
|
||||
transaction {
|
||||
output(UNIVERSAL_PROGRAM_ID) { inState }
|
||||
|
||||
output(UNIVERSAL_PROGRAM_ID, inState)
|
||||
tweak {
|
||||
command(acmeCorp.owningKey) { UniversalContract.Commands.Issue() }
|
||||
command(acmeCorp.owningKey, UniversalContract.Commands.Issue())
|
||||
this `fails with` "the transaction is signed by all liable parties"
|
||||
}
|
||||
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Issue() }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Issue())
|
||||
this.verifies()
|
||||
}
|
||||
}
|
||||
@ -67,17 +64,15 @@ class ZeroCouponBond {
|
||||
@Test
|
||||
fun `execute`() {
|
||||
transaction {
|
||||
input(UNIVERSAL_PROGRAM_ID) { inState }
|
||||
output(UNIVERSAL_PROGRAM_ID) { outState }
|
||||
input(UNIVERSAL_PROGRAM_ID, inState)
|
||||
output(UNIVERSAL_PROGRAM_ID, outState)
|
||||
timeWindow(TEST_TX_TIME_1)
|
||||
|
||||
tweak {
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Action("some undefined name") }
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Action("some undefined name"))
|
||||
this `fails with` "action must be defined"
|
||||
}
|
||||
|
||||
command(highStreetBank.owningKey) { UniversalContract.Commands.Action("execute") }
|
||||
|
||||
command(highStreetBank.owningKey, UniversalContract.Commands.Action("execute"))
|
||||
this.verifies()
|
||||
}
|
||||
}
|
||||
@ -85,11 +80,10 @@ class ZeroCouponBond {
|
||||
@Test
|
||||
fun `execute - not authorized`() {
|
||||
transaction {
|
||||
input(UNIVERSAL_PROGRAM_ID) { inState }
|
||||
output(UNIVERSAL_PROGRAM_ID) { outState }
|
||||
input(UNIVERSAL_PROGRAM_ID, inState)
|
||||
output(UNIVERSAL_PROGRAM_ID, outState)
|
||||
timeWindow(TEST_TX_TIME_1)
|
||||
|
||||
command(momAndPop.owningKey) { UniversalContract.Commands.Action("execute") }
|
||||
command(momAndPop.owningKey, UniversalContract.Commands.Action("execute"))
|
||||
this `fails with` "condition must be met"
|
||||
}
|
||||
}
|
||||
@ -97,11 +91,10 @@ class ZeroCouponBond {
|
||||
@Test
|
||||
fun `execute - outState mismatch`() {
|
||||
transaction {
|
||||
input(UNIVERSAL_PROGRAM_ID) { inState }
|
||||
output(UNIVERSAL_PROGRAM_ID) { outStateWrong }
|
||||
input(UNIVERSAL_PROGRAM_ID, inState)
|
||||
output(UNIVERSAL_PROGRAM_ID, outStateWrong)
|
||||
timeWindow(TEST_TX_TIME_1)
|
||||
|
||||
command(acmeCorp.owningKey) { UniversalContract.Commands.Action("execute") }
|
||||
command(acmeCorp.owningKey, UniversalContract.Commands.Action("execute"))
|
||||
this `fails with` "output state must match action result state"
|
||||
}
|
||||
}
|
||||
@ -109,29 +102,23 @@ class ZeroCouponBond {
|
||||
@Test
|
||||
fun move() {
|
||||
transaction {
|
||||
input(UNIVERSAL_PROGRAM_ID) { inState }
|
||||
|
||||
input(UNIVERSAL_PROGRAM_ID, inState)
|
||||
tweak {
|
||||
output(UNIVERSAL_PROGRAM_ID) { outStateMove }
|
||||
command(acmeCorp.owningKey) {
|
||||
UniversalContract.Commands.Move(acmeCorp, momAndPop)
|
||||
}
|
||||
output(UNIVERSAL_PROGRAM_ID, outStateMove)
|
||||
command(acmeCorp.owningKey,
|
||||
UniversalContract.Commands.Move(acmeCorp, momAndPop))
|
||||
this `fails with` "the transaction is signed by all liable parties"
|
||||
}
|
||||
|
||||
tweak {
|
||||
output(UNIVERSAL_PROGRAM_ID) { inState }
|
||||
command(acmeCorp.owningKey, momAndPop.owningKey, highStreetBank.owningKey) {
|
||||
UniversalContract.Commands.Move(acmeCorp, momAndPop)
|
||||
}
|
||||
output(UNIVERSAL_PROGRAM_ID, inState)
|
||||
command(listOf(acmeCorp.owningKey, momAndPop.owningKey, highStreetBank.owningKey),
|
||||
UniversalContract.Commands.Move(acmeCorp, momAndPop))
|
||||
this `fails with` "output state does not reflect move command"
|
||||
}
|
||||
|
||||
output(UNIVERSAL_PROGRAM_ID) { outStateMove }
|
||||
|
||||
command(acmeCorp.owningKey, momAndPop.owningKey, highStreetBank.owningKey) {
|
||||
UniversalContract.Commands.Move(acmeCorp, momAndPop)
|
||||
}
|
||||
output(UNIVERSAL_PROGRAM_ID, outStateMove)
|
||||
command(listOf(acmeCorp.owningKey, momAndPop.owningKey, highStreetBank.owningKey),
|
||||
UniversalContract.Commands.Move(acmeCorp, momAndPop))
|
||||
this.verifies()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user