Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Corda-自Corda 4升级后,测试接受程序流失败_Corda - Fatal编程技术网

Corda-自Corda 4升级后,测试接受程序流失败

Corda-自Corda 4升级后,测试接受程序流失败,corda,Corda,以下流量测试用于Corda 3中的工作 @Test fun `can ping counterparties`() { val acceptorFlowFutures = listOf(nodeB, nodeC).map { it.registerInitiatedFlow(SendPingAcceptorFlow::class.java).toFuture() } nodeA.startFlow(SendPingInitiatorFlow("Ping

以下流量测试用于Corda 3中的工作

@Test
fun `can ping counterparties`() {

    val acceptorFlowFutures = listOf(nodeB, nodeC).map {
        it.registerInitiatedFlow(SendPingAcceptorFlow::class.java).toFuture()
    }

    nodeA.startFlow(SendPingInitiatorFlow("Ping!"))
    network.runNetwork()

    acceptorFlowFutures.forEach {
        val result = it
            .getOrThrow(Duration.ofMinutes(1)) // Timeout failure here
            .stateMachine
            .resultFuture
            .getOrThrow(Duration.ofMinutes(1)) as String

        assertEquals("Ping!", result)
    }
}
但由于更新为使用Corda 4,它现在得到以下异常:

java.util.concurrent.TimeoutException


是什么导致了这种情况?

我已经在Corda 4上成功地测试了以下代码,并使用了给定的场景

import co.paralleluniverse.fibers.Suspendable
import net.corda.core.flows.*
import net.corda.core.identity.Party
import net.corda.core.toFuture
import net.corda.core.utilities.getOrThrow
import net.corda.core.utilities.unwrap
import net.corda.testing.internal.chooseIdentity
import net.corda.testing.node.MockNetwork
import net.corda.testing.node.StartedMockNode
import org.junit.After
import org.junit.Before
import org.junit.Test
import java.time.Duration
import kotlin.test.assertEquals

class DummyFlowUnitTests2 {
    lateinit var network: MockNetwork
    lateinit var nodeA: StartedMockNode
    lateinit var nodeB: StartedMockNode
    lateinit var nodeC: StartedMockNode

    lateinit var partyA: Party
    lateinit var partyB: Party
    lateinit var partyC: Party

    @Before
    fun setup() {
        network = MockNetwork(listOf("com.corda.cordapp"))

        //Create nodes.
        nodeA = network.createNode()
        nodeB = network.createNode()
        nodeC = network.createNode()

        partyA = nodeA.info.chooseIdentity()
        partyB = nodeB.info.chooseIdentity()
        partyC = nodeC.info.chooseIdentity()

        nodeB.registerInitiatedFlow(SendPingAcceptorFlow::class.java)
        nodeC.registerInitiatedFlow(SendPingAcceptorFlow::class.java)
    }

    @After
    fun tearDown() {
        network.stopNodes()
    }

    @Test
    fun `can ping counterparties`() {

        val acceptorFlowFutures = listOf(nodeB, nodeC).map {
            it.registerInitiatedFlow(SendPingAcceptorFlow::class.java).toFuture()
        }

        nodeA.startFlow(SendPingInitiatorFlow("Ping!", listOf(partyB, partyC)))
        network.runNetwork()

        acceptorFlowFutures.forEach {
            val result = it
                    .getOrThrow(Duration.ofMinutes(1)) // Timeout failure here
                    .stateMachine
                    .resultFuture
                    .getOrThrow(Duration.ofMinutes(1)) as String

            assertEquals("Ping!", result)
        }
    }

    @InitiatingFlow
    @StartableByRPC
    data class SendPingInitiatorFlow(val msg: String, val parties: List<Party>) : FlowLogic<Unit>() {

        @Suspendable
        override fun call() {
            parties.map { initiateFlow(it) }.forEach {
                it.send(msg)
            }
        }
    }

    @InitiatedBy(SendPingInitiatorFlow::class)
    data class SendPingAcceptorFlow(val othersideSession: FlowSession) : FlowLogic<String>() {

        @Suspendable
        override fun call(): String {
            return othersideSession.receive<String>().unwrap { it }
        }
    }
}

import co.paralleluniverse.fibers.Suspendable
导入net.corda.core.flows*
导入net.corda.core.identity.Party
导入net.corda.core.toFuture
导入net.corda.core.utilities.getOrThrow
导入net.corda.core.utilities.unwrap
导入net.corda.testing.internal.chooseIdentity
导入net.corda.testing.node.MockNetwork
导入net.corda.testing.node.StartedMockNode
导入org.junit.After
导入org.junit.Before
导入org.junit.Test
导入java.time.Duration
导入kotlin.test.assertEquals
类DummyFlowUnitTests2{
lateinit var网络:MockNetwork
lateinit变量nodeA:StartedMockNode
lateinit变量nodeB:StartedMockNode
lateinit变量nodeC:StartedMockNode
lateinit var partyA:党
lateinit var partyB:党
lateinit var partyC:参与方
@以前
趣味设置(){
network=MockNetwork(listOf(“com.corda.cordapp”))
//创建节点。
nodeA=network.createNode()
nodeB=network.createNode()
nodeC=network.createNode()
partyA=nodeA.info.chooseIdentity()
partyB=nodeB.info.chooseIdentity()
partyC=nodeC.info.chooseIdentity()
registerInitiatedFlow(SendPingAcceptorFlow::class.java)
registerInitiatedFlow(SendPingAcceptorFlow::class.java)
}
@之后
有趣的撕裂{
network.stopNodes()
}
@试验
乐趣`可以ping交易对手'(){
val acceptorFlowFutures=listOf(nodeB,nodeC).map{
registerInitiatedFlow(SendPingAcceptorFlow::class.java).toFuture()的
}
nodeA.startFlow(SendPingInitiatorFlow(“Ping!”,listOf(partyB,partyC)))
network.runNetwork()
acceptorFlowFutures.forEach{
val result=it
.getOrThrow(持续时间.ofMinutes(1))//此处超时失败
.状态机
.结果未来
.getOrThrow(持续时间为分钟(1))作为字符串
assertEquals(“Ping!”,结果)
}
}
@启动流
@星表
数据类SendPingInitiatorFlow(val msg:String,val parties:List):FlowLogic(){
@暂停
覆盖有趣的调用(){
parties.map{initiateFlow(it)}.forEach{
it.send(msg)
}
}
}
@发起人(SendPingInitiatorFlow::类)
数据类SendPingAcceptorFlow(val othersideSession:FlowSession):FlowLogic(){
@暂停
重写有趣的调用():字符串{
返回othersideSession.receive().unwrap{it}
}
}
}