Re-add lost fix

This commit is contained in:
nikinagy 2020-08-19 18:57:39 +01:00
parent 4cce83522e
commit 8b900c7c08

View File

@ -6,6 +6,7 @@ import net.corda.core.contracts.Contract
import net.corda.core.contracts.ContractState import net.corda.core.contracts.ContractState
import net.corda.core.contracts.StateRef import net.corda.core.contracts.StateRef
import net.corda.core.identity.AbstractParty import net.corda.core.identity.AbstractParty
import net.corda.core.node.ServiceHub
import net.corda.core.node.services.Vault import net.corda.core.node.services.Vault
import net.corda.core.node.services.queryBy import net.corda.core.node.services.queryBy
import net.corda.core.node.services.vault.DEFAULT_PAGE_SIZE import net.corda.core.node.services.vault.DEFAULT_PAGE_SIZE
@ -22,7 +23,9 @@ import net.corda.core.transactions.TransactionBuilder
import net.corda.testing.core.ALICE_NAME import net.corda.testing.core.ALICE_NAME
import net.corda.testing.node.MockNetwork import net.corda.testing.node.MockNetwork
import net.corda.testing.node.MockNetworkParameters import net.corda.testing.node.MockNetworkParameters
import net.corda.testing.node.StartedMockNode
import net.corda.testing.node.internal.cordappsForPackages import net.corda.testing.node.internal.cordappsForPackages
import org.junit.AfterClass
import org.junit.BeforeClass import org.junit.BeforeClass
import org.junit.Test import org.junit.Test
import javax.persistence.Column import javax.persistence.Column
@ -33,7 +36,17 @@ import kotlin.test.assertEquals
class VaultQueryJoinTest { class VaultQueryJoinTest {
companion object { companion object {
private val mockNetwork = MockNetwork( private var mockNetwork: MockNetwork? = null
private lateinit var aliceNode: StartedMockNode
private lateinit var notaryNode: StartedMockNode
private lateinit var serviceHubHandle: ServiceHub
private val createdStateRefs = mutableListOf<StateRef>()
private const val numObjectsInLedger = DEFAULT_PAGE_SIZE + 1
@BeforeClass
@JvmStatic
fun setup() {
mockNetwork = MockNetwork(
MockNetworkParameters( MockNetworkParameters(
cordappsForAllNodes = cordappsForPackages( cordappsForAllNodes = cordappsForPackages(
listOf( listOf(
@ -41,16 +54,11 @@ class VaultQueryJoinTest {
) )
) )
) )
) ).also { mockNetwork ->
private val aliceNode = mockNetwork.createPartyNode(ALICE_NAME) aliceNode = mockNetwork.createPartyNode(ALICE_NAME)
private val notaryNode = mockNetwork.defaultNotaryNode notaryNode = mockNetwork.defaultNotaryNode
private val serviceHubHandle = aliceNode.services serviceHubHandle = aliceNode.services
private val createdStateRefs = mutableListOf<StateRef>() }
private const val numObjectsInLedger = DEFAULT_PAGE_SIZE + 1
@BeforeClass
@JvmStatic
fun setup() {
repeat(numObjectsInLedger) { index -> repeat(numObjectsInLedger) { index ->
createdStateRefs.add(addSimpleObjectToLedger(DummyData(index))) createdStateRefs.add(addSimpleObjectToLedger(DummyData(index)))
} }
@ -58,6 +66,13 @@ class VaultQueryJoinTest {
System.setProperty("net.corda.vault.query.disable.corda3879", "false"); System.setProperty("net.corda.vault.query.disable.corda3879", "false");
} }
@AfterClass
@JvmStatic
fun teardown() {
mockNetwork?.stopNodes()
mockNetwork = null
}
private fun addSimpleObjectToLedger(dummyObject: DummyData): StateRef { private fun addSimpleObjectToLedger(dummyObject: DummyData): StateRef {
val tx = TransactionBuilder(notaryNode.info.legalIdentities.first()) val tx = TransactionBuilder(notaryNode.info.legalIdentities.first())
tx.addOutputState( tx.addOutputState(