2015-11-06 16:55:20 +00:00
|
|
|
package contracts
|
|
|
|
|
|
|
|
import core.*
|
|
|
|
import org.junit.Test
|
|
|
|
|
|
|
|
// TODO: Finish this off.
|
|
|
|
|
2015-11-08 11:30:02 +00:00
|
|
|
class ComedyPaperTests {
|
|
|
|
val PAPER_1 = ComedyPaper.State(
|
2015-11-06 16:55:20 +00:00
|
|
|
issuance = InstitutionReference(MEGA_CORP, OpaqueBytes.of(123)),
|
|
|
|
owner = DUMMY_PUBKEY_1,
|
|
|
|
faceValue = 1000.DOLLARS,
|
|
|
|
maturityDate = TEST_TX_TIME + 7.days
|
|
|
|
)
|
|
|
|
val PAPER_2 = PAPER_1.copy(owner = DUMMY_PUBKEY_2)
|
|
|
|
|
|
|
|
@Test
|
|
|
|
fun move() {
|
|
|
|
// One entity sells the paper to another (e.g. the issuer sells it to a first time buyer)
|
|
|
|
transaction {
|
|
|
|
input { PAPER_1 }
|
|
|
|
output { PAPER_2 }
|
|
|
|
|
2015-11-09 18:18:03 +00:00
|
|
|
this.rejects()
|
2015-11-06 16:55:20 +00:00
|
|
|
|
|
|
|
transaction {
|
2015-11-08 11:30:02 +00:00
|
|
|
arg(DUMMY_PUBKEY_2) { ComedyPaper.Commands.Move() }
|
2015-11-09 18:18:03 +00:00
|
|
|
this `fails requirement` "is signed by the owner"
|
2015-11-06 16:55:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
transaction {
|
2015-11-08 11:30:02 +00:00
|
|
|
arg(DUMMY_PUBKEY_1) { ComedyPaper.Commands.Move() }
|
2015-11-09 18:18:03 +00:00
|
|
|
this.accepts()
|
2015-11-06 16:55:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|