有时,在我们的Cordapp测试代码中,我们需要注入其他类(例如其他流,Corda服务等)作为Cordapp。以前在Corda 3.x中这是可能的。在Corda 4.x中似乎并非如此。
示例:
假设kotlin模板假设测试源中还有
的其他类/**
* This service is representative of a service we use in our primary project.
* It contains logic that's very useful from the perspective of our cordapps testing.
* Historically in Corda 3.x we could load this service into the MockNetwork node's classpath
* This is no longer the case. The log line in the initialiser is never called.
*/
@CordaService
class TestCordaService(serviceHub: AppServiceHub) : SingletonSerializeAsToken() {
//...
}
在Corda 3.x中,我们可以按以下方式启动网络:
MockNetwork(cordappPackages = listOf("<package names>"))
在Corda 4.x中有实现此目的的方法。
答案 0 :(得分:1)
经过一些实验,我遇到了javax.net.ssl.trustStore
类。
我们可以像这样使用此类:
System.getenv("JAVA_HOME") + "/jre/lib/security/cacerts"
有关示例,请参见此仓库:https://github.com/dazraf/mock-network-service-reproducer