java.lang.IllegalStateException: Was not expecting to find existing database transaction on current strand when setting database: Thread[Test worker,5,main], net.corda.nodeapi.internal.persistence.DatabaseTransaction@3e9f2c2e
at net.corda.nodeapi.internal.persistence.CordaPersistence.<init>(CordaPersistence.kt:79)
at net.corda.node.internal.AbstractNodeKt.configureDatabase(AbstractNode.kt:900)
at net.corda.node.internal.AbstractNode.initialiseDatabasePersistence(AbstractNode.kt:668)
at net.corda.testing.node.internal.InternalMockNetwork$MockNode.initialiseDatabasePersistence(InternalMockNetwork.kt:315)
at net.corda.node.internal.AbstractNode.start(AbstractNode.kt:208)
at net.corda.testing.node.internal.InternalMockNetwork$MockNode.start(InternalMockNetwork.kt:245)
at net.corda.testing.node.internal.InternalMockNetwork.createNodeImpl(InternalMockNetwork.kt:377)
at net.corda.testing.node.internal.InternalMockNetwork.createNode(InternalMockNetwork.kt:363)
at net.corda.testing.node.internal.InternalMockNetwork.createNode(InternalMockNetwork.kt:358)
at net.corda.testing.node.internal.InternalMockNetwork.createNotaries$node_driver(InternalMockNetwork.kt:211)
at net.corda.testing.node.internal.InternalMockNetwork.<init>(InternalMockNetwork.kt:194)
at net.corda.testing.node.internal.InternalMockNetwork.<init>(InternalMockNetwork.kt:100)
at net.corda.testing.node.MockNetwork.<init>(MockNetwork.kt:217)
at net.corda.testing.node.MockNetwork.<init>(MockNetwork.kt:211)
at com.synechron.cordapp.flows.FlowUnitTests.setup(FlowUnitTests.kt:29)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:114)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:57)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:66)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy1.processTestClass(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:109)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:146)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:128)
at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:748)
我有用于测试Corda自定义流的测试类,单个测试用例正在成功运行,但是当我运行类本身时抛出异常。流只有代码来创建linear state
并消耗现有状态(如果已存在于vault
上)而不是分发给参与者。没有特别的逻辑或DB session
开放。
为同一项目的其他流程编写测试类,没有任何异常。
不知道为什么它在DB tx
执行之间泄漏了test cases
。
答案 0 :(得分:5)
使用MockNode
时,您应该在执行访问其数据库的操作之前显式打开特定节点的数据库事务:
mockNodeA.transaction {
// Access to the node's database...
}
如果你没有这样做:
IllegalStateException
时,您将获得MockNetwork