Minor: auto-format of module: node

This commit is contained in:
Mike Hearn
2017-04-11 12:42:53 +02:00
parent 3a7bcee15b
commit d6af727751
32 changed files with 130 additions and 111 deletions

View File

@ -9,8 +9,8 @@ import net.corda.core.readLines
import net.corda.node.LOGS_DIRECTORY_NAME import net.corda.node.LOGS_DIRECTORY_NAME
import net.corda.node.services.api.RegulatorService import net.corda.node.services.api.RegulatorService
import net.corda.node.services.transactions.SimpleNotaryService import net.corda.node.services.transactions.SimpleNotaryService
import org.assertj.core.api.Assertions.assertThat
import net.corda.nodeapi.ArtemisMessagingComponent import net.corda.nodeapi.ArtemisMessagingComponent
import org.assertj.core.api.Assertions.assertThat
import org.junit.Test import org.junit.Test
import java.nio.file.Paths import java.nio.file.Paths
import java.util.concurrent.Executors import java.util.concurrent.Executors

View File

@ -1,4 +1,5 @@
@file:JvmName("Corda") @file:JvmName("Corda")
package net.corda.node package net.corda.node
import com.jcabi.manifests.Manifests import com.jcabi.manifests.Manifests
@ -116,7 +117,7 @@ fun main(args: Array<String>) {
log.info("Machine: ${InetAddress.getLocalHost().hostName}") log.info("Machine: ${InetAddress.getLocalHost().hostName}")
log.info("Working Directory: ${cmdlineOptions.baseDirectory}") log.info("Working Directory: ${cmdlineOptions.baseDirectory}")
val agentProperties = sun.misc.VMSupport.getAgentProperties() val agentProperties = sun.misc.VMSupport.getAgentProperties()
if(agentProperties.containsKey("sun.jdwp.listenerAddress")) { if (agentProperties.containsKey("sun.jdwp.listenerAddress")) {
log.info("Debug port: ${agentProperties.getProperty("sun.jdwp.listenerAddress")}") log.info("Debug port: ${agentProperties.getProperty("sun.jdwp.listenerAddress")}")
} }
log.info("Starting as node on ${conf.p2pAddress}") log.info("Starting as node on ${conf.p2pAddress}")
@ -172,7 +173,7 @@ private fun printPluginsAndServices(node: Node) {
} }
val plugins = node.pluginRegistries val plugins = node.pluginRegistries
.map { it.javaClass.name } .map { it.javaClass.name }
.filterNot { it.startsWith("net.corda.node.") || it.startsWith("net.corda.core.") || it.startsWith("net.corda.nodeapi.")} .filterNot { it.startsWith("net.corda.node.") || it.startsWith("net.corda.core.") || it.startsWith("net.corda.nodeapi.") }
.map { it.substringBefore('$') } .map { it.substringBefore('$') }
if (plugins.isNotEmpty()) if (plugins.isNotEmpty())
printBasicNodeInfo("Loaded plugins", plugins.joinToString()) printBasicNodeInfo("Loaded plugins", plugins.joinToString())
@ -217,7 +218,7 @@ private fun drawBanner(nodeVersionInfo: NodeVersionInfo) {
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(

View File

@ -1,4 +1,5 @@
@file:JvmName("Driver") @file:JvmName("Driver")
package net.corda.node.driver package net.corda.node.driver
import com.google.common.net.HostAndPort import com.google.common.net.HostAndPort
@ -287,6 +288,7 @@ class ShutdownManager(private val executorService: ExecutorService) {
val registeredShutdowns = ArrayList<ListenableFuture<() -> Unit>>() val registeredShutdowns = ArrayList<ListenableFuture<() -> Unit>>()
var isShutdown = false var isShutdown = false
} }
private val state = ThreadBox(State()) private val state = ThreadBox(State())
fun shutdown() { fun shutdown() {
@ -302,7 +304,7 @@ class ShutdownManager(private val executorService: ExecutorService) {
/** Could not get all of them, collect what we have */ /** Could not get all of them, collect what we have */
shutdownFutures.filter { it.isDone }.map { it.get() } shutdownFutures.filter { it.isDone }.map { it.get() }
} }
shutdowns.reversed().forEach{ it() } shutdowns.reversed().forEach { it() }
} }
fun registerShutdown(shutdown: ListenableFuture<() -> Unit>) { fun registerShutdown(shutdown: ListenableFuture<() -> Unit>) {
@ -432,9 +434,9 @@ class DriverDSL(
) + customOverrides ) + customOverrides
val config = ConfigHelper.loadConfig( val config = ConfigHelper.loadConfig(
baseDirectory = baseDirectory, baseDirectory = baseDirectory,
allowMissingConfig = true, allowMissingConfig = true,
configOverrides = configOverrides) configOverrides = configOverrides)
val configuration = config.parseAs<FullNodeConfiguration>() val configuration = config.parseAs<FullNodeConfiguration>()
val processFuture = startNode(executorService, configuration, config, quasarJarPath, debugPort, systemProperties) val processFuture = startNode(executorService, configuration, config, quasarJarPath, debugPort, systemProperties)

View File

@ -199,10 +199,12 @@ abstract class AbstractNode(open val configuration: NodeConfiguration,
log.warn("Corda node is running in dev mode.") log.warn("Corda node is running in dev mode.")
configuration.configureWithDevSSLCertificate() configuration.configureWithDevSSLCertificate()
} }
require(hasSSLCertificates()) { "Identity certificate not found. " + require(hasSSLCertificates()) {
"Please either copy your existing identity key and certificate from another node, " + "Identity certificate not found. " +
"or if you don't have one yet, fill out the config file and run corda.jar --initial-registration. " + "Please either copy your existing identity key and certificate from another node, " +
"Read more at: https://docs.corda.net/permissioning.html" } "or if you don't have one yet, fill out the config file and run corda.jar --initial-registration. " +
"Read more at: https://docs.corda.net/permissioning.html"
}
log.info("Node starting up ...") log.info("Node starting up ...")
@ -487,7 +489,7 @@ abstract class AbstractNode(open val configuration: NodeConfiguration,
protected open fun makeSchemaService(): SchemaService = NodeSchemaService() protected open fun makeSchemaService(): SchemaService = NodeSchemaService()
protected abstract fun makeTransactionVerifierService() : TransactionVerifierService protected abstract fun makeTransactionVerifierService(): TransactionVerifierService
open fun stop() { open fun stop() {
// TODO: We need a good way of handling "nice to have" shutdown events, especially those that deal with the // TODO: We need a good way of handling "nice to have" shutdown events, especially those that deal with the

View File

@ -111,7 +111,7 @@ class CordaRPCOpsImpl(
override fun attachmentExists(id: SecureHash): Boolean { override fun attachmentExists(id: SecureHash): Boolean {
// TODO: this operation should not require an explicit transaction // TODO: this operation should not require an explicit transaction
return databaseTransaction(database){ return databaseTransaction(database) {
services.storageService.attachments.openAttachment(id) != null services.storageService.attachments.openAttachment(id) != null
} }
} }
@ -125,10 +125,11 @@ class CordaRPCOpsImpl(
override fun uploadAttachment(jar: InputStream): SecureHash { override fun uploadAttachment(jar: InputStream): SecureHash {
// TODO: this operation should not require an explicit transaction // TODO: this operation should not require an explicit transaction
return databaseTransaction(database){ return databaseTransaction(database) {
services.storageService.attachments.importAttachment(jar) services.storageService.attachments.importAttachment(jar)
} }
} }
override fun authoriseContractUpgrade(state: StateAndRef<*>, upgradedContractClass: Class<out UpgradedContract<*, *>>) = services.vaultService.authoriseContractUpgrade(state, upgradedContractClass) override fun authoriseContractUpgrade(state: StateAndRef<*>, upgradedContractClass: Class<out UpgradedContract<*, *>>) = services.vaultService.authoriseContractUpgrade(state, upgradedContractClass)
override fun deauthoriseContractUpgrade(state: StateAndRef<*>) = services.vaultService.deauthoriseContractUpgrade(state) override fun deauthoriseContractUpgrade(state: StateAndRef<*>) = services.vaultService.deauthoriseContractUpgrade(state)
override fun currentNodeTime(): Instant = Instant.now(services.clock) override fun currentNodeTime(): Instant = Instant.now(services.clock)

View File

@ -23,10 +23,9 @@ import net.corda.node.services.config.FullNodeConfiguration
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
import net.corda.node.services.transactions.PersistentUniquenessProvider import net.corda.node.services.transactions.PersistentUniquenessProvider
import net.corda.node.services.transactions.RaftNonValidatingNotaryService
import net.corda.node.services.transactions.RaftUniquenessProvider import net.corda.node.services.transactions.RaftUniquenessProvider
import net.corda.node.services.transactions.RaftValidatingNotaryService import net.corda.node.services.transactions.RaftValidatingNotaryService
import net.corda.node.services.transactions.RaftNonValidatingNotaryService
import net.corda.node.services.transactions.*
import net.corda.node.utilities.AddressUtils import net.corda.node.utilities.AddressUtils
import net.corda.node.utilities.AffinityExecutor import net.corda.node.utilities.AffinityExecutor
import net.corda.nodeapi.ArtemisMessagingComponent.NetworkMapAddress import net.corda.nodeapi.ArtemisMessagingComponent.NetworkMapAddress

View File

@ -7,7 +7,7 @@ import net.corda.core.node.services.FileUploader
* *
* TODO: In future, also accept uploads over the MQ interface too. * TODO: In future, also accept uploads over the MQ interface too.
*/ */
interface AcceptsFileUpload: FileUploader { interface AcceptsFileUpload : FileUploader {
/** A string that prefixes the URLs, e.g. "attachments" or "interest-rates". Should be OK for URLs. */ /** A string that prefixes the URLs, e.g. "attachments" or "interest-rates". Should be OK for URLs. */
val dataTypePrefix: String val dataTypePrefix: String

View File

@ -9,7 +9,10 @@ import io.requery.sql.*
import io.requery.sql.platform.H2 import io.requery.sql.platform.H2
import io.requery.util.function.Function import io.requery.util.function.Function
import io.requery.util.function.Supplier import io.requery.util.function.Supplier
import net.corda.core.schemas.requery.converters.* import net.corda.core.schemas.requery.converters.InstantConverter
import net.corda.core.schemas.requery.converters.SecureHashConverter
import net.corda.core.schemas.requery.converters.StateRefConverter
import net.corda.core.schemas.requery.converters.VaultStateStatusConverter
import org.jetbrains.exposed.sql.transactions.TransactionManager import org.jetbrains.exposed.sql.transactions.TransactionManager
import java.sql.Connection import java.sql.Connection
import java.util.* import java.util.*
@ -128,8 +131,7 @@ class KotlinConfigurationTransactionWrapper(private val model: EntityModel,
override fun getConnection(): Connection { override fun getConnection(): Connection {
val tx = TransactionManager.manager.currentOrNull() val tx = TransactionManager.manager.currentOrNull()
return CordaConnection( return CordaConnection(
tx?.connection ?: tx?.connection ?: TransactionManager.manager.newTransaction(Connection.TRANSACTION_REPEATABLE_READ).connection
TransactionManager.manager.newTransaction(Connection.TRANSACTION_REPEATABLE_READ).connection
) )
} }
} }

View File

@ -4,7 +4,9 @@ import com.zaxxer.hikari.HikariConfig
import com.zaxxer.hikari.HikariDataSource import com.zaxxer.hikari.HikariDataSource
import io.requery.Persistable import io.requery.Persistable
import io.requery.meta.EntityModel import io.requery.meta.EntityModel
import io.requery.sql.* import io.requery.sql.KotlinEntityDataStore
import io.requery.sql.SchemaModifier
import io.requery.sql.TableCreationMode
import net.corda.core.utilities.loggerFor import net.corda.core.utilities.loggerFor
import org.jetbrains.exposed.sql.transactions.TransactionManager import org.jetbrains.exposed.sql.transactions.TransactionManager
import java.sql.Connection import java.sql.Connection

View File

@ -104,6 +104,7 @@ class NodeMessagingClient(override val config: NodeConfiguration,
var rpcNotificationConsumer: ClientConsumer? = null var rpcNotificationConsumer: ClientConsumer? = null
var verificationResponseConsumer: ClientConsumer? = null var verificationResponseConsumer: ClientConsumer? = null
} }
val verifierService = when (config.verifierType) { val verifierService = when (config.verifierType) {
VerifierType.InMemory -> InMemoryTransactionVerifierService(numberOfWorkers = 4) VerifierType.InMemory -> InMemoryTransactionVerifierService(numberOfWorkers = 4)
VerifierType.OutOfProcess -> createOutOfProcessVerifierService() VerifierType.OutOfProcess -> createOutOfProcessVerifierService()
@ -421,8 +422,10 @@ class NodeMessagingClient(override val config: NodeConfiguration,
putLongProperty(HDR_SCHEDULED_DELIVERY_TIME, System.currentTimeMillis() + amqDelay) putLongProperty(HDR_SCHEDULED_DELIVERY_TIME, System.currentTimeMillis() + amqDelay)
} }
} }
log.trace { "Send to: $mqAddress topic: ${message.topicSession.topic} " + log.trace {
"sessionID: ${message.topicSession.sessionID} uuid: ${message.uniqueMessageId}" } "Send to: $mqAddress topic: ${message.topicSession.topic} " +
"sessionID: ${message.topicSession.sessionID} uuid: ${message.uniqueMessageId}"
}
producer!!.send(mqAddress, artemisMessage) producer!!.send(mqAddress, artemisMessage)
} }
} }
@ -499,19 +502,19 @@ class NodeMessagingClient(override val config: NodeConfiguration,
private fun createOutOfProcessVerifierService(): TransactionVerifierService { private fun createOutOfProcessVerifierService(): TransactionVerifierService {
return object : OutOfProcessTransactionVerifierService(monitoringService) { return object : OutOfProcessTransactionVerifierService(monitoringService) {
override fun sendRequest(nonce: Long, transaction: LedgerTransaction) { override fun sendRequest(nonce: Long, transaction: LedgerTransaction) {
messagingExecutor.fetchFrom { messagingExecutor.fetchFrom {
state.locked { state.locked {
val message = session!!.createMessage(false) val message = session!!.createMessage(false)
val request = VerifierApi.VerificationRequest(nonce, transaction, SimpleString(verifierResponseAddress)) val request = VerifierApi.VerificationRequest(nonce, transaction, SimpleString(verifierResponseAddress))
request.writeToClientMessage(message) request.writeToClientMessage(message)
producer!!.send(VERIFICATION_REQUESTS_QUEUE_NAME, message) producer!!.send(VERIFICATION_REQUESTS_QUEUE_NAME, message)
}
} }
} }
} }
} }
}
override fun getAddressOfParty(partyInfo: PartyInfo): MessageRecipients { override fun getAddressOfParty(partyInfo: PartyInfo): MessageRecipients {

View File

@ -70,7 +70,9 @@ abstract class RPCDispatcher(val ops: RPCOps, val userService: RPCUserService, v
// representing what happened, which is useful for us to send over the wire. // representing what happened, which is useful for us to send over the wire.
val subscription = obj.materialize().subscribe { materialised: Notification<out Any> -> val subscription = obj.materialize().subscribe { materialised: Notification<out Any> ->
val newKryo = createRPCKryoForSerialization(qName, dispatcher) val newKryo = createRPCKryoForSerialization(qName, dispatcher)
val bits = try { MarshalledObservation(handle, materialised).serialize(newKryo) } finally { val bits = try {
MarshalledObservation(handle, materialised).serialize(newKryo)
} finally {
releaseRPCKryoForSerialization(newKryo) releaseRPCKryoForSerialization(newKryo)
} }
rpcLog.debug("RPC sending observation: $materialised") rpcLog.debug("RPC sending observation: $materialised")
@ -91,7 +93,9 @@ abstract class RPCDispatcher(val ops: RPCOps, val userService: RPCUserService, v
throw RPCException("Received RPC without any destination for observations, but the RPC returns observables") throw RPCException("Received RPC without any destination for observations, but the RPC returns observables")
val kryo = createRPCKryoForSerialization(observationsTo, this) val kryo = createRPCKryoForSerialization(observationsTo, this)
val args = try { argsBytes.deserialize(kryo) } finally { val args = try {
argsBytes.deserialize(kryo)
} finally {
releaseRPCKryoForSerialization(kryo) releaseRPCKryoForSerialization(kryo)
} }
@ -173,6 +177,7 @@ abstract class RPCDispatcher(val ops: RPCOps, val userService: RPCUserService, v
// TODO remove this User once webserver doesn't need it // TODO remove this User once webserver doesn't need it
private val nodeUser = User(NODE_USER, NODE_USER, setOf()) private val nodeUser = User(NODE_USER, NODE_USER, setOf())
@VisibleForTesting @VisibleForTesting
protected open fun getUser(message: ClientMessage): User { protected open fun getUser(message: ClientMessage): User {
val validatedUser = message.requiredString(Message.HDR_VALIDATED_USER.toString()) val validatedUser = message.requiredString(Message.HDR_VALIDATED_USER.toString())

View File

@ -10,8 +10,7 @@ class FlowSession(
val flow: FlowLogic<*>, val flow: FlowLogic<*>,
val ourSessionId: Long, val ourSessionId: Long,
val initiatingParty: Party?, val initiatingParty: Party?,
var state: FlowSessionState) var state: FlowSessionState) {
{
val receivedMessages = ConcurrentLinkedQueue<ReceivedSessionMessage<*>>() val receivedMessages = ConcurrentLinkedQueue<ReceivedSessionMessage<*>>()
val fiber: FlowStateMachineImpl<*> get() = flow.stateMachine as FlowStateMachineImpl<*> val fiber: FlowStateMachineImpl<*> get() = flow.stateMachine as FlowStateMachineImpl<*>

View File

@ -26,6 +26,7 @@ interface SessionInitResponse : ExistingSessionMessage {
val initiatorSessionId: Long val initiatorSessionId: Long
override val recipientSessionId: Long get() = initiatorSessionId override val recipientSessionId: Long get() = initiatorSessionId
} }
data class SessionConfirm(override val initiatorSessionId: Long, val initiatedSessionId: Long) : SessionInitResponse data class SessionConfirm(override val initiatorSessionId: Long, val initiatedSessionId: Long) : SessionInitResponse
data class SessionReject(override val initiatorSessionId: Long, val errorMessage: String) : SessionInitResponse data class SessionReject(override val initiatorSessionId: Long, val errorMessage: String) : SessionInitResponse

View File

@ -5,7 +5,6 @@ import co.paralleluniverse.fibers.FiberExecutorScheduler
import co.paralleluniverse.io.serialization.kryo.KryoSerializer import co.paralleluniverse.io.serialization.kryo.KryoSerializer
import co.paralleluniverse.strands.Strand import co.paralleluniverse.strands.Strand
import com.codahale.metrics.Gauge import com.codahale.metrics.Gauge
import com.esotericsoftware.kryo.Kryo
import com.esotericsoftware.kryo.pool.KryoPool import com.esotericsoftware.kryo.pool.KryoPool
import com.google.common.collect.HashMultimap import com.google.common.collect.HashMultimap
import com.google.common.util.concurrent.ListenableFuture import com.google.common.util.concurrent.ListenableFuture
@ -79,6 +78,7 @@ class StateMachineManager(val serviceHub: ServiceHubInternal,
companion object { companion object {
private val logger = loggerFor<StateMachineManager>() private val logger = loggerFor<StateMachineManager>()
internal val sessionTopic = TopicSession("platform.session") internal val sessionTopic = TopicSession("platform.session")
init { init {
Fiber.setDefaultUncaughtExceptionHandler { fiber, throwable -> Fiber.setDefaultUncaughtExceptionHandler { fiber, throwable ->
(fiber as FlowStateMachineImpl<*>).logger.error("Caught exception from flow", throwable) (fiber as FlowStateMachineImpl<*>).logger.error("Caught exception from flow", throwable)
@ -101,12 +101,13 @@ class StateMachineManager(val serviceHub: ServiceHubInternal,
var started = false var started = false
val stateMachines = LinkedHashMap<FlowStateMachineImpl<*>, Checkpoint>() val stateMachines = LinkedHashMap<FlowStateMachineImpl<*>, Checkpoint>()
val changesPublisher = PublishSubject.create<Change>()!! val changesPublisher = PublishSubject.create<Change>()!!
val fibersWaitingForLedgerCommit = HashMultimap.create<SecureHash, FlowStateMachineImpl<*>>()!! val fibersWaitingForLedgerCommit = HashMultimap.create<SecureHash, FlowStateMachineImpl<*>>()!!
fun notifyChangeObservers(fiber: FlowStateMachineImpl<*>, addOrRemove: AddOrRemove) { fun notifyChangeObservers(fiber: FlowStateMachineImpl<*>, addOrRemove: AddOrRemove) {
changesPublisher.bufferUntilDatabaseCommit().onNext(Change(fiber.logic, addOrRemove, fiber.id)) changesPublisher.bufferUntilDatabaseCommit().onNext(Change(fiber.logic, addOrRemove, fiber.id))
} }
} }
private val mutex = ThreadBox(InnerState()) private val mutex = ThreadBox(InnerState())
// True if we're shutting down, so don't resume anything. // True if we're shutting down, so don't resume anything.

View File

@ -9,7 +9,6 @@ import net.corda.core.node.services.TransactionVerifierService
import net.corda.core.random63BitValue import net.corda.core.random63BitValue
import net.corda.core.serialization.SingletonSerializeAsToken import net.corda.core.serialization.SingletonSerializeAsToken
import net.corda.core.transactions.LedgerTransaction import net.corda.core.transactions.LedgerTransaction
import net.corda.core.utilities.debug
import net.corda.core.utilities.loggerFor import net.corda.core.utilities.loggerFor
import net.corda.node.services.api.MonitoringService import net.corda.node.services.api.MonitoringService
import net.corda.nodeapi.VerifierApi import net.corda.nodeapi.VerifierApi
@ -22,15 +21,18 @@ abstract class OutOfProcessTransactionVerifierService(
companion object { companion object {
val log = loggerFor<OutOfProcessTransactionVerifierService>() val log = loggerFor<OutOfProcessTransactionVerifierService>()
} }
private data class VerificationHandle( private data class VerificationHandle(
val transactionId: SecureHash, val transactionId: SecureHash,
val resultFuture: SettableFuture<Unit>, val resultFuture: SettableFuture<Unit>,
val durationTimerContext: Timer.Context val durationTimerContext: Timer.Context
) )
private val verificationHandles = ConcurrentHashMap<Long, VerificationHandle>() private val verificationHandles = ConcurrentHashMap<Long, VerificationHandle>()
// Metrics // Metrics
private fun metric(name: String) = "OutOfProcessTransactionVerifierService.$name" private fun metric(name: String) = "OutOfProcessTransactionVerifierService.$name"
private val durationTimer = monitoringService.metrics.timer(metric("Verification.Duration")) private val durationTimer = monitoringService.metrics.timer(metric("Verification.Duration"))
private val successMeter = monitoringService.metrics.meter(metric("Verification.Success")) private val successMeter = monitoringService.metrics.meter(metric("Verification.Success"))
private val failureMeter = monitoringService.metrics.meter(metric("Verification.Failure")) private val failureMeter = monitoringService.metrics.meter(metric("Verification.Failure"))

View File

@ -13,7 +13,10 @@ import net.corda.contracts.asset.Cash
import net.corda.core.ThreadBox import net.corda.core.ThreadBox
import net.corda.core.bufferUntilSubscribed import net.corda.core.bufferUntilSubscribed
import net.corda.core.contracts.* import net.corda.core.contracts.*
import net.corda.core.crypto.* import net.corda.core.crypto.AbstractParty
import net.corda.core.crypto.CompositeKey
import net.corda.core.crypto.Party
import net.corda.core.crypto.SecureHash
import net.corda.core.node.ServiceHub import net.corda.core.node.ServiceHub
import net.corda.core.node.services.StatesNotAvailableException import net.corda.core.node.services.StatesNotAvailableException
import net.corda.core.node.services.Vault import net.corda.core.node.services.Vault
@ -55,7 +58,7 @@ class NodeVaultService(private val services: ServiceHub, dataSourceProperties: P
val log = loggerFor<NodeVaultService>() val log = loggerFor<NodeVaultService>()
// Define composite primary key used in Requery Expression // Define composite primary key used in Requery Expression
val stateRefCompositeColumn : RowExpression = RowExpression.of(listOf(VaultStatesEntity.TX_ID, VaultStatesEntity.INDEX)) val stateRefCompositeColumn: RowExpression = RowExpression.of(listOf(VaultStatesEntity.TX_ID, VaultStatesEntity.INDEX))
} }
val configuration = RequeryConfiguration(dataSourceProperties) val configuration = RequeryConfiguration(dataSourceProperties)
@ -136,7 +139,7 @@ class NodeVaultService(private val services: ServiceHub, dataSourceProperties: P
} }
upsert(state ?: cashBalanceEntity) upsert(state ?: cashBalanceEntity)
val total = state?.amount ?: cashBalanceEntity.amount val total = state?.amount ?: cashBalanceEntity.amount
log.trace{"Updating Cash balance for $currency by ${cashBalanceEntity.amount} pennies (total: $total)"} log.trace { "Updating Cash balance for $currency by ${cashBalanceEntity.amount} pennies (total: $total)" }
} }
} }
} }
@ -171,24 +174,24 @@ class NodeVaultService(private val services: ServiceHub, dataSourceProperties: P
} }
} }
override fun <T: ContractState> states(clazzes: Set<Class<T>>, statuses: EnumSet<Vault.StateStatus>, includeSoftLockedStates: Boolean): Iterable<StateAndRef<T>> { override fun <T : ContractState> states(clazzes: Set<Class<T>>, statuses: EnumSet<Vault.StateStatus>, includeSoftLockedStates: Boolean): Iterable<StateAndRef<T>> {
val stateAndRefs = val stateAndRefs =
session.withTransaction(TransactionIsolation.REPEATABLE_READ) { session.withTransaction(TransactionIsolation.REPEATABLE_READ) {
var query = select(VaultSchema.VaultStates::class) var query = select(VaultSchema.VaultStates::class)
.where(VaultSchema.VaultStates::stateStatus `in` statuses) .where(VaultSchema.VaultStates::stateStatus `in` statuses)
// TODO: temporary fix to continue supporting track() function (until becomes Typed) // TODO: temporary fix to continue supporting track() function (until becomes Typed)
if (!clazzes.map {it.name}.contains(ContractState::class.java.name)) if (!clazzes.map { it.name }.contains(ContractState::class.java.name))
query.and (VaultSchema.VaultStates::contractStateClassName `in` (clazzes.map { it.name })) query.and(VaultSchema.VaultStates::contractStateClassName `in` (clazzes.map { it.name }))
if (!includeSoftLockedStates) if (!includeSoftLockedStates)
query.and(VaultSchema.VaultStates::lockId.isNull()) query.and(VaultSchema.VaultStates::lockId.isNull())
val iterator = query.get().iterator() val iterator = query.get().iterator()
Sequence{iterator} Sequence { iterator }
.map { it -> .map { it ->
val stateRef = StateRef(SecureHash.parse(it.txId), it.index) val stateRef = StateRef(SecureHash.parse(it.txId), it.index)
val state = it.contractState.deserialize<TransactionState<T>>(storageKryo()) val state = it.contractState.deserialize<TransactionState<T>>(storageKryo())
StateAndRef(state, stateRef) StateAndRef(state, stateRef)
} }
} }
return stateAndRefs.asIterable() return stateAndRefs.asIterable()
} }
@ -286,14 +289,13 @@ class NodeVaultService(private val services: ServiceHub, dataSourceProperties: P
val update = update(VaultStatesEntity::class) val update = update(VaultStatesEntity::class)
.set(VaultStatesEntity.LOCK_ID, null) .set(VaultStatesEntity.LOCK_ID, null)
.set(VaultStatesEntity.LOCK_UPDATE_TIME, services.clock.instant()) .set(VaultStatesEntity.LOCK_UPDATE_TIME, services.clock.instant())
.where (VaultStatesEntity.STATE_STATUS eq Vault.StateStatus.UNCONSUMED) .where(VaultStatesEntity.STATE_STATUS eq Vault.StateStatus.UNCONSUMED)
.and (VaultStatesEntity.LOCK_ID eq lockId.toString()).get() .and(VaultStatesEntity.LOCK_ID eq lockId.toString()).get()
if (update.value() > 0) { if (update.value() > 0) {
log.trace("Releasing ${update.value()} soft locked states for $lockId") log.trace("Releasing ${update.value()} soft locked states for $lockId")
} }
} }
} } else if (stateRefs.isNotEmpty()) {
else if (stateRefs.isNotEmpty()) {
try { try {
session.withTransaction(TransactionIsolation.REPEATABLE_READ) { session.withTransaction(TransactionIsolation.REPEATABLE_READ) {
val updatedRows = update(VaultStatesEntity::class) val updatedRows = update(VaultStatesEntity::class)
@ -412,21 +414,21 @@ class NodeVaultService(private val services: ServiceHub, dataSourceProperties: P
override fun <T : ContractState> softLockedStates(lockId: UUID?): List<StateAndRef<T>> { override fun <T : ContractState> softLockedStates(lockId: UUID?): List<StateAndRef<T>> {
val stateAndRefs = val stateAndRefs =
session.withTransaction(TransactionIsolation.REPEATABLE_READ) { session.withTransaction(TransactionIsolation.REPEATABLE_READ) {
var query = select(VaultSchema.VaultStates::class) var query = select(VaultSchema.VaultStates::class)
.where(VaultSchema.VaultStates::stateStatus eq Vault.StateStatus.UNCONSUMED) .where(VaultSchema.VaultStates::stateStatus eq Vault.StateStatus.UNCONSUMED)
.and(VaultSchema.VaultStates::contractStateClassName eq Cash.State::class.java.name) .and(VaultSchema.VaultStates::contractStateClassName eq Cash.State::class.java.name)
if (lockId != null) if (lockId != null)
query.and(VaultSchema.VaultStates::lockId eq lockId) query.and(VaultSchema.VaultStates::lockId eq lockId)
else else
query.and(VaultSchema.VaultStates::lockId.notNull()) query.and(VaultSchema.VaultStates::lockId.notNull())
query.get() query.get()
.map { it -> .map { it ->
val stateRef = StateRef(SecureHash.parse(it.txId), it.index) val stateRef = StateRef(SecureHash.parse(it.txId), it.index)
val state = it.contractState.deserialize<TransactionState<T>>(storageKryo()) val state = it.contractState.deserialize<TransactionState<T>>(storageKryo())
StateAndRef(state, stateRef) StateAndRef(state, stateRef)
}.toList() }.toList()
} }
return stateAndRefs return stateAndRefs
} }
@ -561,8 +563,8 @@ class NodeVaultService(private val services: ServiceHub, dataSourceProperties: P
if (tx.inputs.isNotEmpty()) { if (tx.inputs.isNotEmpty()) {
session.withTransaction(TransactionIsolation.REPEATABLE_READ) { session.withTransaction(TransactionIsolation.REPEATABLE_READ) {
val result = select(VaultStatesEntity::class). val result = select(VaultStatesEntity::class).
where (stateRefCompositeColumn.`in`(stateRefArgs(tx.inputs))). where(stateRefCompositeColumn.`in`(stateRefArgs(tx.inputs))).
and (VaultSchema.VaultStates::stateStatus eq Vault.StateStatus.UNCONSUMED) and(VaultSchema.VaultStates::stateStatus eq Vault.StateStatus.UNCONSUMED)
result.get().forEach { result.get().forEach {
val txHash = SecureHash.parse(it.txId) val txHash = SecureHash.parse(it.txId)
val index = it.index val index = it.index

View File

@ -1,4 +1,5 @@
package net.corda.node.services.vault package net.corda.node.services.vault
import net.corda.core.contracts.StateRef import net.corda.core.contracts.StateRef
import net.corda.core.flows.FlowLogic import net.corda.core.flows.FlowLogic
import net.corda.core.flows.StateMachineRunId import net.corda.core.flows.StateMachineRunId
@ -19,7 +20,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)

View File

@ -217,7 +217,7 @@ object InteractiveShell {
return return
} else if (matches.size > 1) { } else if (matches.size > 1) {
output.println("Ambigous name provided, please be more specific. Your options are:") output.println("Ambigous name provided, please be more specific. Your options are:")
matches.forEachIndexed { i, s -> output.println("${i+1}. $s", Color.yellow) } matches.forEachIndexed { i, s -> output.println("${i + 1}. $s", Color.yellow) }
return return
} }
val match = matches.single() val match = matches.single()

View File

@ -1,11 +1,13 @@
package net.corda.node.utilities package net.corda.node.utilities
import com.google.common.util.concurrent.ListeningScheduledExecutorService
import com.google.common.util.concurrent.SettableFuture import com.google.common.util.concurrent.SettableFuture
import com.google.common.util.concurrent.Uninterruptibles import com.google.common.util.concurrent.Uninterruptibles
import net.corda.core.utilities.loggerFor import net.corda.core.utilities.loggerFor
import java.util.* import java.util.*
import java.util.concurrent.* import java.util.concurrent.CompletableFuture
import java.util.concurrent.Executor
import java.util.concurrent.LinkedBlockingQueue
import java.util.concurrent.ScheduledThreadPoolExecutor
import java.util.function.Supplier import java.util.function.Supplier
/** /**

View File

@ -261,6 +261,7 @@ fun <T : Any> rx.Observable<T>.wrapWithDatabaseTransaction(db: Database? = null)
// Composite columns for use with below Exposed helpers. // Composite columns for use with below Exposed helpers.
data class PartyColumns(val name: Column<String>, val owningKey: Column<CompositeKey>) data class PartyColumns(val name: Column<String>, val owningKey: Column<CompositeKey>)
data class StateRefColumns(val txId: Column<SecureHash>, val index: Column<Int>) data class StateRefColumns(val txId: Column<SecureHash>, val index: Column<Int>)
data class TxnNoteColumns(val txId: Column<SecureHash>, val note: Column<String>) data class TxnNoteColumns(val txId: Column<SecureHash>, val note: Column<String>)

View File

@ -28,6 +28,7 @@ class InteractiveShellTest {
constructor(amount: Amount<Currency>) : this(amount.toString()) constructor(amount: Amount<Currency>) : this(amount.toString())
constructor(pair: Pair<Amount<Currency>, SecureHash.SHA256>) : this(pair.toString()) constructor(pair: Pair<Amount<Currency>, SecureHash.SHA256>) : this(pair.toString())
constructor(party: Party) : this(party.name) constructor(party: Party) : this(party.name)
override fun call() = a override fun call() = a
} }

View File

@ -14,8 +14,8 @@ import net.corda.node.services.network.NetworkMapService
import net.corda.node.services.persistence.NodeAttachmentService import net.corda.node.services.persistence.NodeAttachmentService
import net.corda.node.services.persistence.schemas.AttachmentEntity import net.corda.node.services.persistence.schemas.AttachmentEntity
import net.corda.node.services.transactions.SimpleNotaryService import net.corda.node.services.transactions.SimpleNotaryService
import net.corda.testing.node.MockNetwork
import net.corda.node.utilities.databaseTransaction import net.corda.node.utilities.databaseTransaction
import net.corda.testing.node.MockNetwork
import net.corda.testing.node.makeTestDataSourceProperties import net.corda.testing.node.makeTestDataSourceProperties
import org.jetbrains.exposed.sql.Database import org.jetbrains.exposed.sql.Database
import org.junit.Before import org.junit.Before

View File

@ -256,6 +256,7 @@ abstract class AbstractNetworkMapServiceTest<out S : AbstractNetworkMapService>
data class Added(val node: NodeInfo) : Changed() { data class Added(val node: NodeInfo) : Changed() {
constructor(node: MockNode) : this(node.info) constructor(node: MockNode) : this(node.info)
} }
data class Removed(val node: NodeInfo) : Changed() { data class Removed(val node: NodeInfo) : Changed() {
constructor(node: MockNode) : this(node.info) constructor(node: MockNode) : this(node.info)
} }

View File

@ -4,7 +4,10 @@ import net.corda.core.crypto.Party
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.node.services.identity.InMemoryIdentityService import net.corda.node.services.identity.InMemoryIdentityService
import net.corda.testing.* import net.corda.testing.ALICE
import net.corda.testing.ALICE_PUBKEY
import net.corda.testing.BOB
import net.corda.testing.BOB_PUBKEY
import org.junit.Test import org.junit.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertNull import kotlin.test.assertNull

View File

@ -8,7 +8,6 @@ import net.corda.core.node.services.ServiceInfo
import net.corda.core.seconds import net.corda.core.seconds
import net.corda.core.transactions.WireTransaction import net.corda.core.transactions.WireTransaction
import net.corda.core.utilities.DUMMY_NOTARY import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.core.utilities.DUMMY_NOTARY_KEY
import net.corda.flows.NotaryChangeFlow.Instigator import net.corda.flows.NotaryChangeFlow.Instigator
import net.corda.flows.StateReplacementException import net.corda.flows.StateReplacementException
import net.corda.node.internal.AbstractNode import net.corda.node.internal.AbstractNode

View File

@ -11,14 +11,12 @@ import net.corda.core.node.services.ServiceInfo
import net.corda.core.seconds import net.corda.core.seconds
import net.corda.core.transactions.SignedTransaction import net.corda.core.transactions.SignedTransaction
import net.corda.core.utilities.DUMMY_NOTARY import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.core.utilities.DUMMY_NOTARY_KEY
import net.corda.flows.NotaryError import net.corda.flows.NotaryError
import net.corda.flows.NotaryException import net.corda.flows.NotaryException
import net.corda.flows.NotaryFlow import net.corda.flows.NotaryFlow
import net.corda.node.internal.AbstractNode import net.corda.node.internal.AbstractNode
import net.corda.node.services.network.NetworkMapService import net.corda.node.services.network.NetworkMapService
import net.corda.node.services.transactions.SimpleNotaryService import net.corda.node.services.transactions.SimpleNotaryService
import net.corda.testing.MINI_CORP_KEY
import net.corda.testing.node.MockNetwork import net.corda.testing.node.MockNetwork
import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThat
import org.junit.Before import org.junit.Before

View File

@ -8,7 +8,6 @@ import net.corda.core.getOrThrow
import net.corda.core.node.services.ServiceInfo import net.corda.core.node.services.ServiceInfo
import net.corda.core.transactions.SignedTransaction import net.corda.core.transactions.SignedTransaction
import net.corda.core.utilities.DUMMY_NOTARY import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.core.utilities.DUMMY_NOTARY_KEY
import net.corda.flows.NotaryError import net.corda.flows.NotaryError
import net.corda.flows.NotaryException import net.corda.flows.NotaryException
import net.corda.flows.NotaryFlow import net.corda.flows.NotaryFlow
@ -16,7 +15,6 @@ import net.corda.node.internal.AbstractNode
import net.corda.node.services.network.NetworkMapService import net.corda.node.services.network.NetworkMapService
import net.corda.node.services.transactions.ValidatingNotaryService import net.corda.node.services.transactions.ValidatingNotaryService
import net.corda.testing.MEGA_CORP_KEY import net.corda.testing.MEGA_CORP_KEY
import net.corda.testing.MINI_CORP_KEY
import net.corda.testing.node.MockNetwork import net.corda.testing.node.MockNetwork
import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThat
import org.junit.Before import org.junit.Before

View File

@ -14,9 +14,6 @@ import net.corda.core.transactions.SignedTransaction
import net.corda.core.utilities.DUMMY_NOTARY import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.core.utilities.DUMMY_NOTARY_KEY import net.corda.core.utilities.DUMMY_NOTARY_KEY
import net.corda.core.utilities.LogHelper import net.corda.core.utilities.LogHelper
import net.corda.node.services.schema.HibernateObserver
import net.corda.node.services.schema.NodeSchemaService
import net.corda.node.services.vault.NodeVaultService
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.BOB_KEY import net.corda.testing.BOB_KEY
@ -138,9 +135,9 @@ class VaultWithCashTest {
databaseTransaction(database) { databaseTransaction(database) {
// A tx that sends us money. // A tx that sends us money.
services.fillWithSomeTestCash(100.DOLLARS, DUMMY_NOTARY, 10, 10, Random(0L), services.fillWithSomeTestCash(100.DOLLARS, DUMMY_NOTARY, 10, 10, Random(0L),
issuedBy = MEGA_CORP.ref(1), issuedBy = MEGA_CORP.ref(1),
issuerKey = MEGA_CORP_KEY, issuerKey = MEGA_CORP_KEY,
ownedBy = freshKey.public.composite) ownedBy = freshKey.public.composite)
println("Cash balance: ${vault.cashBalances[USD]}") println("Cash balance: ${vault.cashBalances[USD]}")
assertThat(vault.unconsumedStates<Cash.State>()).hasSize(10) assertThat(vault.unconsumedStates<Cash.State>()).hasSize(10)
@ -173,8 +170,7 @@ class VaultWithCashTest {
LOCKED: ${vault.softLockedStates<Cash.State>().count()} : ${vault.softLockedStates<Cash.State>()} LOCKED: ${vault.softLockedStates<Cash.State>().count()} : ${vault.softLockedStates<Cash.State>()}
""") """)
txn1 txn1
} } catch(e: Exception) {
catch(e: Exception) {
println(e) println(e)
} }
} }
@ -206,8 +202,7 @@ class VaultWithCashTest {
LOCKED: ${vault.softLockedStates<Cash.State>().count()} : ${vault.softLockedStates<Cash.State>()} LOCKED: ${vault.softLockedStates<Cash.State>().count()} : ${vault.softLockedStates<Cash.State>()}
""") """)
txn2 txn2
} } catch(e: Exception) {
catch(e: Exception) {
println(e) println(e)
} }
} }
@ -219,7 +214,7 @@ class VaultWithCashTest {
countDown.await() countDown.await()
databaseTransaction(database) { databaseTransaction(database) {
println("Cash balance: ${vault.cashBalances[USD]}") println("Cash balance: ${vault.cashBalances[USD]}")
assertThat(vault.cashBalances[USD]).isIn(DOLLARS(20),DOLLARS(40)) assertThat(vault.cashBalances[USD]).isIn(DOLLARS(20), DOLLARS(40))
} }
} }
@ -287,7 +282,7 @@ class VaultWithCashTest {
val cash = vault.unconsumedStates<Cash.State>() val cash = vault.unconsumedStates<Cash.State>()
cash.forEach { println(it.state.data.amount) } cash.forEach { println(it.state.data.amount) }
services.fillWithSomeTestDeals(listOf("123","456","789")) services.fillWithSomeTestDeals(listOf("123", "456", "789"))
val deals = vault.unconsumedStates<net.corda.contracts.testing.DummyDealContract.State>() val deals = vault.unconsumedStates<net.corda.contracts.testing.DummyDealContract.State>()
deals.forEach { println(it.state.data.ref) } deals.forEach { println(it.state.data.ref) }
} }
@ -315,7 +310,7 @@ class VaultWithCashTest {
val freshKey = services.keyManagementService.freshKey() val freshKey = services.keyManagementService.freshKey()
databaseTransaction(database) { databaseTransaction(database) {
services.fillWithSomeTestDeals(listOf("123","456","789")) services.fillWithSomeTestDeals(listOf("123", "456", "789"))
val deals = vault.unconsumedStates<net.corda.contracts.testing.DummyDealContract.State>().toList() val deals = vault.unconsumedStates<net.corda.contracts.testing.DummyDealContract.State>().toList()
deals.forEach { println(it.state.data.ref) } deals.forEach { println(it.state.data.ref) }

View File

@ -15,7 +15,6 @@ import net.corda.core.utilities.LogHelper
import net.corda.node.services.RPCUserService import net.corda.node.services.RPCUserService
import net.corda.node.services.RPCUserServiceImpl import net.corda.node.services.RPCUserServiceImpl
import net.corda.node.services.api.MonitoringService import net.corda.node.services.api.MonitoringService
import net.corda.node.services.config.FullNodeConfiguration
import net.corda.node.services.config.NodeConfiguration import net.corda.node.services.config.NodeConfiguration
import net.corda.node.services.config.configureWithDevSSLCertificate import net.corda.node.services.config.configureWithDevSSLCertificate
import net.corda.node.services.network.InMemoryNetworkMapCache import net.corda.node.services.network.InMemoryNetworkMapCache

View File

@ -324,7 +324,7 @@ class StateMachineManagerTests {
node1.info.legalIdentity, node1.info.legalIdentity,
notary1.info.notaryIdentity)) notary1.info.notaryIdentity))
// We pay a couple of times, the notary picking should go round robin // We pay a couple of times, the notary picking should go round robin
for (i in 1 .. 3) { for (i in 1..3) {
node1.services.startFlow(CashPaymentFlow(500.DOLLARS, node2.info.legalIdentity)) node1.services.startFlow(CashPaymentFlow(500.DOLLARS, node2.info.legalIdentity))
net.runNetwork() net.runNetwork()
} }

View File

@ -303,7 +303,7 @@ class NodeVaultServiceTest {
val spendableStatesUSD = (services.vaultService as NodeVaultService).unconsumedStatesForSpending<Cash.State>(100.DOLLARS, lockId = UUID.randomUUID()) val spendableStatesUSD = (services.vaultService as NodeVaultService).unconsumedStatesForSpending<Cash.State>(100.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).isEqualTo(100L*100) assertThat(spendableStatesUSD[0].state.data.amount.quantity).isEqualTo(100L * 100)
assertThat(services.vaultService.softLockedStates<Cash.State>()).hasSize(1) assertThat(services.vaultService.softLockedStates<Cash.State>()).hasSize(1)
} }
} }
@ -316,7 +316,7 @@ class NodeVaultServiceTest {
services.fillWithSomeTestCash(100.DOLLARS, DUMMY_NOTARY, 1, 1, Random(0L), issuedBy = (BOC.ref(1)), issuerKey = BOC_KEY) services.fillWithSomeTestCash(100.DOLLARS, DUMMY_NOTARY, 1, 1, Random(0L), issuedBy = (BOC.ref(1)), issuerKey = BOC_KEY)
val spendableStatesUSD = services.vaultService.unconsumedStatesForSpending<Cash.State>(200.DOLLARS, lockId = UUID.randomUUID(), val spendableStatesUSD = services.vaultService.unconsumedStatesForSpending<Cash.State>(200.DOLLARS, lockId = UUID.randomUUID(),
onlyFromIssuerParties = setOf(DUMMY_CASH_ISSUER.party, BOC)).toList() onlyFromIssuerParties = setOf(DUMMY_CASH_ISSUER.party, BOC)).toList()
spendableStatesUSD.forEach(::println) spendableStatesUSD.forEach(::println)
assertThat(spendableStatesUSD).hasSize(2) assertThat(spendableStatesUSD).hasSize(2)
assertThat(spendableStatesUSD[0].state.data.amount.token.issuer).isEqualTo(DUMMY_CASH_ISSUER) assertThat(spendableStatesUSD[0].state.data.amount.token.issuer).isEqualTo(DUMMY_CASH_ISSUER)
@ -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(1L * 100)
assertThat(services.vaultService.softLockedStates<Cash.State>()).hasSize(1) assertThat(services.vaultService.softLockedStates<Cash.State>()).hasSize(1)
} }
} }

View File

@ -5,7 +5,6 @@ import org.junit.Test
import java.util.* import java.util.*
import java.util.concurrent.CountDownLatch import java.util.concurrent.CountDownLatch
import java.util.concurrent.atomic.AtomicReference import java.util.concurrent.atomic.AtomicReference
import kotlin.concurrent.thread
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFails import kotlin.test.assertFails
import kotlin.test.assertNotEquals import kotlin.test.assertNotEquals