mirror of
https://github.com/corda/corda.git
synced 2025-06-11 03:41:41 +00:00
Minor: address more formatting issues spotted by Shams
This commit is contained in:
parent
4853e41a58
commit
0c0c5521c0
@ -24,8 +24,7 @@ import org.junit.Before
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.concurrent.locks.ReentrantLock
|
import java.util.concurrent.locks.ReentrantLock
|
||||||
|
|
||||||
abstract class AbstractClientRPC {
|
abstract class AbstractClientRPCTest {
|
||||||
|
|
||||||
lateinit var artemis: EmbeddedActiveMQ
|
lateinit var artemis: EmbeddedActiveMQ
|
||||||
lateinit var serverSession: ClientSession
|
lateinit var serverSession: ClientSession
|
||||||
lateinit var clientSession: ClientSession
|
lateinit var clientSession: ClientSession
|
||||||
@ -93,8 +92,10 @@ abstract class AbstractClientRPC {
|
|||||||
return CordaRPCClientImpl(clientSession, ReentrantLock(), rpcUser.username).proxyFor(type)
|
return CordaRPCClientImpl(clientSession, ReentrantLock(), rpcUser.username).proxyFor(type)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun safeClose(obj: Any) = try {
|
fun safeClose(obj: Any) {
|
||||||
|
try {
|
||||||
(obj as AutoCloseable).close()
|
(obj as AutoCloseable).close()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -23,7 +23,7 @@ import kotlin.test.assertEquals
|
|||||||
import kotlin.test.assertFailsWith
|
import kotlin.test.assertFailsWith
|
||||||
import kotlin.test.assertTrue
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
class ClientRPCInfrastructureTests : AbstractClientRPC() {
|
class ClientRPCInfrastructureTests : AbstractClientRPCTest() {
|
||||||
// TODO: Test that timeouts work
|
// TODO: Test that timeouts work
|
||||||
|
|
||||||
lateinit var proxy: TestOps
|
lateinit var proxy: TestOps
|
||||||
|
@ -8,7 +8,7 @@ import org.junit.After
|
|||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import kotlin.test.assertFailsWith
|
import kotlin.test.assertFailsWith
|
||||||
|
|
||||||
class RPCPermissionsTest : AbstractClientRPC() {
|
class RPCPermissionsTest : AbstractClientRPCTest() {
|
||||||
companion object {
|
companion object {
|
||||||
const val DUMMY_FLOW = "StartFlow.net.corda.flows.DummyFlow"
|
const val DUMMY_FLOW = "StartFlow.net.corda.flows.DummyFlow"
|
||||||
const val OTHER_FLOW = "StartFlow.net.corda.flows.OtherFlow"
|
const val OTHER_FLOW = "StartFlow.net.corda.flows.OtherFlow"
|
||||||
|
@ -10,30 +10,13 @@ import java.time.Instant
|
|||||||
* UTC zone offset.
|
* UTC zone offset.
|
||||||
*/
|
*/
|
||||||
class InstantConverter : Converter<Instant, Timestamp> {
|
class InstantConverter : Converter<Instant, Timestamp> {
|
||||||
|
override fun getMappedType() = Instant::class.java
|
||||||
|
|
||||||
override fun getMappedType(): Class<Instant> {
|
override fun getPersistedType() = Timestamp::class.java
|
||||||
return Instant::class.java
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getPersistedType(): Class<Timestamp> {
|
override fun getPersistedSize() = null
|
||||||
return Timestamp::class.java
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getPersistedSize(): Int? {
|
override fun convertToPersisted(value: Instant?) = value?.let { Timestamp.from(it) }
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun convertToPersisted(value: Instant?): Timestamp? {
|
override fun convertToMapped(type: Class<out Instant>, value: Timestamp?) = value?.toInstant()
|
||||||
if (value == null) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
return Timestamp.from(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun convertToMapped(type: Class<out Instant>, value: Timestamp?): Instant? {
|
|
||||||
if (value == null) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
return value.toInstant()
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -8,31 +8,14 @@ import net.corda.core.crypto.SecureHash
|
|||||||
* Converts from a [StateRef] to a Composite Key defined by a [String] txnHash and an [Int] index
|
* Converts from a [StateRef] to a Composite Key defined by a [String] txnHash and an [Int] index
|
||||||
*/
|
*/
|
||||||
class StateRefConverter : Converter<StateRef, Pair<String, Int>> {
|
class StateRefConverter : Converter<StateRef, Pair<String, Int>> {
|
||||||
|
override fun getMappedType() = StateRef::class.java
|
||||||
override fun getMappedType(): Class<StateRef> {
|
|
||||||
return StateRef::class.java
|
|
||||||
}
|
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
override fun getPersistedType(): Class<Pair<String, Int>> {
|
override fun getPersistedType() = Pair::class.java as Class<Pair<String, Int>>
|
||||||
return Pair::class.java as Class<Pair<String, Int>>
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getPersistedSize(): Int? {
|
override fun getPersistedSize() = null
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun convertToPersisted(value: StateRef?): Pair<String, Int>? {
|
override fun convertToPersisted(value: StateRef?) = value?.let { Pair(it.txhash.toString(), it.index) }
|
||||||
if (value == null) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
return Pair(value.txhash.toString(), value.index)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun convertToMapped(type: Class<out StateRef>, value: Pair<String, Int>?): StateRef? {
|
override fun convertToMapped(type: Class<out StateRef>, value: Pair<String, Int>?) = value?.let { StateRef(SecureHash.parse(it.first), it.second) }
|
||||||
if (value == null) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
return StateRef(SecureHash.parse(value.first), value.second)
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -144,7 +144,6 @@ object TwoPartyTradeFlow {
|
|||||||
val typeToBuy: Class<out OwnableState>) : FlowLogic<SignedTransaction>() {
|
val typeToBuy: Class<out OwnableState>) : FlowLogic<SignedTransaction>() {
|
||||||
// DOCSTART 2
|
// DOCSTART 2
|
||||||
object RECEIVING : ProgressTracker.Step("Waiting for seller trading info")
|
object RECEIVING : ProgressTracker.Step("Waiting for seller trading info")
|
||||||
|
|
||||||
object VERIFYING : ProgressTracker.Step("Verifying seller assets")
|
object VERIFYING : ProgressTracker.Step("Verifying seller assets")
|
||||||
object SIGNING : ProgressTracker.Step("Generating and signing transaction proposal")
|
object SIGNING : ProgressTracker.Step("Generating and signing transaction proposal")
|
||||||
object SENDING_SIGNATURES : ProgressTracker.Step("Sending signatures to the seller")
|
object SENDING_SIGNATURES : ProgressTracker.Step("Sending signatures to the seller")
|
||||||
|
@ -28,6 +28,7 @@ import org.junit.Assert
|
|||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
|
import sun.misc.MessageUtils.where
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.concurrent.CountDownLatch
|
import java.util.concurrent.CountDownLatch
|
||||||
|
@ -217,8 +217,7 @@ private fun drawBanner(nodeVersionInfo: NodeVersionInfo) {
|
|||||||
Emoji.renderIfSupported {
|
Emoji.renderIfSupported {
|
||||||
val (msg1, msg2) = messageOfTheDay()
|
val (msg1, msg2) = messageOfTheDay()
|
||||||
|
|
||||||
println(Ansi.ansi().fgBrightRed().a(
|
println(Ansi.ansi().fgBrightRed().a("""
|
||||||
"""
|
|
||||||
______ __
|
______ __
|
||||||
/ ____/ _________/ /___ _
|
/ ____/ _________/ /___ _
|
||||||
/ / __ / ___/ __ / __ `/ """).fgBrightBlue().a(msg1).newline().fgBrightRed().a(
|
/ / __ / ___/ __ / __ `/ """).fgBrightBlue().a(msg1).newline().fgBrightRed().a(
|
||||||
|
@ -5,6 +5,7 @@ import net.corda.core.flows.FlowLogic
|
|||||||
import net.corda.core.flows.StateMachineRunId
|
import net.corda.core.flows.StateMachineRunId
|
||||||
import net.corda.core.node.services.VaultService
|
import net.corda.core.node.services.VaultService
|
||||||
import net.corda.core.utilities.loggerFor
|
import net.corda.core.utilities.loggerFor
|
||||||
|
import net.corda.core.utilities.trace
|
||||||
import net.corda.node.services.statemachine.StateMachineManager
|
import net.corda.node.services.statemachine.StateMachineManager
|
||||||
import net.corda.node.utilities.AddOrRemove
|
import net.corda.node.utilities.AddOrRemove
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@ -20,7 +21,7 @@ class VaultSoftLockManager(val vault: VaultService, smm: StateMachineManager) {
|
|||||||
init {
|
init {
|
||||||
smm.changes.subscribe { change ->
|
smm.changes.subscribe { change ->
|
||||||
if (change.addOrRemove == AddOrRemove.REMOVE && trackingFlowIds.contains(change.id.uuid)) {
|
if (change.addOrRemove == AddOrRemove.REMOVE && trackingFlowIds.contains(change.id.uuid)) {
|
||||||
log.trace("${change.addOrRemove} Flow name ${change.logic.javaClass} with id ${change.id}")
|
log.trace { "${change.addOrRemove} Flow name ${change.logic.javaClass} with id ${change.id}" }
|
||||||
unregisterSoftLocks(change.id, change.logic)
|
unregisterSoftLocks(change.id, change.logic)
|
||||||
}
|
}
|
||||||
trackingFlowIds.remove(change.id.uuid)
|
trackingFlowIds.remove(change.id.uuid)
|
||||||
|
@ -373,7 +373,7 @@ class NodeVaultServiceTest {
|
|||||||
val spendableStatesUSD = (services.vaultService as NodeVaultService).unconsumedStatesForSpending<Cash.State>(1.DOLLARS, lockId = UUID.randomUUID())
|
val spendableStatesUSD = (services.vaultService as NodeVaultService).unconsumedStatesForSpending<Cash.State>(1.DOLLARS, lockId = UUID.randomUUID())
|
||||||
spendableStatesUSD.forEach(::println)
|
spendableStatesUSD.forEach(::println)
|
||||||
assertThat(spendableStatesUSD).hasSize(1)
|
assertThat(spendableStatesUSD).hasSize(1)
|
||||||
assertThat(spendableStatesUSD[0].state.data.amount.quantity).isGreaterThanOrEqualTo(1L * 100)
|
assertThat(spendableStatesUSD[0].state.data.amount.quantity).isGreaterThanOrEqualTo(100L)
|
||||||
assertThat(services.vaultService.softLockedStates<Cash.State>()).hasSize(1)
|
assertThat(services.vaultService.softLockedStates<Cash.State>()).hasSize(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,8 +75,6 @@ private class BankOfCordaDriver {
|
|||||||
if (result)
|
if (result)
|
||||||
println("Successfully processed Cash Issue request")
|
println("Successfully processed Cash Issue request")
|
||||||
}
|
}
|
||||||
Role.ISSUER -> {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
println("Exception occurred: $e \n ${e.printStackTrace()}")
|
println("Exception occurred: $e \n ${e.printStackTrace()}")
|
||||||
|
@ -12,8 +12,6 @@ class BankOfCordaPlugin : CordaPluginRegistry() {
|
|||||||
// A list of classes that expose web APIs.
|
// A list of classes that expose web APIs.
|
||||||
override val webApis = listOf(Function(::BankOfCordaWebApi))
|
override val webApis = listOf(Function(::BankOfCordaWebApi))
|
||||||
// A list of flow that are required for this cordapp
|
// A list of flow that are required for this cordapp
|
||||||
override val requiredFlows: Map<String, Set<String>> =
|
override val requiredFlows: Map<String, Set<String>> = mapOf(IssuerFlow.IssuanceRequester::class.java.name to setOf(Amount::class.java.name, Party::class.java.name, OpaqueBytes::class.java.name, Party::class.java.name))
|
||||||
mapOf(IssuerFlow.IssuanceRequester::class.java.name to setOf(Amount::class.java.name, Party::class.java.name, OpaqueBytes::class.java.name, Party::class.java.name)
|
|
||||||
)
|
|
||||||
override val servicePlugins = listOf(Function(IssuerFlow.Issuer::Service))
|
override val servicePlugins = listOf(Function(IssuerFlow.Issuer::Service))
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,6 @@ import java.util.function.Function
|
|||||||
|
|
||||||
class ExplorerPlugin : CordaPluginRegistry() {
|
class ExplorerPlugin : CordaPluginRegistry() {
|
||||||
// A list of flow that are required for this cordapp
|
// A list of flow that are required for this cordapp
|
||||||
override val requiredFlows: Map<String, Set<String>> =
|
override val requiredFlows: Map<String, Set<String>> = mapOf(IssuerFlow.IssuanceRequester::class.java.name to setOf(Amount::class.java.name, Party::class.java.name, OpaqueBytes::class.java.name, Party::class.java.name))
|
||||||
mapOf(IssuerFlow.IssuanceRequester::class.java.name to setOf(Amount::class.java.name, Party::class.java.name, OpaqueBytes::class.java.name, Party::class.java.name)
|
|
||||||
)
|
|
||||||
override val servicePlugins = listOf(Function(IssuerFlow.Issuer::Service))
|
override val servicePlugins = listOf(Function(IssuerFlow.Issuer::Service))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user