【发布时间】:2019-10-27 01:45:01
【问题描述】:
有时,在我们的 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 中实现这一点。
【问题讨论】:
标签: corda