Corda 是否可以在合同单元测试中获取从LedgerDSL返回的LedgerTransaction对象?

Corda 是否可以在合同单元测试中获取从LedgerDSL返回的LedgerTransaction对象?,corda,Corda,我有一个使用这种符号的单元测试: ledgerServices.ledger { transaction { ... this.verifies() } } 我希望实际拥有LedgerTransaction对象,这样我就可以测试一个以tx作为参数的helper方法。是否可以使用LedgerDSL执行此操作,还是需要在单元测试中手动使用TransactionBuilder创建LedgerTransaction实例?我

我有一个使用这种符号的单元测试:

ledgerServices.ledger {
        transaction {
            ...
            this.verifies()
        }
}
我希望实际拥有LedgerTransaction对象,这样我就可以测试一个以tx作为参数的helper方法。是否可以使用LedgerDSL执行此操作,还是需要在单元测试中手动使用TransactionBuilder创建LedgerTransaction实例?

我不这么认为

我建议您在测试流时计算事务并测试助手方法:

    @Test
fun flowReturnsCorrectlyFormedPartiallySignedTransaction() {
    val lender = a.info.chooseIdentityAndCert().party
    val borrower = b.info.chooseIdentityAndCert().party
    val stx = issueIou(IOUState(10.POUNDS, lender, borrower))
    val inputIou = stx.tx.outputs.single().data as IOUState
    val flow = IOUTransferFlow(inputIou.linearId, c.info.chooseIdentityAndCert().party)
    val future = a.startFlow(flow)
    mockNetwork.runNetwork()
    val ptx = future.getOrThrow()
    // Check the transaction is well formed...
    // One output IOUState, one input state reference and a Transfer command with the right properties.
    assert(ptx.tx.inputs.size == 1)
    assert(ptx.tx.outputs.size == 1)
    assert(ptx.tx.inputs.single() == StateRef(stx.id, 0))
    println("Input state ref: ${ptx.tx.inputs.single()} == ${StateRef(stx.id, 0)}")
    val outputIou = ptx.tx.outputs.single().data as IOUState
    println("Output state: $outputIou")
    val command = ptx.tx.commands.single()
    assert(command.value == IOUContract.Commands.Transfer())
    ptx.verifySignaturesExcept(b.info.chooseIdentityAndCert().party.owningKey, c.info.chooseIdentityAndCert().party.owningKey,
            mockNetwork.defaultNotaryNode.info.legalIdentitiesAndCerts.first().owningKey)
}