mirror of
https://github.com/corda/corda.git
synced 2025-06-22 09:08:49 +00:00
Minor: auto-format of module: test-utils
This commit is contained in:
@ -68,6 +68,7 @@ inline fun <reified E : Any> expect(
|
|||||||
* @param expectations The pieces of DSL that should run sequentially when events arrive.
|
* @param expectations The pieces of DSL that should run sequentially when events arrive.
|
||||||
*/
|
*/
|
||||||
fun <E> sequence(vararg expectations: ExpectCompose<E>): ExpectCompose<E> = ExpectCompose.Sequential(listOf(*expectations))
|
fun <E> sequence(vararg expectations: ExpectCompose<E>): ExpectCompose<E> = ExpectCompose.Sequential(listOf(*expectations))
|
||||||
|
|
||||||
fun <E> sequence(expectations: List<ExpectCompose<E>>): ExpectCompose<E> = ExpectCompose.Sequential(expectations)
|
fun <E> sequence(expectations: List<ExpectCompose<E>>): ExpectCompose<E> = ExpectCompose.Sequential(expectations)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,6 +77,7 @@ fun <E> sequence(expectations: List<ExpectCompose<E>>): ExpectCompose<E> = Expec
|
|||||||
* @param expectations The pieces of DSL all of which should run but in an unspecified order depending on what sequence events arrive.
|
* @param expectations The pieces of DSL all of which should run but in an unspecified order depending on what sequence events arrive.
|
||||||
*/
|
*/
|
||||||
fun <E> parallel(vararg expectations: ExpectCompose<E>): ExpectCompose<E> = ExpectCompose.Parallel(listOf(*expectations))
|
fun <E> parallel(vararg expectations: ExpectCompose<E>): ExpectCompose<E> = ExpectCompose.Parallel(listOf(*expectations))
|
||||||
|
|
||||||
fun <E> parallel(expectations: List<ExpectCompose<E>>): ExpectCompose<E> = ExpectCompose.Parallel(expectations)
|
fun <E> parallel(expectations: List<ExpectCompose<E>>): ExpectCompose<E> = ExpectCompose.Parallel(expectations)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -202,6 +204,7 @@ private sealed class ExpectComposeState<E : Any> {
|
|||||||
override fun nextState(event: E) = null
|
override fun nextState(event: E) = null
|
||||||
override fun getExpectedEvents(): List<Class<E>> = listOf()
|
override fun getExpectedEvents(): List<Class<E>> = listOf()
|
||||||
}
|
}
|
||||||
|
|
||||||
class Single<E : Any, T : E>(val single: ExpectCompose.Single<E, T>) : ExpectComposeState<E>() {
|
class Single<E : Any, T : E>(val single: ExpectCompose.Single<E, T>) : ExpectComposeState<E>() {
|
||||||
override fun nextState(event: E): Pair<() -> Unit, ExpectComposeState<E>>? =
|
override fun nextState(event: E): Pair<() -> Unit, ExpectComposeState<E>>? =
|
||||||
if (single.expect.clazz.isAssignableFrom(event.javaClass)) {
|
if (single.expect.clazz.isAssignableFrom(event.javaClass)) {
|
||||||
@ -215,6 +218,7 @@ private sealed class ExpectComposeState<E : Any> {
|
|||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getExpectedEvents() = listOf(single.expect.clazz)
|
override fun getExpectedEvents() = listOf(single.expect.clazz)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,6 +270,7 @@ private sealed class ExpectComposeState<E : Any> {
|
|||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getExpectedEvents() = states.flatMap { it.getExpectedEvents() }
|
override fun getExpectedEvents() = states.flatMap { it.getExpectedEvents() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package net.corda.testing
|
package net.corda.testing
|
||||||
|
|
||||||
import net.corda.core.contracts.*
|
import net.corda.core.contracts.ContractState
|
||||||
|
import net.corda.core.contracts.StateAndRef
|
||||||
|
import net.corda.core.contracts.TransactionState
|
||||||
import net.corda.core.crypto.SecureHash
|
import net.corda.core.crypto.SecureHash
|
||||||
import net.corda.core.transactions.TransactionBuilder
|
import net.corda.core.transactions.TransactionBuilder
|
||||||
import net.corda.core.transactions.WireTransaction
|
import net.corda.core.transactions.WireTransaction
|
||||||
@ -132,6 +134,7 @@ class LedgerDSL<out T : TransactionDSLInterpreter, out L : LedgerDSLInterpreter<
|
|||||||
fun transaction(label: String? = null, transactionBuilder: TransactionBuilder = TransactionBuilder(notary = DUMMY_NOTARY),
|
fun transaction(label: String? = null, transactionBuilder: TransactionBuilder = TransactionBuilder(notary = DUMMY_NOTARY),
|
||||||
dsl: TransactionDSL<TransactionDSLInterpreter>.() -> EnforceVerifyOrFail) =
|
dsl: TransactionDSL<TransactionDSLInterpreter>.() -> EnforceVerifyOrFail) =
|
||||||
_transaction(label, transactionBuilder, dsl)
|
_transaction(label, transactionBuilder, dsl)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see LedgerDSLInterpreter._unverifiedTransaction
|
* @see LedgerDSLInterpreter._unverifiedTransaction
|
||||||
*/
|
*/
|
||||||
|
@ -4,8 +4,8 @@ import com.google.common.net.HostAndPort
|
|||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.io.InputStreamReader
|
import java.io.InputStreamReader
|
||||||
import java.net.ConnectException
|
import java.net.ConnectException
|
||||||
import java.net.SocketException
|
|
||||||
import java.net.HttpURLConnection
|
import java.net.HttpURLConnection
|
||||||
|
import java.net.SocketException
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.corda.testing
|
package net.corda.testing
|
||||||
|
|
||||||
|
import net.corda.testing.TestTimestamp.Companion.timestamp
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
@ -84,6 +84,7 @@ class TransactionDSL<out T : TransactionDSLInterpreter>(val interpreter: T) : Tr
|
|||||||
}
|
}
|
||||||
input(transaction.outRef<ContractState>(0).ref)
|
input(transaction.outRef<ContractState>(0).ref)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun input(stateClosure: () -> ContractState) = input(stateClosure())
|
fun input(stateClosure: () -> ContractState) = input(stateClosure())
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -92,6 +93,7 @@ class TransactionDSL<out T : TransactionDSLInterpreter>(val interpreter: T) : Tr
|
|||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
fun output(label: String? = null, notary: Party = DUMMY_NOTARY, encumbrance: Int? = null, contractStateClosure: () -> ContractState) =
|
fun output(label: String? = null, notary: Party = DUMMY_NOTARY, encumbrance: Int? = null, contractStateClosure: () -> ContractState) =
|
||||||
_output(label, notary, encumbrance, contractStateClosure())
|
_output(label, notary, encumbrance, contractStateClosure())
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see TransactionDSLInterpreter._output
|
* @see TransactionDSLInterpreter._output
|
||||||
*/
|
*/
|
||||||
@ -106,6 +108,7 @@ class TransactionDSL<out T : TransactionDSLInterpreter>(val interpreter: T) : Tr
|
|||||||
*/
|
*/
|
||||||
fun command(vararg signers: CompositeKey, commandDataClosure: () -> CommandData) =
|
fun command(vararg signers: CompositeKey, commandDataClosure: () -> CommandData) =
|
||||||
_command(listOf(*signers), commandDataClosure())
|
_command(listOf(*signers), commandDataClosure())
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see TransactionDSLInterpreter._command
|
* @see TransactionDSLInterpreter._command
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package net.corda.testing.http
|
package net.corda.testing.http
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper
|
|
||||||
import com.google.common.net.HostAndPort
|
import com.google.common.net.HostAndPort
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
|
|
||||||
@ -11,6 +10,7 @@ class HttpApi(val root: URL) {
|
|||||||
* @param data String values are assumed to be valid JSON. All other values will be mapped to JSON.
|
* @param data String values are assumed to be valid JSON. All other values will be mapped to JSON.
|
||||||
*/
|
*/
|
||||||
fun putJson(path: String, data: Any = Unit) = HttpUtils.putJson(URL(root, path), toJson(data))
|
fun putJson(path: String, data: Any = Unit) = HttpUtils.putJson(URL(root, path), toJson(data))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a POST with a payload to the path on the API specified.
|
* Send a POST with a payload to the path on the API specified.
|
||||||
*
|
*
|
||||||
|
@ -85,7 +85,10 @@ class MockIdentityService(val identities: List<Party>) : IdentityService, Single
|
|||||||
private val nameToParties: Map<String, Party>
|
private val nameToParties: Map<String, Party>
|
||||||
get() = synchronized(identities) { identities.associateBy { it.name } }
|
get() = synchronized(identities) { identities.associateBy { it.name } }
|
||||||
|
|
||||||
override fun registerIdentity(party: Party) { throw UnsupportedOperationException() }
|
override fun registerIdentity(party: Party) {
|
||||||
|
throw UnsupportedOperationException()
|
||||||
|
}
|
||||||
|
|
||||||
override fun getAllIdentities(): Iterable<Party> = ArrayList(keyToParties.values)
|
override fun getAllIdentities(): Iterable<Party> = ArrayList(keyToParties.values)
|
||||||
override fun partyFromAnonymous(party: AnonymousParty): Party? = keyToParties[party.owningKey]
|
override fun partyFromAnonymous(party: AnonymousParty): Party? = keyToParties[party.owningKey]
|
||||||
override fun partyFromAnonymous(partyRef: PartyAndReference): Party? = partyFromAnonymous(partyRef.party)
|
override fun partyFromAnonymous(partyRef: PartyAndReference): Party? = partyFromAnonymous(partyRef.party)
|
||||||
|
@ -6,8 +6,8 @@ import com.google.common.util.concurrent.SettableFuture
|
|||||||
import net.corda.core.crypto.composite
|
import net.corda.core.crypto.composite
|
||||||
import net.corda.core.crypto.generateKeyPair
|
import net.corda.core.crypto.generateKeyPair
|
||||||
import net.corda.core.messaging.RPCOps
|
import net.corda.core.messaging.RPCOps
|
||||||
import net.corda.testing.MOCK_NODE_VERSION_INFO
|
|
||||||
import net.corda.node.services.RPCUserServiceImpl
|
import net.corda.node.services.RPCUserServiceImpl
|
||||||
|
import net.corda.node.services.api.MonitoringService
|
||||||
import net.corda.node.services.config.NodeConfiguration
|
import net.corda.node.services.config.NodeConfiguration
|
||||||
import net.corda.node.services.messaging.ArtemisMessagingServer
|
import net.corda.node.services.messaging.ArtemisMessagingServer
|
||||||
import net.corda.node.services.messaging.NodeMessagingClient
|
import net.corda.node.services.messaging.NodeMessagingClient
|
||||||
@ -15,12 +15,12 @@ import net.corda.node.services.network.InMemoryNetworkMapCache
|
|||||||
import net.corda.node.utilities.AffinityExecutor.ServiceAffinityExecutor
|
import net.corda.node.utilities.AffinityExecutor.ServiceAffinityExecutor
|
||||||
import net.corda.node.utilities.configureDatabase
|
import net.corda.node.utilities.configureDatabase
|
||||||
import net.corda.node.utilities.databaseTransaction
|
import net.corda.node.utilities.databaseTransaction
|
||||||
|
import net.corda.testing.MOCK_NODE_VERSION_INFO
|
||||||
import net.corda.testing.freeLocalHostAndPort
|
import net.corda.testing.freeLocalHostAndPort
|
||||||
import org.jetbrains.exposed.sql.Database
|
import org.jetbrains.exposed.sql.Database
|
||||||
import java.io.Closeable
|
import java.io.Closeable
|
||||||
import java.security.KeyPair
|
import java.security.KeyPair
|
||||||
import kotlin.concurrent.thread
|
import kotlin.concurrent.thread
|
||||||
import net.corda.node.services.api.MonitoringService
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a bare-bones node which can only send and receive messages. It doesn't register with a network map service or
|
* This is a bare-bones node which can only send and receive messages. It doesn't register with a network map service or
|
||||||
@ -51,7 +51,9 @@ class SimpleNode(val config: NodeConfiguration, val address: HostAndPort = freeL
|
|||||||
fun start() {
|
fun start() {
|
||||||
broker.start()
|
broker.start()
|
||||||
net.start(
|
net.start(
|
||||||
object : RPCOps { override val protocolVersion = 0 },
|
object : RPCOps {
|
||||||
|
override val protocolVersion = 0
|
||||||
|
},
|
||||||
userService)
|
userService)
|
||||||
thread(name = config.myLegalName) {
|
thread(name = config.myLegalName) {
|
||||||
net.run()
|
net.run()
|
||||||
|
Reference in New Issue
Block a user