mirror of
https://github.com/corda/corda.git
synced 2025-01-30 16:14:39 +00:00
Fix bugs in the trade finance contracts and tests, where txns weren't being properly verified and thus the lack of timestamping wasn't detected.
This commit is contained in:
parent
1c3379f508
commit
301d787e45
@ -3,7 +3,10 @@ package com.r3corda.contracts
|
|||||||
import com.r3corda.core.contracts.*
|
import com.r3corda.core.contracts.*
|
||||||
import com.r3corda.core.crypto.Party
|
import com.r3corda.core.crypto.Party
|
||||||
import com.r3corda.core.crypto.SecureHash
|
import com.r3corda.core.crypto.SecureHash
|
||||||
|
import com.r3corda.core.days
|
||||||
|
import com.r3corda.core.testing.DUMMY_NOTARY
|
||||||
import java.security.PublicKey
|
import java.security.PublicKey
|
||||||
|
import java.time.Instant
|
||||||
import java.time.LocalDate
|
import java.time.LocalDate
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -109,9 +112,11 @@ class BillOfLadingAgreement : Contract {
|
|||||||
/**
|
/**
|
||||||
* Returns a transaction that issues a Bill of Lading Agreement
|
* Returns a transaction that issues a Bill of Lading Agreement
|
||||||
*/
|
*/
|
||||||
fun generateIssue(owner: PublicKey, beneficiary: Party, props: BillOfLadingProperties, notary: Party? = null): TransactionBuilder {
|
fun generateIssue(owner: PublicKey, beneficiary: Party, props: BillOfLadingProperties, notary: Party = DUMMY_NOTARY): TransactionBuilder {
|
||||||
val state = State(owner, beneficiary, props)
|
val state = State(owner, beneficiary, props)
|
||||||
return TransactionType.General.Builder(notary = notary).withItems(state, Command(Commands.IssueBL(), props.carrierOwner.owningKey))
|
val builder = TransactionType.General.Builder(notary = notary)
|
||||||
|
builder.setTime(Instant.now(), notary, 1.days)
|
||||||
|
return builder.withItems(state, Command(Commands.IssueBL(), props.carrierOwner.owningKey))
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,7 +4,10 @@ import com.r3corda.contracts.asset.sumCashBy
|
|||||||
import com.r3corda.core.contracts.*
|
import com.r3corda.core.contracts.*
|
||||||
import com.r3corda.core.crypto.Party
|
import com.r3corda.core.crypto.Party
|
||||||
import com.r3corda.core.crypto.SecureHash
|
import com.r3corda.core.crypto.SecureHash
|
||||||
|
import com.r3corda.core.days
|
||||||
|
import com.r3corda.core.testing.DUMMY_NOTARY
|
||||||
import java.security.PublicKey
|
import java.security.PublicKey
|
||||||
|
import java.time.Instant
|
||||||
import java.time.LocalDate
|
import java.time.LocalDate
|
||||||
import java.time.Period
|
import java.time.Period
|
||||||
import java.time.ZoneOffset
|
import java.time.ZoneOffset
|
||||||
@ -142,7 +145,9 @@ class LOC : Contract {
|
|||||||
|
|
||||||
fun generateIssue(beneficiaryPaid: Boolean, issued: Boolean, terminated: Boolean, props: LOCProperties, notary: Party): TransactionBuilder {
|
fun generateIssue(beneficiaryPaid: Boolean, issued: Boolean, terminated: Boolean, props: LOCProperties, notary: Party): TransactionBuilder {
|
||||||
val state = State(beneficiaryPaid, issued, terminated, props)
|
val state = State(beneficiaryPaid, issued, terminated, props)
|
||||||
return TransactionType.General.Builder(notary = notary).withItems(state, Command(Commands.Issuance(), props.issuingbank.owningKey))
|
val builder = TransactionType.General.Builder(notary = notary)
|
||||||
|
builder.setTime(Instant.now(), notary, 1.days)
|
||||||
|
return builder.withItems(state, Command(Commands.Issuance(), props.issuingbank.owningKey))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,8 +48,9 @@ class BillOfLadingAgreementTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun issueGenerationMethod() {
|
fun issueGenerationMethod() {
|
||||||
val ptx = BillOfLadingAgreement().generateIssue(Bill.owner, Bill.beneficiary,Bill.props, notary = DUMMY_NOTARY).apply {
|
val ptx = BillOfLadingAgreement().generateIssue(Bill.owner, Bill.beneficiary,Bill.props).apply {
|
||||||
signWith(ALICE_KEY)
|
signWith(ALICE_KEY)
|
||||||
|
signWith(DUMMY_NOTARY_KEY)
|
||||||
}
|
}
|
||||||
val stx = ptx.toSignedTransaction()
|
val stx = ptx.toSignedTransaction()
|
||||||
stx.verifyToLedgerTransaction(MOCK_IDENTITY_SERVICE,attachments)
|
stx.verifyToLedgerTransaction(MOCK_IDENTITY_SERVICE,attachments)
|
||||||
|
@ -120,6 +120,7 @@ class LOCTests {
|
|||||||
fun issueSignedByBank() {
|
fun issueSignedByBank() {
|
||||||
val ptx = LOC().generateIssue(LOCstate.beneficiaryPaid, LOCstate.issued, LOCstate.terminated, LOCstate.props, DUMMY_NOTARY).apply {
|
val ptx = LOC().generateIssue(LOCstate.beneficiaryPaid, LOCstate.issued, LOCstate.terminated, LOCstate.props, DUMMY_NOTARY).apply {
|
||||||
signWith(MEGA_CORP_KEY)
|
signWith(MEGA_CORP_KEY)
|
||||||
|
signWith(DUMMY_NOTARY_KEY)
|
||||||
}
|
}
|
||||||
val stx = ptx.toSignedTransaction()
|
val stx = ptx.toSignedTransaction()
|
||||||
stx.verify()
|
stx.verify()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user