mirror of
https://github.com/corda/corda.git
synced 2025-02-22 10:10:59 +00:00
test dsl: LastLineShouldTestForVerifiesOrFails->EnforceVerifyOrFail
This commit is contained in:
parent
e31b769fef
commit
f177b1ffaa
@ -97,7 +97,7 @@ class CommercialPaperTestsGeneric {
|
|||||||
input("alice's paper")
|
input("alice's paper")
|
||||||
input("some profits")
|
input("some profits")
|
||||||
|
|
||||||
fun TransactionDSL<LastLineShouldTestForVerifiesOrFails, TransactionDSLInterpreter<LastLineShouldTestForVerifiesOrFails>>.outputs(aliceGetsBack: Amount<Issued<Currency>>) {
|
fun TransactionDSL<EnforceVerifyOrFail, TransactionDSLInterpreter<EnforceVerifyOrFail>>.outputs(aliceGetsBack: Amount<Issued<Currency>>) {
|
||||||
output("Alice's profit") { aliceGetsBack.STATE `owned by` ALICE_PUBKEY }
|
output("Alice's profit") { aliceGetsBack.STATE `owned by` ALICE_PUBKEY }
|
||||||
output("Change") { (someProfits - aliceGetsBack).STATE `owned by` MEGA_CORP_PUBKEY }
|
output("Change") { (someProfits - aliceGetsBack).STATE `owned by` MEGA_CORP_PUBKEY }
|
||||||
}
|
}
|
||||||
|
@ -360,7 +360,7 @@ class IRSTests {
|
|||||||
/**
|
/**
|
||||||
* Generates a typical transactional history for an IRS.
|
* Generates a typical transactional history for an IRS.
|
||||||
*/
|
*/
|
||||||
fun trade(): LedgerDSL<LastLineShouldTestForVerifiesOrFails, TestTransactionDSLInterpreter, TestLedgerDSLInterpreter> {
|
fun trade(): LedgerDSL<EnforceVerifyOrFail, TestTransactionDSLInterpreter, TestLedgerDSLInterpreter> {
|
||||||
|
|
||||||
val ld = LocalDate.of(2016, 3, 8)
|
val ld = LocalDate.of(2016, 3, 8)
|
||||||
val bd = BigDecimal("0.0063518")
|
val bd = BigDecimal("0.0063518")
|
||||||
@ -555,8 +555,6 @@ class IRSTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `various fixing tests`() {
|
fun `various fixing tests`() {
|
||||||
ledger {
|
|
||||||
|
|
||||||
val ld = LocalDate.of(2016, 3, 8)
|
val ld = LocalDate.of(2016, 3, 8)
|
||||||
val bd = BigDecimal("0.0063518")
|
val bd = BigDecimal("0.0063518")
|
||||||
|
|
||||||
@ -647,7 +645,6 @@ class IRSTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -656,7 +653,7 @@ class IRSTests {
|
|||||||
* result and the grouping won't work either.
|
* result and the grouping won't work either.
|
||||||
* In reality, the only fields that should be in common will be the next fixing date and the reference rate.
|
* In reality, the only fields that should be in common will be the next fixing date and the reference rate.
|
||||||
*/
|
*/
|
||||||
fun tradegroups(): LedgerDSL<LastLineShouldTestForVerifiesOrFails, TestTransactionDSLInterpreter, TestLedgerDSLInterpreter> {
|
fun tradegroups(): LedgerDSL<EnforceVerifyOrFail, TestTransactionDSLInterpreter, TestLedgerDSLInterpreter> {
|
||||||
val ld1 = LocalDate.of(2016, 3, 8)
|
val ld1 = LocalDate.of(2016, 3, 8)
|
||||||
val bd1 = BigDecimal("0.0063518")
|
val bd1 = BigDecimal("0.0063518")
|
||||||
|
|
||||||
|
@ -29,7 +29,6 @@ class CashTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun trivial() {
|
fun trivial() {
|
||||||
ledger {
|
|
||||||
transaction {
|
transaction {
|
||||||
input { inState }
|
input { inState }
|
||||||
this `fails with` "the amounts balance"
|
this `fails with` "the amounts balance"
|
||||||
@ -62,11 +61,9 @@ class CashTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun issueMoney() {
|
fun issueMoney() {
|
||||||
ledger {
|
|
||||||
// Check we can't "move" money into existence.
|
// Check we can't "move" money into existence.
|
||||||
transaction {
|
transaction {
|
||||||
input { DummyState() }
|
input { DummyState() }
|
||||||
@ -170,7 +167,6 @@ class CashTests {
|
|||||||
this.verifies()
|
this.verifies()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that the issuance builder rejects building into a transaction with existing
|
* Test that the issuance builder rejects building into a transaction with existing
|
||||||
@ -193,7 +189,6 @@ class CashTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testMergeSplit() {
|
fun testMergeSplit() {
|
||||||
ledger {
|
|
||||||
// Splitting value works.
|
// Splitting value works.
|
||||||
transaction {
|
transaction {
|
||||||
command(DUMMY_PUBKEY_1) { Cash.Commands.Move() }
|
command(DUMMY_PUBKEY_1) { Cash.Commands.Move() }
|
||||||
@ -218,11 +213,9 @@ class CashTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun zeroSizedValues() {
|
fun zeroSizedValues() {
|
||||||
ledger {
|
|
||||||
transaction {
|
transaction {
|
||||||
input { inState }
|
input { inState }
|
||||||
input { inState.copy(amount = 0.DOLLARS `issued by` defaultIssuer) }
|
input { inState.copy(amount = 0.DOLLARS `issued by` defaultIssuer) }
|
||||||
@ -235,11 +228,9 @@ class CashTests {
|
|||||||
this `fails with` "zero sized outputs"
|
this `fails with` "zero sized outputs"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun trivialMismatches() {
|
fun trivialMismatches() {
|
||||||
ledger {
|
|
||||||
// Can't change issuer.
|
// Can't change issuer.
|
||||||
transaction {
|
transaction {
|
||||||
input { inState }
|
input { inState }
|
||||||
@ -287,11 +278,9 @@ class CashTests {
|
|||||||
this `fails with` "for deposit [01]"
|
this `fails with` "for deposit [01]"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun exitLedger() {
|
fun exitLedger() {
|
||||||
ledger {
|
|
||||||
// Single input/output straightforward case.
|
// Single input/output straightforward case.
|
||||||
transaction {
|
transaction {
|
||||||
input { inState }
|
input { inState }
|
||||||
@ -332,11 +321,9 @@ class CashTests {
|
|||||||
this.verifies()
|
this.verifies()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun multiIssuer() {
|
fun multiIssuer() {
|
||||||
ledger {
|
|
||||||
transaction {
|
transaction {
|
||||||
// Gather 2000 dollars from two different issuers.
|
// Gather 2000 dollars from two different issuers.
|
||||||
input { inState }
|
input { inState }
|
||||||
@ -361,11 +348,9 @@ class CashTests {
|
|||||||
this.verifies()
|
this.verifies()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun multiCurrency() {
|
fun multiCurrency() {
|
||||||
ledger {
|
|
||||||
// Check we can do an atomic currency trade tx.
|
// Check we can do an atomic currency trade tx.
|
||||||
transaction {
|
transaction {
|
||||||
val pounds = Cash.State(658.POUNDS `issued by` MINI_CORP.ref(3, 4, 5), DUMMY_PUBKEY_2)
|
val pounds = Cash.State(658.POUNDS `issued by` MINI_CORP.ref(3, 4, 5), DUMMY_PUBKEY_2)
|
||||||
@ -378,7 +363,6 @@ class CashTests {
|
|||||||
this.verifies()
|
this.verifies()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -35,7 +35,7 @@ class ObligationTests {
|
|||||||
val outState = inState.copy(beneficiary = DUMMY_PUBKEY_2)
|
val outState = inState.copy(beneficiary = DUMMY_PUBKEY_2)
|
||||||
|
|
||||||
private fun obligationTestRoots(
|
private fun obligationTestRoots(
|
||||||
group: LedgerDSL<LastLineShouldTestForVerifiesOrFails, TestTransactionDSLInterpreter, TestLedgerDSLInterpreter>
|
group: LedgerDSL<EnforceVerifyOrFail, TestTransactionDSLInterpreter, TestLedgerDSLInterpreter>
|
||||||
) = group.apply {
|
) = group.apply {
|
||||||
unverifiedTransaction {
|
unverifiedTransaction {
|
||||||
output("Alice's $1,000,000 obligation to Bob", oneMillionDollars.OBLIGATION `between` Pair(ALICE, BOB_PUBKEY))
|
output("Alice's $1,000,000 obligation to Bob", oneMillionDollars.OBLIGATION `between` Pair(ALICE, BOB_PUBKEY))
|
||||||
|
@ -17,15 +17,15 @@ import java.util.*
|
|||||||
fun transaction(
|
fun transaction(
|
||||||
transactionLabel: String? = null,
|
transactionLabel: String? = null,
|
||||||
dsl: TransactionDSL<
|
dsl: TransactionDSL<
|
||||||
LastLineShouldTestForVerifiesOrFails,
|
EnforceVerifyOrFail,
|
||||||
TransactionDSLInterpreter<LastLineShouldTestForVerifiesOrFails>
|
TransactionDSLInterpreter<EnforceVerifyOrFail>
|
||||||
>.() -> LastLineShouldTestForVerifiesOrFails
|
>.() -> EnforceVerifyOrFail
|
||||||
) = JavaTestHelpers.transaction(transactionLabel, dsl)
|
) = JavaTestHelpers.transaction(transactionLabel, dsl)
|
||||||
|
|
||||||
fun ledger(
|
fun ledger(
|
||||||
identityService: IdentityService = MOCK_IDENTITY_SERVICE,
|
identityService: IdentityService = MOCK_IDENTITY_SERVICE,
|
||||||
storageService: StorageService = MockStorageService(),
|
storageService: StorageService = MockStorageService(),
|
||||||
dsl: LedgerDSL<LastLineShouldTestForVerifiesOrFails, TestTransactionDSLInterpreter, TestLedgerDSLInterpreter>.() -> Unit
|
dsl: LedgerDSL<EnforceVerifyOrFail, TestTransactionDSLInterpreter, TestLedgerDSLInterpreter>.() -> Unit
|
||||||
) = JavaTestHelpers.ledger(identityService, storageService, dsl)
|
) = JavaTestHelpers.ledger(identityService, storageService, dsl)
|
||||||
|
|
||||||
@Deprecated(
|
@Deprecated(
|
||||||
@ -33,8 +33,8 @@ fun ledger(
|
|||||||
replaceWith = ReplaceWith("tweak"),
|
replaceWith = ReplaceWith("tweak"),
|
||||||
level = DeprecationLevel.ERROR)
|
level = DeprecationLevel.ERROR)
|
||||||
@Suppress("UNUSED_PARAMETER")
|
@Suppress("UNUSED_PARAMETER")
|
||||||
fun TransactionDSLInterpreter<LastLineShouldTestForVerifiesOrFails>.ledger(
|
fun TransactionDSLInterpreter<EnforceVerifyOrFail>.ledger(
|
||||||
dsl: LedgerDSL<LastLineShouldTestForVerifiesOrFails, TestTransactionDSLInterpreter, TestLedgerDSLInterpreter>.() -> Unit) {
|
dsl: LedgerDSL<EnforceVerifyOrFail, TestTransactionDSLInterpreter, TestLedgerDSLInterpreter>.() -> Unit) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated(
|
@Deprecated(
|
||||||
@ -42,11 +42,11 @@ fun TransactionDSLInterpreter<LastLineShouldTestForVerifiesOrFails>.ledger(
|
|||||||
replaceWith = ReplaceWith("tweak"),
|
replaceWith = ReplaceWith("tweak"),
|
||||||
level = DeprecationLevel.ERROR)
|
level = DeprecationLevel.ERROR)
|
||||||
@Suppress("UNUSED_PARAMETER")
|
@Suppress("UNUSED_PARAMETER")
|
||||||
fun TransactionDSLInterpreter<LastLineShouldTestForVerifiesOrFails>.transaction(
|
fun TransactionDSLInterpreter<EnforceVerifyOrFail>.transaction(
|
||||||
dsl: TransactionDSL<
|
dsl: TransactionDSL<
|
||||||
LastLineShouldTestForVerifiesOrFails,
|
EnforceVerifyOrFail,
|
||||||
TransactionDSLInterpreter<LastLineShouldTestForVerifiesOrFails>
|
TransactionDSLInterpreter<EnforceVerifyOrFail>
|
||||||
>.() -> LastLineShouldTestForVerifiesOrFails) {
|
>.() -> EnforceVerifyOrFail) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated(
|
@Deprecated(
|
||||||
@ -54,8 +54,8 @@ fun TransactionDSLInterpreter<LastLineShouldTestForVerifiesOrFails>.transaction(
|
|||||||
replaceWith = ReplaceWith("tweak"),
|
replaceWith = ReplaceWith("tweak"),
|
||||||
level = DeprecationLevel.ERROR)
|
level = DeprecationLevel.ERROR)
|
||||||
@Suppress("UNUSED_PARAMETER")
|
@Suppress("UNUSED_PARAMETER")
|
||||||
fun LedgerDSLInterpreter<LastLineShouldTestForVerifiesOrFails, TransactionDSLInterpreter<LastLineShouldTestForVerifiesOrFails>>.ledger(
|
fun LedgerDSLInterpreter<EnforceVerifyOrFail, TransactionDSLInterpreter<EnforceVerifyOrFail>>.ledger(
|
||||||
dsl: LedgerDSL<LastLineShouldTestForVerifiesOrFails, TestTransactionDSLInterpreter, TestLedgerDSLInterpreter>.() -> Unit) {
|
dsl: LedgerDSL<EnforceVerifyOrFail, TestTransactionDSLInterpreter, TestLedgerDSLInterpreter>.() -> Unit) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,8 +64,8 @@ fun LedgerDSLInterpreter<LastLineShouldTestForVerifiesOrFails, TransactionDSLInt
|
|||||||
* will have as the last line either an accept or a failure test. The name is deliberately long to help make sense of
|
* will have as the last line either an accept or a failure test. The name is deliberately long to help make sense of
|
||||||
* the triggered diagnostic.
|
* the triggered diagnostic.
|
||||||
*/
|
*/
|
||||||
sealed class LastLineShouldTestForVerifiesOrFails {
|
sealed class EnforceVerifyOrFail {
|
||||||
internal object Token: LastLineShouldTestForVerifiesOrFails()
|
internal object Token: EnforceVerifyOrFail()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -80,7 +80,7 @@ data class TestTransactionDSLInterpreter(
|
|||||||
private val commands: ArrayList<Command> = arrayListOf(),
|
private val commands: ArrayList<Command> = arrayListOf(),
|
||||||
private val signers: LinkedHashSet<PublicKey> = LinkedHashSet(),
|
private val signers: LinkedHashSet<PublicKey> = LinkedHashSet(),
|
||||||
private val transactionType: TransactionType = TransactionType.General()
|
private val transactionType: TransactionType = TransactionType.General()
|
||||||
) : TransactionDSLInterpreter<LastLineShouldTestForVerifiesOrFails>, OutputStateLookup by ledgerInterpreter {
|
) : TransactionDSLInterpreter<EnforceVerifyOrFail>, OutputStateLookup by ledgerInterpreter {
|
||||||
private fun copy(): TestTransactionDSLInterpreter =
|
private fun copy(): TestTransactionDSLInterpreter =
|
||||||
TestTransactionDSLInterpreter(
|
TestTransactionDSLInterpreter(
|
||||||
ledgerInterpreter = ledgerInterpreter,
|
ledgerInterpreter = ledgerInterpreter,
|
||||||
@ -121,13 +121,13 @@ data class TestTransactionDSLInterpreter(
|
|||||||
commands.add(Command(commandData, signers))
|
commands.add(Command(commandData, signers))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun verifies(): LastLineShouldTestForVerifiesOrFails {
|
override fun verifies(): EnforceVerifyOrFail {
|
||||||
val resolvedTransaction = ledgerInterpreter.resolveWireTransaction(toWireTransaction())
|
val resolvedTransaction = ledgerInterpreter.resolveWireTransaction(toWireTransaction())
|
||||||
resolvedTransaction.verify()
|
resolvedTransaction.verify()
|
||||||
return LastLineShouldTestForVerifiesOrFails.Token
|
return EnforceVerifyOrFail.Token
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun failsWith(expectedMessage: String?): LastLineShouldTestForVerifiesOrFails {
|
override fun failsWith(expectedMessage: String?): EnforceVerifyOrFail {
|
||||||
val exceptionThrown = try {
|
val exceptionThrown = try {
|
||||||
this.verifies()
|
this.verifies()
|
||||||
false
|
false
|
||||||
@ -151,14 +151,14 @@ data class TestTransactionDSLInterpreter(
|
|||||||
throw AssertionError("Expected exception but didn't get one")
|
throw AssertionError("Expected exception but didn't get one")
|
||||||
}
|
}
|
||||||
|
|
||||||
return LastLineShouldTestForVerifiesOrFails.Token
|
return EnforceVerifyOrFail.Token
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun tweak(
|
override fun tweak(
|
||||||
dsl: TransactionDSL<
|
dsl: TransactionDSL<
|
||||||
LastLineShouldTestForVerifiesOrFails,
|
EnforceVerifyOrFail,
|
||||||
TransactionDSLInterpreter<LastLineShouldTestForVerifiesOrFails>
|
TransactionDSLInterpreter<EnforceVerifyOrFail>
|
||||||
>.() -> LastLineShouldTestForVerifiesOrFails
|
>.() -> EnforceVerifyOrFail
|
||||||
) = dsl(TransactionDSL(copy()))
|
) = dsl(TransactionDSL(copy()))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ data class TestLedgerDSLInterpreter private constructor (
|
|||||||
internal val labelToOutputStateAndRefs: HashMap<String, StateAndRef<ContractState>> = HashMap(),
|
internal val labelToOutputStateAndRefs: HashMap<String, StateAndRef<ContractState>> = HashMap(),
|
||||||
private val transactionWithLocations: HashMap<SecureHash, WireTransactionWithLocation> = HashMap(),
|
private val transactionWithLocations: HashMap<SecureHash, WireTransactionWithLocation> = HashMap(),
|
||||||
private val nonVerifiedTransactionWithLocations: HashMap<SecureHash, WireTransactionWithLocation> = HashMap()
|
private val nonVerifiedTransactionWithLocations: HashMap<SecureHash, WireTransactionWithLocation> = HashMap()
|
||||||
) : LedgerDSLInterpreter<LastLineShouldTestForVerifiesOrFails, TestTransactionDSLInterpreter> {
|
) : LedgerDSLInterpreter<EnforceVerifyOrFail, TestTransactionDSLInterpreter> {
|
||||||
|
|
||||||
val wireTransactions: List<WireTransaction> get() = transactionWithLocations.values.map { it.transaction }
|
val wireTransactions: List<WireTransaction> get() = transactionWithLocations.values.map { it.transaction }
|
||||||
|
|
||||||
@ -243,7 +243,7 @@ data class TestLedgerDSLInterpreter private constructor (
|
|||||||
storageService.attachments.openAttachment(attachmentId) ?: throw AttachmentResolutionException(attachmentId)
|
storageService.attachments.openAttachment(attachmentId) ?: throw AttachmentResolutionException(attachmentId)
|
||||||
|
|
||||||
private fun <Return> interpretTransactionDsl(
|
private fun <Return> interpretTransactionDsl(
|
||||||
dsl: TransactionDSL<LastLineShouldTestForVerifiesOrFails, TestTransactionDSLInterpreter>.() -> Return
|
dsl: TransactionDSL<EnforceVerifyOrFail, TestTransactionDSLInterpreter>.() -> Return
|
||||||
): TestTransactionDSLInterpreter {
|
): TestTransactionDSLInterpreter {
|
||||||
val transactionInterpreter = TestTransactionDSLInterpreter(this)
|
val transactionInterpreter = TestTransactionDSLInterpreter(this)
|
||||||
dsl(TransactionDSL(transactionInterpreter))
|
dsl(TransactionDSL(transactionInterpreter))
|
||||||
@ -274,7 +274,7 @@ data class TestLedgerDSLInterpreter private constructor (
|
|||||||
|
|
||||||
private fun <R> recordTransactionWithTransactionMap(
|
private fun <R> recordTransactionWithTransactionMap(
|
||||||
transactionLabel: String?,
|
transactionLabel: String?,
|
||||||
dsl: TransactionDSL<LastLineShouldTestForVerifiesOrFails, TestTransactionDSLInterpreter>.() -> R,
|
dsl: TransactionDSL<EnforceVerifyOrFail, TestTransactionDSLInterpreter>.() -> R,
|
||||||
transactionMap: HashMap<SecureHash, WireTransactionWithLocation> = HashMap()
|
transactionMap: HashMap<SecureHash, WireTransactionWithLocation> = HashMap()
|
||||||
): WireTransaction {
|
): WireTransaction {
|
||||||
val transactionLocation = getCallerLocation(3)
|
val transactionLocation = getCallerLocation(3)
|
||||||
@ -296,17 +296,17 @@ data class TestLedgerDSLInterpreter private constructor (
|
|||||||
|
|
||||||
override fun transaction(
|
override fun transaction(
|
||||||
transactionLabel: String?,
|
transactionLabel: String?,
|
||||||
dsl: TransactionDSL<LastLineShouldTestForVerifiesOrFails, TestTransactionDSLInterpreter>.() -> LastLineShouldTestForVerifiesOrFails
|
dsl: TransactionDSL<EnforceVerifyOrFail, TestTransactionDSLInterpreter>.() -> EnforceVerifyOrFail
|
||||||
) = recordTransactionWithTransactionMap(transactionLabel, dsl, transactionWithLocations)
|
) = recordTransactionWithTransactionMap(transactionLabel, dsl, transactionWithLocations)
|
||||||
|
|
||||||
override fun unverifiedTransaction(
|
override fun unverifiedTransaction(
|
||||||
transactionLabel: String?,
|
transactionLabel: String?,
|
||||||
dsl: TransactionDSL<LastLineShouldTestForVerifiesOrFails, TestTransactionDSLInterpreter>.() -> Unit
|
dsl: TransactionDSL<EnforceVerifyOrFail, TestTransactionDSLInterpreter>.() -> Unit
|
||||||
) = recordTransactionWithTransactionMap(transactionLabel, dsl, nonVerifiedTransactionWithLocations)
|
) = recordTransactionWithTransactionMap(transactionLabel, dsl, nonVerifiedTransactionWithLocations)
|
||||||
|
|
||||||
override fun tweak(
|
override fun tweak(
|
||||||
dsl: LedgerDSL<LastLineShouldTestForVerifiesOrFails, TestTransactionDSLInterpreter,
|
dsl: LedgerDSL<EnforceVerifyOrFail, TestTransactionDSLInterpreter,
|
||||||
LedgerDSLInterpreter<LastLineShouldTestForVerifiesOrFails, TestTransactionDSLInterpreter>>.() -> Unit) =
|
LedgerDSLInterpreter<EnforceVerifyOrFail, TestTransactionDSLInterpreter>>.() -> Unit) =
|
||||||
dsl(LedgerDSL(copy()))
|
dsl(LedgerDSL(copy()))
|
||||||
|
|
||||||
override fun attachment(attachment: InputStream): SecureHash {
|
override fun attachment(attachment: InputStream): SecureHash {
|
||||||
@ -349,6 +349,6 @@ fun signAll(transactionsToSign: List<WireTransaction>, extraKeys: Array<out KeyP
|
|||||||
SignedTransaction(bits, signatures)
|
SignedTransaction(bits, signatures)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun LedgerDSL<LastLineShouldTestForVerifiesOrFails, TestTransactionDSLInterpreter, TestLedgerDSLInterpreter>.signAll(
|
fun LedgerDSL<EnforceVerifyOrFail, TestTransactionDSLInterpreter, TestLedgerDSLInterpreter>.signAll(
|
||||||
transactionsToSign: List<WireTransaction> = this.interpreter.wireTransactions, vararg extraKeys: KeyPair) =
|
transactionsToSign: List<WireTransaction> = this.interpreter.wireTransactions, vararg extraKeys: KeyPair) =
|
||||||
signAll(transactionsToSign, extraKeys)
|
signAll(transactionsToSign, extraKeys)
|
||||||
|
@ -93,8 +93,8 @@ object JavaTestHelpers {
|
|||||||
@JvmStatic @JvmOverloads fun ledger(
|
@JvmStatic @JvmOverloads fun ledger(
|
||||||
identityService: IdentityService = MOCK_IDENTITY_SERVICE,
|
identityService: IdentityService = MOCK_IDENTITY_SERVICE,
|
||||||
storageService: StorageService = MockStorageService(),
|
storageService: StorageService = MockStorageService(),
|
||||||
dsl: LedgerDSL<LastLineShouldTestForVerifiesOrFails, TestTransactionDSLInterpreter, TestLedgerDSLInterpreter>.() -> Unit
|
dsl: LedgerDSL<EnforceVerifyOrFail, TestTransactionDSLInterpreter, TestLedgerDSLInterpreter>.() -> Unit
|
||||||
): LedgerDSL<LastLineShouldTestForVerifiesOrFails, TestTransactionDSLInterpreter, TestLedgerDSLInterpreter> {
|
): LedgerDSL<EnforceVerifyOrFail, TestTransactionDSLInterpreter, TestLedgerDSLInterpreter> {
|
||||||
val ledgerDsl = LedgerDSL(TestLedgerDSLInterpreter(identityService, storageService))
|
val ledgerDsl = LedgerDSL(TestLedgerDSLInterpreter(identityService, storageService))
|
||||||
dsl(ledgerDsl)
|
dsl(ledgerDsl)
|
||||||
return ledgerDsl
|
return ledgerDsl
|
||||||
@ -103,9 +103,9 @@ object JavaTestHelpers {
|
|||||||
@JvmStatic @JvmOverloads fun transaction(
|
@JvmStatic @JvmOverloads fun transaction(
|
||||||
transactionLabel: String? = null,
|
transactionLabel: String? = null,
|
||||||
dsl: TransactionDSL<
|
dsl: TransactionDSL<
|
||||||
LastLineShouldTestForVerifiesOrFails,
|
EnforceVerifyOrFail,
|
||||||
TransactionDSLInterpreter<LastLineShouldTestForVerifiesOrFails>
|
TransactionDSLInterpreter<EnforceVerifyOrFail>
|
||||||
>.() -> LastLineShouldTestForVerifiesOrFails
|
>.() -> EnforceVerifyOrFail
|
||||||
) = ledger { transaction(transactionLabel, dsl) }
|
) = ledger { transaction(transactionLabel, dsl) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,7 +366,7 @@ class TwoPartyTradeProtocolTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun LedgerDSL<LastLineShouldTestForVerifiesOrFails, TestTransactionDSLInterpreter, TestLedgerDSLInterpreter>.runWithError(
|
private fun LedgerDSL<EnforceVerifyOrFail, TestTransactionDSLInterpreter, TestLedgerDSLInterpreter>.runWithError(
|
||||||
bobError: Boolean,
|
bobError: Boolean,
|
||||||
aliceError: Boolean,
|
aliceError: Boolean,
|
||||||
expectedMessageSubstring: String
|
expectedMessageSubstring: String
|
||||||
@ -431,7 +431,7 @@ class TwoPartyTradeProtocolTests {
|
|||||||
return signed.associateBy { it.id }
|
return signed.associateBy { it.id }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun LedgerDSL<LastLineShouldTestForVerifiesOrFails, TestTransactionDSLInterpreter, TestLedgerDSLInterpreter>.fillUpForBuyer(
|
private fun LedgerDSL<EnforceVerifyOrFail, TestTransactionDSLInterpreter, TestLedgerDSLInterpreter>.fillUpForBuyer(
|
||||||
withError: Boolean,
|
withError: Boolean,
|
||||||
owner: PublicKey = BOB_PUBKEY,
|
owner: PublicKey = BOB_PUBKEY,
|
||||||
issuer: PartyAndReference = MEGA_CORP.ref(1)): Pair<Wallet, List<WireTransaction>> {
|
issuer: PartyAndReference = MEGA_CORP.ref(1)): Pair<Wallet, List<WireTransaction>> {
|
||||||
@ -472,7 +472,7 @@ class TwoPartyTradeProtocolTests {
|
|||||||
return Pair(wallet, listOf(eb1, bc1, bc2))
|
return Pair(wallet, listOf(eb1, bc1, bc2))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun LedgerDSL<LastLineShouldTestForVerifiesOrFails, TestTransactionDSLInterpreter, TestLedgerDSLInterpreter>.fillUpForSeller(
|
private fun LedgerDSL<EnforceVerifyOrFail, TestTransactionDSLInterpreter, TestLedgerDSLInterpreter>.fillUpForSeller(
|
||||||
withError: Boolean,
|
withError: Boolean,
|
||||||
owner: PublicKey,
|
owner: PublicKey,
|
||||||
amount: Amount<Issued<Currency>>,
|
amount: Amount<Issued<Currency>>,
|
||||||
|
@ -9,7 +9,7 @@ import org.graphstream.graph.Node
|
|||||||
import org.graphstream.graph.implementations.SingleGraph
|
import org.graphstream.graph.implementations.SingleGraph
|
||||||
import kotlin.reflect.memberProperties
|
import kotlin.reflect.memberProperties
|
||||||
|
|
||||||
class GraphVisualiser(val dsl: LedgerDSL<LastLineShouldTestForVerifiesOrFails, TestTransactionDSLInterpreter, TestLedgerDSLInterpreter>) {
|
class GraphVisualiser(val dsl: LedgerDSL<EnforceVerifyOrFail, TestTransactionDSLInterpreter, TestLedgerDSLInterpreter>) {
|
||||||
companion object {
|
companion object {
|
||||||
val css = GraphVisualiser::class.java.getResourceAsStream("graph.css").bufferedReader().readText()
|
val css = GraphVisualiser::class.java.getResourceAsStream("graph.css").bufferedReader().readText()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user