mirror of
https://github.com/corda/corda.git
synced 2025-01-14 16:59:52 +00:00
Fixed incorrect imports.
This commit is contained in:
parent
0a62fd8a7a
commit
cca532b5c0
@ -1,5 +1,8 @@
|
|||||||
package net.corda.finance.contracts
|
package com.r3.corda.enterprise.perftestcordapp.contracts
|
||||||
|
|
||||||
|
import com.r3.corda.enterprise.perftestcordapp.DOLLARS
|
||||||
|
import com.r3.corda.enterprise.perftestcordapp.`issued by`
|
||||||
|
import com.r3.corda.enterprise.perftestcordapp.contracts.asset.*
|
||||||
import net.corda.core.contracts.*
|
import net.corda.core.contracts.*
|
||||||
import net.corda.core.identity.AnonymousParty
|
import net.corda.core.identity.AnonymousParty
|
||||||
import net.corda.core.identity.Party
|
import net.corda.core.identity.Party
|
||||||
@ -9,14 +12,8 @@ import net.corda.core.transactions.SignedTransaction
|
|||||||
import net.corda.core.transactions.TransactionBuilder
|
import net.corda.core.transactions.TransactionBuilder
|
||||||
import net.corda.core.utilities.days
|
import net.corda.core.utilities.days
|
||||||
import net.corda.core.utilities.seconds
|
import net.corda.core.utilities.seconds
|
||||||
import net.corda.finance.DOLLARS
|
|
||||||
import net.corda.finance.`issued by`
|
|
||||||
import net.corda.finance.contracts.asset.*
|
|
||||||
import net.corda.testing.*
|
import net.corda.testing.*
|
||||||
import net.corda.testing.contracts.fillWithSomeTestCash
|
|
||||||
import net.corda.testing.node.MockServices
|
import net.corda.testing.node.MockServices
|
||||||
import net.corda.testing.node.MockServices.Companion.makeTestDatabaseAndMockServices
|
|
||||||
import org.junit.Ignore
|
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
@ -28,30 +25,17 @@ import kotlin.test.assertTrue
|
|||||||
|
|
||||||
// TODO: The generate functions aren't tested by these tests: add them.
|
// TODO: The generate functions aren't tested by these tests: add them.
|
||||||
|
|
||||||
interface ICommercialPaperTestTemplate {
|
interface CommercialPaperTestTemplate {
|
||||||
fun getPaper(): ICommercialPaperState
|
fun getPaper(): CommercialPaper.State
|
||||||
fun getIssueCommand(notary: Party): CommandData
|
fun getIssueCommand(notary: Party): CommandData
|
||||||
fun getRedeemCommand(notary: Party): CommandData
|
fun getRedeemCommand(notary: Party): CommandData
|
||||||
fun getMoveCommand(): CommandData
|
fun getMoveCommand(): CommandData
|
||||||
fun getContract(): ContractClassName
|
fun getContract(): ContractClassName
|
||||||
}
|
}
|
||||||
|
|
||||||
class JavaCommercialPaperTest : ICommercialPaperTestTemplate {
|
|
||||||
override fun getPaper(): ICommercialPaperState = JavaCommercialPaper.State(
|
|
||||||
MEGA_CORP.ref(123),
|
|
||||||
MEGA_CORP,
|
|
||||||
1000.DOLLARS `issued by` MEGA_CORP.ref(123),
|
|
||||||
TEST_TX_TIME + 7.days
|
|
||||||
)
|
|
||||||
|
|
||||||
override fun getIssueCommand(notary: Party): CommandData = JavaCommercialPaper.Commands.Issue()
|
class KotlinCommercialPaperTest : CommercialPaperTestTemplate {
|
||||||
override fun getRedeemCommand(notary: Party): CommandData = JavaCommercialPaper.Commands.Redeem()
|
override fun getPaper(): CommercialPaper.State = CommercialPaper.State(
|
||||||
override fun getMoveCommand(): CommandData = JavaCommercialPaper.Commands.Move()
|
|
||||||
override fun getContract() = JavaCommercialPaper.JCP_PROGRAM_ID
|
|
||||||
}
|
|
||||||
|
|
||||||
class KotlinCommercialPaperTest : ICommercialPaperTestTemplate {
|
|
||||||
override fun getPaper(): ICommercialPaperState = CommercialPaper.State(
|
|
||||||
issuance = MEGA_CORP.ref(123),
|
issuance = MEGA_CORP.ref(123),
|
||||||
owner = MEGA_CORP,
|
owner = MEGA_CORP,
|
||||||
faceValue = 1000.DOLLARS `issued by` MEGA_CORP.ref(123),
|
faceValue = 1000.DOLLARS `issued by` MEGA_CORP.ref(123),
|
||||||
@ -64,8 +48,8 @@ class KotlinCommercialPaperTest : ICommercialPaperTestTemplate {
|
|||||||
override fun getContract() = CommercialPaper.CP_PROGRAM_ID
|
override fun getContract() = CommercialPaper.CP_PROGRAM_ID
|
||||||
}
|
}
|
||||||
|
|
||||||
class KotlinCommercialPaperLegacyTest : ICommercialPaperTestTemplate {
|
class KotlinCommercialPaperLegacyTest : CommercialPaperTestTemplate {
|
||||||
override fun getPaper(): ICommercialPaperState = CommercialPaper.State(
|
override fun getPaper(): CommercialPaper.State = CommercialPaper.State(
|
||||||
issuance = MEGA_CORP.ref(123),
|
issuance = MEGA_CORP.ref(123),
|
||||||
owner = MEGA_CORP,
|
owner = MEGA_CORP,
|
||||||
faceValue = 1000.DOLLARS `issued by` MEGA_CORP.ref(123),
|
faceValue = 1000.DOLLARS `issued by` MEGA_CORP.ref(123),
|
||||||
@ -81,13 +65,12 @@ class KotlinCommercialPaperLegacyTest : ICommercialPaperTestTemplate {
|
|||||||
@RunWith(Parameterized::class)
|
@RunWith(Parameterized::class)
|
||||||
class CommercialPaperTestsGeneric {
|
class CommercialPaperTestsGeneric {
|
||||||
companion object {
|
companion object {
|
||||||
@Parameterized.Parameters
|
@Parameterized.Parameters @JvmStatic
|
||||||
@JvmStatic
|
fun data() = listOf(KotlinCommercialPaperTest(), KotlinCommercialPaperLegacyTest())
|
||||||
fun data() = listOf(JavaCommercialPaperTest(), KotlinCommercialPaperTest(), KotlinCommercialPaperLegacyTest())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameterized.Parameter
|
@Parameterized.Parameter
|
||||||
lateinit var thisTest: ICommercialPaperTestTemplate
|
lateinit var thisTest: CommercialPaperTestTemplate
|
||||||
@Rule
|
@Rule
|
||||||
@JvmField
|
@JvmField
|
||||||
val testSerialization = SerializationEnvironmentRule()
|
val testSerialization = SerializationEnvironmentRule()
|
||||||
@ -105,7 +88,7 @@ class CommercialPaperTestsGeneric {
|
|||||||
|
|
||||||
// Some CP is issued onto the ledger by MegaCorp.
|
// Some CP is issued onto the ledger by MegaCorp.
|
||||||
transaction("Issuance") {
|
transaction("Issuance") {
|
||||||
attachments(CP_PROGRAM_ID, JavaCommercialPaper.JCP_PROGRAM_ID)
|
attachments(CP_PROGRAM_ID, CommercialPaper.CP_PROGRAM_ID)
|
||||||
output(thisTest.getContract(), "paper") { thisTest.getPaper() }
|
output(thisTest.getContract(), "paper") { thisTest.getPaper() }
|
||||||
command(MEGA_CORP_PUBKEY) { thisTest.getIssueCommand(DUMMY_NOTARY) }
|
command(MEGA_CORP_PUBKEY) { thisTest.getIssueCommand(DUMMY_NOTARY) }
|
||||||
timeWindow(TEST_TX_TIME)
|
timeWindow(TEST_TX_TIME)
|
||||||
@ -115,11 +98,11 @@ class CommercialPaperTestsGeneric {
|
|||||||
// The CP is sold to alice for her $900, $100 less than the face value. At 10% interest after only 7 days,
|
// The CP is sold to alice for her $900, $100 less than the face value. At 10% interest after only 7 days,
|
||||||
// that sounds a bit too good to be true!
|
// that sounds a bit too good to be true!
|
||||||
transaction("Trade") {
|
transaction("Trade") {
|
||||||
attachments(Cash.PROGRAM_ID, JavaCommercialPaper.JCP_PROGRAM_ID)
|
attachments(Cash.PROGRAM_ID, CommercialPaper.CP_PROGRAM_ID)
|
||||||
input("paper")
|
input("paper")
|
||||||
input("alice's $900")
|
input("alice's $900")
|
||||||
output(Cash.PROGRAM_ID, "borrowed $900") { 900.DOLLARS.CASH issuedBy issuer ownedBy MEGA_CORP }
|
output(Cash.PROGRAM_ID, "borrowed $900") { 900.DOLLARS.CASH issuedBy issuer ownedBy MEGA_CORP }
|
||||||
output(thisTest.getContract(), "alice's paper") { "paper".output<ICommercialPaperState>().withOwner(ALICE) }
|
output(thisTest.getContract(), "alice's paper") { "paper".output<CommercialPaper.State>().withOwner(ALICE) }
|
||||||
command(ALICE_PUBKEY) { Cash.Commands.Move() }
|
command(ALICE_PUBKEY) { Cash.Commands.Move() }
|
||||||
command(MEGA_CORP_PUBKEY) { thisTest.getMoveCommand() }
|
command(MEGA_CORP_PUBKEY) { thisTest.getMoveCommand() }
|
||||||
this.verifies()
|
this.verifies()
|
||||||
@ -128,7 +111,7 @@ class CommercialPaperTestsGeneric {
|
|||||||
// Time passes, and Alice redeem's her CP for $1000, netting a $100 profit. MegaCorp has received $1200
|
// Time passes, and Alice redeem's her CP for $1000, netting a $100 profit. MegaCorp has received $1200
|
||||||
// as a single payment from somewhere and uses it to pay Alice off, keeping the remaining $200 as change.
|
// as a single payment from somewhere and uses it to pay Alice off, keeping the remaining $200 as change.
|
||||||
transaction("Redemption") {
|
transaction("Redemption") {
|
||||||
attachments(CP_PROGRAM_ID, JavaCommercialPaper.JCP_PROGRAM_ID)
|
attachments(CP_PROGRAM_ID, CommercialPaper.CP_PROGRAM_ID)
|
||||||
input("alice's paper")
|
input("alice's paper")
|
||||||
input("some profits")
|
input("some profits")
|
||||||
|
|
||||||
@ -155,7 +138,7 @@ class CommercialPaperTestsGeneric {
|
|||||||
timeWindow(TEST_TX_TIME + 8.days)
|
timeWindow(TEST_TX_TIME + 8.days)
|
||||||
|
|
||||||
tweak {
|
tweak {
|
||||||
output(thisTest.getContract()) { "paper".output<ICommercialPaperState>() }
|
output(thisTest.getContract()) { "paper".output<CommercialPaper.State>() }
|
||||||
this `fails with` "must be destroyed"
|
this `fails with` "must be destroyed"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,7 +151,7 @@ class CommercialPaperTestsGeneric {
|
|||||||
fun `key mismatch at issue`() {
|
fun `key mismatch at issue`() {
|
||||||
transaction {
|
transaction {
|
||||||
attachment(CP_PROGRAM_ID)
|
attachment(CP_PROGRAM_ID)
|
||||||
attachment(JavaCommercialPaper.JCP_PROGRAM_ID)
|
attachment(CP_PROGRAM_ID)
|
||||||
output(thisTest.getContract()) { thisTest.getPaper() }
|
output(thisTest.getContract()) { thisTest.getPaper() }
|
||||||
command(MINI_CORP_PUBKEY) { thisTest.getIssueCommand(DUMMY_NOTARY) }
|
command(MINI_CORP_PUBKEY) { thisTest.getIssueCommand(DUMMY_NOTARY) }
|
||||||
timeWindow(TEST_TX_TIME)
|
timeWindow(TEST_TX_TIME)
|
||||||
@ -180,7 +163,7 @@ class CommercialPaperTestsGeneric {
|
|||||||
fun `face value is not zero`() {
|
fun `face value is not zero`() {
|
||||||
transaction {
|
transaction {
|
||||||
attachment(CP_PROGRAM_ID)
|
attachment(CP_PROGRAM_ID)
|
||||||
attachment(JavaCommercialPaper.JCP_PROGRAM_ID)
|
attachment(CP_PROGRAM_ID)
|
||||||
output(thisTest.getContract()) { thisTest.getPaper().withFaceValue(0.DOLLARS `issued by` issuer) }
|
output(thisTest.getContract()) { thisTest.getPaper().withFaceValue(0.DOLLARS `issued by` issuer) }
|
||||||
command(MEGA_CORP_PUBKEY) { thisTest.getIssueCommand(DUMMY_NOTARY) }
|
command(MEGA_CORP_PUBKEY) { thisTest.getIssueCommand(DUMMY_NOTARY) }
|
||||||
timeWindow(TEST_TX_TIME)
|
timeWindow(TEST_TX_TIME)
|
||||||
@ -192,7 +175,7 @@ class CommercialPaperTestsGeneric {
|
|||||||
fun `maturity date not in the past`() {
|
fun `maturity date not in the past`() {
|
||||||
transaction {
|
transaction {
|
||||||
attachment(CP_PROGRAM_ID)
|
attachment(CP_PROGRAM_ID)
|
||||||
attachment(JavaCommercialPaper.JCP_PROGRAM_ID)
|
attachment(CP_PROGRAM_ID)
|
||||||
output(thisTest.getContract()) { thisTest.getPaper().withMaturityDate(TEST_TX_TIME - 10.days) }
|
output(thisTest.getContract()) { thisTest.getPaper().withMaturityDate(TEST_TX_TIME - 10.days) }
|
||||||
command(MEGA_CORP_PUBKEY) { thisTest.getIssueCommand(DUMMY_NOTARY) }
|
command(MEGA_CORP_PUBKEY) { thisTest.getIssueCommand(DUMMY_NOTARY) }
|
||||||
timeWindow(TEST_TX_TIME)
|
timeWindow(TEST_TX_TIME)
|
||||||
@ -204,7 +187,7 @@ class CommercialPaperTestsGeneric {
|
|||||||
fun `issue cannot replace an existing state`() {
|
fun `issue cannot replace an existing state`() {
|
||||||
transaction {
|
transaction {
|
||||||
attachment(CP_PROGRAM_ID)
|
attachment(CP_PROGRAM_ID)
|
||||||
attachment(JavaCommercialPaper.JCP_PROGRAM_ID)
|
attachment(CP_PROGRAM_ID)
|
||||||
input(thisTest.getContract(), thisTest.getPaper())
|
input(thisTest.getContract(), thisTest.getPaper())
|
||||||
output(thisTest.getContract()) { thisTest.getPaper() }
|
output(thisTest.getContract()) { thisTest.getPaper() }
|
||||||
command(MEGA_CORP_PUBKEY) { thisTest.getIssueCommand(DUMMY_NOTARY) }
|
command(MEGA_CORP_PUBKEY) { thisTest.getIssueCommand(DUMMY_NOTARY) }
|
||||||
@ -232,9 +215,8 @@ class CommercialPaperTestsGeneric {
|
|||||||
private lateinit var moveTX: SignedTransaction
|
private lateinit var moveTX: SignedTransaction
|
||||||
|
|
||||||
// @Test
|
// @Test
|
||||||
@Ignore
|
|
||||||
fun `issue move and then redeem`() = withTestSerialization{
|
fun `issue move and then redeem`() = withTestSerialization{
|
||||||
val aliceDatabaseAndServices = makeTestDatabaseAndMockServices(keys = listOf(ALICE_KEY))
|
val aliceDatabaseAndServices = MockServices.makeTestDatabaseAndMockServices(keys = listOf(ALICE_KEY))
|
||||||
val databaseAlice = aliceDatabaseAndServices.first
|
val databaseAlice = aliceDatabaseAndServices.first
|
||||||
aliceServices = aliceDatabaseAndServices.second
|
aliceServices = aliceDatabaseAndServices.second
|
||||||
aliceVaultService = aliceServices.vaultService
|
aliceVaultService = aliceServices.vaultService
|
||||||
@ -244,7 +226,7 @@ class CommercialPaperTestsGeneric {
|
|||||||
aliceVaultService = aliceServices.vaultService
|
aliceVaultService = aliceServices.vaultService
|
||||||
}
|
}
|
||||||
|
|
||||||
val bigCorpDatabaseAndServices = makeTestDatabaseAndMockServices(keys = listOf(BIG_CORP_KEY))
|
val bigCorpDatabaseAndServices = MockServices.makeTestDatabaseAndMockServices(keys = listOf(BIG_CORP_KEY))
|
||||||
val databaseBigCorp = bigCorpDatabaseAndServices.first
|
val databaseBigCorp = bigCorpDatabaseAndServices.first
|
||||||
bigCorpServices = bigCorpDatabaseAndServices.second
|
bigCorpServices = bigCorpDatabaseAndServices.second
|
||||||
bigCorpVaultService = bigCorpServices.vaultService
|
bigCorpVaultService = bigCorpServices.vaultService
|
||||||
|
Loading…
Reference in New Issue
Block a user