【问题标题】:Restarting nodes in a flow test throws an error在流测试中重新启动节点会引发错误
【发布时间】:2019-12-17 17:51:42
【问题描述】:

我的节点有一个自定义的配置文件,事件流程如下:
1. 启动我的网络
2. 运行创建我的 TokenType
的流程 3. 停止节点
4. 将令牌类型标识符添加到自定义配置
5. 启动节点
6. 现在我的其他流程可以从自定义配置中读取该值并完成他们的工作

// Custom config map
Map<String, String> customConfig = new LinkedHashMap<>();

// Assign custom config to nodes
network = new MockNetwork(new MockNetworkParameters().withCordappsForAllNodes(ImmutableList.of(
                TestCordapp.findCordapp("xxx").withConfig(customConfig),

// Run the network and my flow that creates some value to be stored in the config

// Stop the nodes
network.stopNodes();
// Add new value to custom config
customConfig.put("new_value", someNewValue);
// Start the nodes
network.startNodes();

但第二次启动网络时出现此错误:

java.lang.IllegalStateException: Unable to determine which flow to use when responding to: 
com.r3.corda.lib.tokens.workflows.flows.rpc.ConfidentialRedeemFungibleTokens. 
[com.r3.corda.lib.tokens.workflows.flows.rpc.ConfidentialRedeemFungibleTokensHandler, 
com.r3.corda.lib.tokens.workflows.flows.rpc.ConfidentialRedeemFungibleTokensHandler] are all registered 
with equal weight.

【问题讨论】:

    标签: corda


    【解决方案1】:

    corda-app 中是否存在多个流?尝试覆盖现有流程时出现类似错误。在deployNodes gradle task下的节点定义中添加flowOverride后,问题就消失了。

    例子:

    node {
            name "O=PartyA,L=London,C=GB"
            p2pPort 10004
            rpcSettings {
                address("localhost:10005")
                adminAddress("localhost:10006")
            }
            rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]]
            flowOverride("com.example.flow.ExampleFlow.Initiator",
                    "com.example.flow.OverrideAcceptor")
        }
    

    有关此内容的更多信息,请参见以下链接: https://docs.corda.net/head/flow-overriding.html#configuring-responder-flows https://lankydan.dev/2019/03/02/extending-and-overriding-flows-from-external-cordapps

    【讨论】:

    • Kalyan,我的问题是内部流测试;不是在运行节点时;所以这里不涉及deployNodes任务。
    猜你喜欢
    • 2013-11-23
    • 1970-01-01
    • 2018-01-30
    • 2019-09-11
    • 2013-09-22
    • 1970-01-01
    • 1970-01-01
    • 2020-11-04
    相关资源
    最近更新 更多