Corda FlowTest设置中具有两个未消耗状态的LinearState [英] LinearState with two unconsumed states in Corda FlowTest setup

查看:53
本文介绍了Corda FlowTest设置中具有两个未消耗状态的LinearState的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为带有LinearState的流编写FlowTest。在设置中,我需要创建一个LinearState,然后通过在第二个事务中使用第一个事务来创建该状态的第二个版本(具有相同的唯一标识符)。我按照Corda文档上 v2.0 教程中的步骤进行操作。

I am trying to write a FlowTest for a Flow with a LinearState. In the setup, I need to create a LinearState and then create a second version of that state (with the same unique identifier) by consuming the first in a second transaction. I followed the steps in the v2.0 tutorial on the corda docs.

但是,当我查询库中的状态时,会得到两个未消耗状态。我希望其中的一个已被消耗(因此具有 Vault.StateStatus.UNCONSUMED )。

However, when I query for the states in the vault, I get two unconsumed states. I would have expected one of them to have been consumed (and thus have Vault.StateStatus.UNCONSUMED).

我已经为真实代码编写了一个基于驱动程序的集成测试,并且工作正常。因此,我认为我为此情况设置了错误的测试。

I have written a driver based integration test for the real code, and that works fine. So I'm presuming I have incorrectly set up the test for this situation.

任何想法我需要做什么,以便在保管库中只有一个未使用状态?

Any ideas what I need to do to have only one unconsumed state in the vault?

类似的测试代码重现此处

非常感谢:-)

推荐答案

在测试代码中,您首先生成了两个事务,然后使用以下代码一次记录了两个事务:

In your test code, you generate the two transactions first, then record them both at once using the following code:

member1.database.transaction {
    member1.services.recordTransactions(tx1, tx2)
}

如果修改代码,以便在第二项之前记录第一个事务,那么流测试将通过:

If you modify your code so that you record the first transaction before the second, the flow tests pass:

member1.database.transaction {
    member1.services.recordTransactions(tx1)
    member1.services.recordTransactions(tx2)
}

它看起来像 recordTransactions 不一定记录交易它们作为参数传递的顺序。如果首先记录 tx2 ,则找不到 tx1 的输出状态标记为已消耗。因此, tx1 的输出状态仍未消耗。

It looks like recordTransactions doesn't necessarily record the transactions in the order in which they are passed in as arguments. If tx2 is recorded first, it can't find the output state of tx1 to mark as consumed. The output state of tx1 therefore remains unconsumed.

这篇关于Corda FlowTest设置中具有两个未消耗状态的LinearState的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆