mirror of
https://github.com/corda/corda.git
synced 2025-06-17 14:48:16 +00:00
Minor changes made in ENT which should have been ported over (#3932)
This commit is contained in:
@ -10,6 +10,8 @@ import net.corda.core.utilities.ProgressTracker
|
||||
import net.corda.core.utilities.getOrThrow
|
||||
import net.corda.core.utilities.unwrap
|
||||
import net.corda.node.services.Permissions
|
||||
import net.corda.testing.core.ALICE_NAME
|
||||
import net.corda.testing.core.BOB_NAME
|
||||
import net.corda.testing.core.singleIdentity
|
||||
import net.corda.testing.driver.DriverParameters
|
||||
import net.corda.testing.driver.driver
|
||||
@ -38,8 +40,8 @@ class FlowRetryTest {
|
||||
startNodesInProcess = isQuasarAgentSpecified(),
|
||||
notarySpecs = emptyList()
|
||||
)) {
|
||||
val nodeAHandle = startNode(rpcUsers = listOf(user)).getOrThrow()
|
||||
val nodeBHandle = startNode(rpcUsers = listOf(user)).getOrThrow()
|
||||
val nodeAHandle = startNode(providedName = ALICE_NAME, rpcUsers = listOf(user)).getOrThrow()
|
||||
val nodeBHandle = startNode(providedName = BOB_NAME, rpcUsers = listOf(user)).getOrThrow()
|
||||
|
||||
val result = CordaRPCClient(nodeAHandle.rpcAddress).start(user.username, user.password).use {
|
||||
it.proxy.startFlow(::InitiatorFlow, numSessions, numIterations, nodeBHandle.nodeInfo.singleIdentity()).returnValue.getOrThrow()
|
||||
@ -66,7 +68,7 @@ class InitiatorFlow(private val sessionsCount: Int, private val iterationsCount:
|
||||
|
||||
fun tracker() = ProgressTracker(FIRST_STEP)
|
||||
|
||||
val seen = Collections.synchronizedSet(HashSet<Visited>())
|
||||
val seen: MutableSet<Visited> = Collections.synchronizedSet(HashSet<Visited>())
|
||||
|
||||
fun visit(sessionNum: Int, iterationNum: Int, step: Step) {
|
||||
val visited = Visited(sessionNum, iterationNum, step)
|
||||
@ -117,7 +119,7 @@ class InitiatedFlow(val session: FlowSession) : FlowLogic<Any>() {
|
||||
|
||||
fun tracker() = ProgressTracker(FIRST_STEP)
|
||||
|
||||
val seen = Collections.synchronizedSet(HashSet<Visited>())
|
||||
val seen: MutableSet<Visited> = Collections.synchronizedSet(HashSet<Visited>())
|
||||
|
||||
fun visit(sessionNum: Int, iterationNum: Int, step: Step) {
|
||||
val visited = Visited(sessionNum, iterationNum, step)
|
||||
@ -154,4 +156,4 @@ data class SessionInfo(val sessionNum: Int, val iterationsCount: Int)
|
||||
|
||||
enum class Step { First, BeforeInitiate, AfterInitiate, AfterInitiateSendReceive, BeforeSend, AfterSend, BeforeReceive, AfterReceive }
|
||||
|
||||
data class Visited(val sessionNum: Int, val iterationNum: Int, val step: Step)
|
||||
data class Visited(val sessionNum: Int, val iterationNum: Int, val step: Step)
|
||||
|
@ -6,8 +6,8 @@ import net.corda.core.flows.*
|
||||
import net.corda.core.identity.Party
|
||||
import net.corda.core.internal.concurrent.map
|
||||
import net.corda.core.messaging.startFlow
|
||||
import net.corda.core.utilities.contextLogger
|
||||
import net.corda.core.utilities.getOrThrow
|
||||
import net.corda.core.utilities.loggerFor
|
||||
import net.corda.core.utilities.unwrap
|
||||
import net.corda.node.services.Permissions
|
||||
import net.corda.testing.core.ALICE_NAME
|
||||
@ -29,6 +29,9 @@ import java.util.concurrent.TimeUnit
|
||||
import kotlin.test.fail
|
||||
|
||||
class P2PFlowsDrainingModeTest {
|
||||
companion object {
|
||||
private val logger = contextLogger()
|
||||
}
|
||||
|
||||
private val portAllocation = PortAllocation.Incremental(10000)
|
||||
private val user = User("mark", "dadada", setOf(Permissions.all()))
|
||||
@ -36,10 +39,6 @@ class P2PFlowsDrainingModeTest {
|
||||
|
||||
private var executor: ScheduledExecutorService? = null
|
||||
|
||||
companion object {
|
||||
private val logger = loggerFor<P2PFlowsDrainingModeTest>()
|
||||
}
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
executor = Executors.newSingleThreadScheduledExecutor()
|
||||
|
@ -116,4 +116,4 @@ class ScheduledFlowIntegrationTests {
|
||||
assertEquals(aliceSpentStates.count(), bobSpentStates.count())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,10 @@ import kotlin.concurrent.thread
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class HardRestartTest {
|
||||
companion object {
|
||||
val logConfigFile = ProjectStructure.projectRootDir / "config" / "dev" / "log4j2.xml"
|
||||
}
|
||||
|
||||
@StartableByRPC
|
||||
@InitiatingFlow
|
||||
class Ping(private val pongParty: Party, val times: Int) : FlowLogic<Unit>() {
|
||||
@ -54,10 +58,6 @@ class HardRestartTest {
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
val logConfigFile = ProjectStructure.projectRootDir / "config" / "dev" / "log4j2.xml"
|
||||
}
|
||||
|
||||
@Test
|
||||
fun restartShortPingPongFlowRandomly() {
|
||||
val demoUser = User("demo", "demo", setOf(Permissions.startFlow<Ping>(), Permissions.all()))
|
||||
@ -257,4 +257,4 @@ class HardRestartTest {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,10 @@ class P2PMessagingTest {
|
||||
}
|
||||
|
||||
private fun startDriverWithDistributedService(dsl: DriverDSL.(List<InProcess>) -> Unit) {
|
||||
driver(DriverParameters(startNodesInProcess = true, notarySpecs = listOf(NotarySpec(DISTRIBUTED_SERVICE_NAME, cluster = ClusterSpec.Raft(clusterSize = 2))))) {
|
||||
driver(DriverParameters(
|
||||
startNodesInProcess = true,
|
||||
notarySpecs = listOf(NotarySpec(DISTRIBUTED_SERVICE_NAME, cluster = ClusterSpec.Raft(clusterSize = 2)))
|
||||
)) {
|
||||
dsl(defaultNotaryHandle.nodeHandles.getOrThrow().map { (it as InProcess) })
|
||||
}
|
||||
}
|
||||
|
@ -11,4 +11,4 @@ fun main(args: Array<String>) {
|
||||
// It will exit the process in case of startup failure and is not intended to be used by embedders. If you want
|
||||
// to embed Node in your own container, instantiate it directly and set up the configuration objects yourself.
|
||||
NodeStartup().start(args)
|
||||
}
|
||||
}
|
||||
|
@ -12,4 +12,3 @@ sealed class InitiatedFlowFactory<out F : FlowLogic<*>> {
|
||||
val appName: String,
|
||||
override val factory: (FlowSession) -> F) : InitiatedFlowFactory<F>()
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,6 @@ class PersistentKeyManagementService(val identityService: PersistentIdentityServ
|
||||
@Entity
|
||||
@javax.persistence.Table(name = "${NODE_DATABASE_PREFIX}our_key_pairs")
|
||||
class PersistentKey(
|
||||
|
||||
@Id
|
||||
@Column(name = "public_key_hash", length = MAX_HASH_HEX_SIZE, nullable = false)
|
||||
var publicKeyHash: String,
|
||||
@ -51,8 +50,7 @@ class PersistentKeyManagementService(val identityService: PersistentIdentityServ
|
||||
return AppendOnlyPersistentMap(
|
||||
"PersistentKeyManagementService_keys",
|
||||
toPersistentEntityKey = { it.toStringShort() },
|
||||
fromPersistentEntity = { Pair(Crypto.decodePublicKey(it.publicKey), Crypto.decodePrivateKey(
|
||||
it.privateKey)) },
|
||||
fromPersistentEntity = { Pair(Crypto.decodePublicKey(it.publicKey), Crypto.decodePrivateKey(it.privateKey)) },
|
||||
toPersistentEntity = { key: PublicKey, value: PrivateKey ->
|
||||
PersistentKey(key, value)
|
||||
},
|
||||
|
@ -336,6 +336,7 @@ class RPCServer(
|
||||
context.invocation.pushToLoggingContext()
|
||||
when (arguments) {
|
||||
is Try.Success -> {
|
||||
log.debug { "Arguments: ${arguments.value.toTypedArray().contentDeepToString()}" }
|
||||
rpcExecutor!!.submit {
|
||||
val result = invokeRpc(context, clientToServer.methodName, arguments.value)
|
||||
sendReply(clientToServer.replyId, clientToServer.clientAddress, result)
|
||||
|
@ -65,7 +65,7 @@ class DBCheckpointStorage : CheckpointStorage {
|
||||
|
||||
override fun getCheckpoint(id: StateMachineRunId): SerializedBytes<Checkpoint>? {
|
||||
val bytes = currentDBSession().get(DBCheckpoint::class.java, id.uuid.toString())?.checkpoint ?: return null
|
||||
return SerializedBytes<Checkpoint>(bytes)
|
||||
return SerializedBytes(bytes)
|
||||
}
|
||||
|
||||
override fun getAllCheckpoints(): Stream<Pair<StateMachineRunId, SerializedBytes<Checkpoint>>> {
|
||||
@ -78,8 +78,8 @@ class DBCheckpointStorage : CheckpointStorage {
|
||||
}
|
||||
}
|
||||
|
||||
override fun getCheckpointCount(connection: Connection): Long =
|
||||
try {
|
||||
override fun getCheckpointCount(connection: Connection): Long {
|
||||
return try {
|
||||
connection.prepareStatement("select count(*) from node_checkpoints").use { ps ->
|
||||
ps.executeQuery().use { rs ->
|
||||
rs.next()
|
||||
@ -90,5 +90,5 @@ class DBCheckpointStorage : CheckpointStorage {
|
||||
// Happens when the table was not created yet.
|
||||
0L
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -366,4 +366,4 @@ class KryoTests(private val compression: CordaSerializationEncoding?) {
|
||||
assertEquals(20222, uncompressedSize)
|
||||
assertEquals(1111, compressedSize)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,9 @@ package net.corda.node.services.network
|
||||
|
||||
import net.corda.core.crypto.generateKeyPair
|
||||
import net.corda.core.node.services.NetworkMapCache
|
||||
import net.corda.node.services.api.NetworkMapCacheInternal
|
||||
import net.corda.testing.core.ALICE_NAME
|
||||
import net.corda.testing.core.BOB_NAME
|
||||
import net.corda.node.services.api.NetworkMapCacheInternal
|
||||
import net.corda.testing.core.getTestPartyAndCertificate
|
||||
import net.corda.testing.core.singleIdentity
|
||||
import net.corda.testing.node.internal.InternalMockNetwork
|
||||
|
Reference in New Issue
Block a user