mirror of
https://github.com/corda/corda.git
synced 2025-01-13 16:30:25 +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.identity.AnonymousParty
|
||||
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.utilities.days
|
||||
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.contracts.fillWithSomeTestCash
|
||||
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.Test
|
||||
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.
|
||||
|
||||
interface ICommercialPaperTestTemplate {
|
||||
fun getPaper(): ICommercialPaperState
|
||||
interface CommercialPaperTestTemplate {
|
||||
fun getPaper(): CommercialPaper.State
|
||||
fun getIssueCommand(notary: Party): CommandData
|
||||
fun getRedeemCommand(notary: Party): CommandData
|
||||
fun getMoveCommand(): CommandData
|
||||
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()
|
||||
override fun getRedeemCommand(notary: Party): CommandData = JavaCommercialPaper.Commands.Redeem()
|
||||
override fun getMoveCommand(): CommandData = JavaCommercialPaper.Commands.Move()
|
||||
override fun getContract() = JavaCommercialPaper.JCP_PROGRAM_ID
|
||||
}
|
||||
|
||||
class KotlinCommercialPaperTest : ICommercialPaperTestTemplate {
|
||||
override fun getPaper(): ICommercialPaperState = CommercialPaper.State(
|
||||
class KotlinCommercialPaperTest : CommercialPaperTestTemplate {
|
||||
override fun getPaper(): CommercialPaper.State = CommercialPaper.State(
|
||||
issuance = MEGA_CORP.ref(123),
|
||||
owner = MEGA_CORP,
|
||||
faceValue = 1000.DOLLARS `issued by` MEGA_CORP.ref(123),
|
||||
@ -64,8 +48,8 @@ class KotlinCommercialPaperTest : ICommercialPaperTestTemplate {
|
||||
override fun getContract() = CommercialPaper.CP_PROGRAM_ID
|
||||
}
|
||||
|
||||
class KotlinCommercialPaperLegacyTest : ICommercialPaperTestTemplate {
|
||||
override fun getPaper(): ICommercialPaperState = CommercialPaper.State(
|
||||
class KotlinCommercialPaperLegacyTest : CommercialPaperTestTemplate {
|
||||
override fun getPaper(): CommercialPaper.State = CommercialPaper.State(
|
||||
issuance = MEGA_CORP.ref(123),
|
||||
owner = MEGA_CORP,
|
||||
faceValue = 1000.DOLLARS `issued by` MEGA_CORP.ref(123),
|
||||
@ -81,13 +65,12 @@ class KotlinCommercialPaperLegacyTest : ICommercialPaperTestTemplate {
|
||||
@RunWith(Parameterized::class)
|
||||
class CommercialPaperTestsGeneric {
|
||||
companion object {
|
||||
@Parameterized.Parameters
|
||||
@JvmStatic
|
||||
fun data() = listOf(JavaCommercialPaperTest(), KotlinCommercialPaperTest(), KotlinCommercialPaperLegacyTest())
|
||||
@Parameterized.Parameters @JvmStatic
|
||||
fun data() = listOf(KotlinCommercialPaperTest(), KotlinCommercialPaperLegacyTest())
|
||||
}
|
||||
|
||||
@Parameterized.Parameter
|
||||
lateinit var thisTest: ICommercialPaperTestTemplate
|
||||
lateinit var thisTest: CommercialPaperTestTemplate
|
||||
@Rule
|
||||
@JvmField
|
||||
val testSerialization = SerializationEnvironmentRule()
|
||||
@ -105,7 +88,7 @@ class CommercialPaperTestsGeneric {
|
||||
|
||||
// Some CP is issued onto the ledger by MegaCorp.
|
||||
transaction("Issuance") {
|
||||
attachments(CP_PROGRAM_ID, JavaCommercialPaper.JCP_PROGRAM_ID)
|
||||
attachments(CP_PROGRAM_ID, CommercialPaper.CP_PROGRAM_ID)
|
||||
output(thisTest.getContract(), "paper") { thisTest.getPaper() }
|
||||
command(MEGA_CORP_PUBKEY) { thisTest.getIssueCommand(DUMMY_NOTARY) }
|
||||
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,
|
||||
// that sounds a bit too good to be true!
|
||||
transaction("Trade") {
|
||||
attachments(Cash.PROGRAM_ID, JavaCommercialPaper.JCP_PROGRAM_ID)
|
||||
attachments(Cash.PROGRAM_ID, CommercialPaper.CP_PROGRAM_ID)
|
||||
input("paper")
|
||||
input("alice's $900")
|
||||
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(MEGA_CORP_PUBKEY) { thisTest.getMoveCommand() }
|
||||
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
|
||||
// as a single payment from somewhere and uses it to pay Alice off, keeping the remaining $200 as change.
|
||||
transaction("Redemption") {
|
||||
attachments(CP_PROGRAM_ID, JavaCommercialPaper.JCP_PROGRAM_ID)
|
||||
attachments(CP_PROGRAM_ID, CommercialPaper.CP_PROGRAM_ID)
|
||||
input("alice's paper")
|
||||
input("some profits")
|
||||
|
||||
@ -155,7 +138,7 @@ class CommercialPaperTestsGeneric {
|
||||
timeWindow(TEST_TX_TIME + 8.days)
|
||||
|
||||
tweak {
|
||||
output(thisTest.getContract()) { "paper".output<ICommercialPaperState>() }
|
||||
output(thisTest.getContract()) { "paper".output<CommercialPaper.State>() }
|
||||
this `fails with` "must be destroyed"
|
||||
}
|
||||
|
||||
@ -168,7 +151,7 @@ class CommercialPaperTestsGeneric {
|
||||
fun `key mismatch at issue`() {
|
||||
transaction {
|
||||
attachment(CP_PROGRAM_ID)
|
||||
attachment(JavaCommercialPaper.JCP_PROGRAM_ID)
|
||||
attachment(CP_PROGRAM_ID)
|
||||
output(thisTest.getContract()) { thisTest.getPaper() }
|
||||
command(MINI_CORP_PUBKEY) { thisTest.getIssueCommand(DUMMY_NOTARY) }
|
||||
timeWindow(TEST_TX_TIME)
|
||||
@ -180,7 +163,7 @@ class CommercialPaperTestsGeneric {
|
||||
fun `face value is not zero`() {
|
||||
transaction {
|
||||
attachment(CP_PROGRAM_ID)
|
||||
attachment(JavaCommercialPaper.JCP_PROGRAM_ID)
|
||||
attachment(CP_PROGRAM_ID)
|
||||
output(thisTest.getContract()) { thisTest.getPaper().withFaceValue(0.DOLLARS `issued by` issuer) }
|
||||
command(MEGA_CORP_PUBKEY) { thisTest.getIssueCommand(DUMMY_NOTARY) }
|
||||
timeWindow(TEST_TX_TIME)
|
||||
@ -192,7 +175,7 @@ class CommercialPaperTestsGeneric {
|
||||
fun `maturity date not in the past`() {
|
||||
transaction {
|
||||
attachment(CP_PROGRAM_ID)
|
||||
attachment(JavaCommercialPaper.JCP_PROGRAM_ID)
|
||||
attachment(CP_PROGRAM_ID)
|
||||
output(thisTest.getContract()) { thisTest.getPaper().withMaturityDate(TEST_TX_TIME - 10.days) }
|
||||
command(MEGA_CORP_PUBKEY) { thisTest.getIssueCommand(DUMMY_NOTARY) }
|
||||
timeWindow(TEST_TX_TIME)
|
||||
@ -204,7 +187,7 @@ class CommercialPaperTestsGeneric {
|
||||
fun `issue cannot replace an existing state`() {
|
||||
transaction {
|
||||
attachment(CP_PROGRAM_ID)
|
||||
attachment(JavaCommercialPaper.JCP_PROGRAM_ID)
|
||||
attachment(CP_PROGRAM_ID)
|
||||
input(thisTest.getContract(), thisTest.getPaper())
|
||||
output(thisTest.getContract()) { thisTest.getPaper() }
|
||||
command(MEGA_CORP_PUBKEY) { thisTest.getIssueCommand(DUMMY_NOTARY) }
|
||||
@ -232,9 +215,8 @@ class CommercialPaperTestsGeneric {
|
||||
private lateinit var moveTX: SignedTransaction
|
||||
|
||||
// @Test
|
||||
@Ignore
|
||||
fun `issue move and then redeem`() = withTestSerialization {
|
||||
val aliceDatabaseAndServices = makeTestDatabaseAndMockServices(keys = listOf(ALICE_KEY))
|
||||
fun `issue move and then redeem`() = withTestSerialization{
|
||||
val aliceDatabaseAndServices = MockServices.makeTestDatabaseAndMockServices(keys = listOf(ALICE_KEY))
|
||||
val databaseAlice = aliceDatabaseAndServices.first
|
||||
aliceServices = aliceDatabaseAndServices.second
|
||||
aliceVaultService = aliceServices.vaultService
|
||||
@ -244,7 +226,7 @@ class CommercialPaperTestsGeneric {
|
||||
aliceVaultService = aliceServices.vaultService
|
||||
}
|
||||
|
||||
val bigCorpDatabaseAndServices = makeTestDatabaseAndMockServices(keys = listOf(BIG_CORP_KEY))
|
||||
val bigCorpDatabaseAndServices = MockServices.makeTestDatabaseAndMockServices(keys = listOf(BIG_CORP_KEY))
|
||||
val databaseBigCorp = bigCorpDatabaseAndServices.first
|
||||
bigCorpServices = bigCorpDatabaseAndServices.second
|
||||
bigCorpVaultService = bigCorpServices.vaultService
|
||||
|
Loading…
Reference in New Issue
Block a user