為了測(cè)試我的 CorDapp,我使用了 API 的說明:測(cè)試文檔和cordapp-template-java 項(xiàng)目中的 FlowTest.java 文件。您將在下面找到我的代碼。我對(duì)這個(gè)StartedNodeServices.startFlow()功能很掙扎。文檔指出它應(yīng)該接受 a FlowLogic<T>,這將是我的示例中的類的實(shí)例InitiatorFlow。然而,測(cè)試文檔顯示了兩個(gè)輸入。下面的代碼會(huì)導(dǎo)致以下錯(cuò)誤:The method startFlow(FlowLogic<? extends T>, InvocationContext) in the type FlowStarter is not applicable for the arguments (ServiceHub, InitiatorFlow)我不知道如何處理這個(gè)問題,因?yàn)闇y(cè)試文檔中顯示的第一個(gè)輸入不是 FlowLogic。如果我切換參數(shù),也會(huì)發(fā)生同樣的錯(cuò)誤。也許你可以給我一些如何處理這個(gè)問題的提示。感謝您的幫助!package com.template;import com.google.common.collect.ImmutableList;import com.template.flows.InitiatorFlow;import com.template.flows.Responder;import com.template.states.MyState;import net.corda.core.concurrent.CordaFuture;import net.corda.core.context.InvocationContext;import net.corda.core.flows.InitiatedBy;import net.corda.core.identity.AbstractParty;import net.corda.core.identity.CordaX500Name;import net.corda.core.transactions.SignedTransaction;import net.corda.testing.node.MockNetwork;import net.corda.testing.node.MockNetworkParameters;import net.corda.testing.node.StartedMockNode;import net.corda.testing.node.TestCordapp;import org.junit.After;import org.junit.Before;import org.junit.Test;import net.corda.node.services.api.StartedNodeServices;import net.corda.node.services.statemachine.ExternalEvent.ExternalStartFlowEvent;import net.corda.node.services.api.StartedNodeServices.*;public class FlowTests { private final MockNetwork network = new MockNetwork(new MockNetworkParameters(ImmutableList.of( TestCordapp.findCordapp("com.template.contracts"), TestCordapp.findCordapp("com.template.flows") ))); private final StartedMockNode alice = network.createPartyNode(new CordaX500Name("Alice", "London", "GB")); private final StartedMockNode bob = network.createPartyNode(new CordaX500Name("Bob", "Paris", "FR")); public FlowTests() { alice.registerInitiatedFlow(InitiatorFlow.class); bob.registerInitiatedFlow(InitiatorFlow.class); }
1 回答

回首憶惘然
TA貢獻(xiàn)1847條經(jīng)驗(yàn) 獲得超11個(gè)贊
可以使用以下測(cè)試方法修復(fù)此問題:
public void dummyTest() throws InterruptedException, ExecutionException {
InitiatorFlow flow = new InitiatorFlow(5, 100, bob.getInfo().getLegalIdentitiesAndCerts().get(0).getParty());
CordaFuture<SignedTransaction> future = alice.startFlow(flow);
network.runNetwork();
SignedTransaction signedTransaction = future.get();
}
確保InitiatorFlow延伸FlowLogic <SignedTransaction>.
添加回答
舉報(bào)
0/150
提交
取消