Merge remote-tracking branch 'remotes/open/master' into merges/may-14-15-21

# Conflicts:
#	.idea/compiler.xml
#	constants.properties
#	experimental/behave/src/main/kotlin/net/corda/behave/network/Network.kt
#	experimental/behave/src/main/kotlin/net/corda/behave/node/Distribution.kt
#	experimental/behave/src/test/kotlin/net/corda/behave/service/PostreSQLServiceTests.kt
#	node-api/src/main/kotlin/net/corda/nodeapi/internal/bridging/AMQPBridgeManager.kt
#	node-api/src/main/kotlin/net/corda/nodeapi/internal/persistence/CordaPersistence.kt
#	node-api/src/main/kotlin/net/corda/nodeapi/internal/persistence/HibernateConfiguration.kt
#	node-api/src/main/kotlin/net/corda/nodeapi/internal/protonwrapper/netty/AMQPChannelHandler.kt
#	node-api/src/main/kotlin/net/corda/nodeapi/internal/protonwrapper/netty/AMQPClient.kt
#	node/src/integration-test/kotlin/net/corda/node/AuthDBTests.kt
#	node/src/main/kotlin/net/corda/node/internal/AbstractNode.kt
#	node/src/main/kotlin/net/corda/node/internal/NodeStartup.kt
#	node/src/main/kotlin/net/corda/node/services/config/ConfigUtilities.kt
#	node/src/main/kotlin/net/corda/node/services/messaging/MessagingExecutor.kt
#	node/src/main/kotlin/net/corda/node/services/persistence/AbstractPartyToX500NameAsStringConverter.kt
#	node/src/main/kotlin/net/corda/node/services/persistence/DBTransactionMappingStorage.kt
#	node/src/main/kotlin/net/corda/node/utilities/AddOrRemove.kt
#	node/src/test/kotlin/net/corda/node/services/config/NodeConfigurationImplTest.kt
#	samples/attachment-demo/src/integration-test/kotlin/net/corda/attachmentdemo/AttachmentDemoTest.kt
#	samples/irs-demo/web/src/test/kotlin/net/corda/irs/web/IrsDemoWebApplicationTests.kt
#	samples/simm-valuation-demo/src/integration-test/kotlin/net/corda/vega/SimmValuationTest.kt
#	testing/node-driver/src/main/kotlin/net/corda/testing/driver/Driver.kt
#	testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/InternalTestUtils.kt
#	testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/RPCDriver.kt
#	testing/smoke-test-utils/src/main/kotlin/net/corda/smoketesting/NodeConfig.kt
#	webserver/src/integration-test/kotlin/net/corda/webserver/WebserverDriverTests.kt
This commit is contained in:
sollecitom
2018-05-14 15:56:43 +01:00
475 changed files with 1987 additions and 1521 deletions

View File

@ -9,7 +9,7 @@ omissions, and create a pull request, or email <james@r3.com>, if you wish to
see changes to this list.
* acetheultimate
* Adrian Flethcehr (TD)
* Adrian Fletcher (TD)
* agoldvarg
* Alberto Arri (R3)
* amiracam
@ -108,7 +108,7 @@ see changes to this list.
* Lars Stage Thomsen (Danske Bank)
* Lee Braine (Barclays)
* Lucas Salmen (Itau)
* Maksymillian Pawlak (R3)
* Maksymilian Pawlak (R3)
* Marek Scocovsky (ABSA)
* marekdapps
* Mark Lauer (Westpac)
@ -176,6 +176,7 @@ see changes to this list.
* Tommy Lillehagen (R3)
* tomtau
* Tudor Malene (R3)
* Tushar Singh Bora
* varunkm
* verymahler
* Viktor Kolomeyko (R3)

View File

@ -120,7 +120,9 @@ buildscript {
classpath "net.corda.plugins:quasar-utils:$gradle_plugins_version"
classpath "net.corda.plugins:cordformation:$gradle_plugins_version"
classpath "net.corda.plugins:cordapp:$gradle_plugins_version"
classpath "net.corda.plugins:api-scanner:$gradle_plugins_version"
//TODO Anthony- this should be changed back to $gradle_plugins_version when the api-scaner is fixed
// classpath "net.corda.plugins:api-scanner:$gradle_plugins_version"
classpath "net.corda.plugins:api-scanner:4.0.15"
classpath 'com.github.ben-manes:gradle-versions-plugin:0.15.0'
classpath "org.jetbrains.kotlin:kotlin-noarg:$kotlin_version"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:${dokka_version}"

View File

@ -340,14 +340,14 @@ object JacksonSupport {
mapper.wellKnownPartyFromX500Name(principal) ?: throw JsonParseException(parser, "Could not find a Party with name $principal")
} else {
val nameMatches = mapper.partiesFromName(parser.text)
if (nameMatches.isEmpty()) {
when {
nameMatches.isEmpty() -> {
val publicKey = parser.readValueAs<PublicKey>()
mapper.partyFromKey(publicKey)
?: throw JsonParseException(parser, "Could not find a Party with key ${publicKey.toStringShort()}")
} else if (nameMatches.size == 1) {
nameMatches.first()
} else {
throw JsonParseException(parser, "Ambiguous name match '${parser.text}': could be any of " +
}
nameMatches.size == 1 -> nameMatches.first()
else -> throw JsonParseException(parser, "Ambiguous name match '${parser.text}': could be any of " +
nameMatches.map { it.name }.joinToString(" ... or ... "))
}
}

View File

@ -230,7 +230,7 @@ open class StringToMethodCallParser<in T : Any> @JvmOverloads constructor(
val paramNames = methodParamNames[name]!!
val typeNames = args.parameters.map { it.type.simpleName }
val paramTypes = paramNames.zip(typeNames)
paramTypes.map { "${it.first}: ${it.second}" }.joinToString(", ")
paramTypes.joinToString(", ") { "${it.first}: ${it.second}" }
}
Pair(name, argStr)
}.toMap()

View File

@ -13,7 +13,6 @@ package net.corda.client.jackson
import net.corda.core.crypto.SecureHash
import org.junit.Assert.assertArrayEquals
import org.junit.Test
import kotlin.reflect.full.primaryConstructor
import kotlin.test.assertEquals
class StringToMethodCallParserTest {

View File

@ -121,13 +121,13 @@ class NodeMonitorModelTest : IntegrationTest() {
sequence(
// TODO : Add test for remove when driver DSL support individual node shutdown.
expect { output: NetworkMapCache.MapChange ->
require(output.node.legalIdentities.any { it.name == ALICE_NAME }) { "Expecting : ${ALICE_NAME}, Actual : ${output.node.legalIdentities.map(Party::name)}" }
require(output.node.legalIdentities.any { it.name == ALICE_NAME }) { "Expecting : $ALICE_NAME, Actual : ${output.node.legalIdentities.map(Party::name)}" }
},
expect { output: NetworkMapCache.MapChange ->
require(output.node.legalIdentities.any { it.name == BOB_NAME }) { "Expecting : ${BOB_NAME}, Actual : ${output.node.legalIdentities.map(Party::name)}" }
require(output.node.legalIdentities.any { it.name == BOB_NAME }) { "Expecting : $BOB_NAME, Actual : ${output.node.legalIdentities.map(Party::name)}" }
},
expect { output: NetworkMapCache.MapChange ->
require(output.node.legalIdentities.any { it.name == CHARLIE_NAME }) { "Expecting : ${CHARLIE_NAME}, Actual : ${output.node.legalIdentities.map(Party::name)}" }
require(output.node.legalIdentities.any { it.name == CHARLIE_NAME }) { "Expecting : $CHARLIE_NAME, Actual : ${output.node.legalIdentities.map(Party::name)}" }
}
)
}

View File

@ -39,24 +39,23 @@ class ContractStateModel {
private val cashStatesDiff: Observable<Diff<Cash.State>> = contractStatesDiff.map {
Diff(it.added.filterCashStateAndRefs(), it.removed.filterCashStateAndRefs())
}
val cashStates: ObservableList<StateAndRef<Cash.State>> = cashStatesDiff.fold(FXCollections.observableArrayList()) { list: MutableList<StateAndRef<Cash.State>>, statesDiff ->
list.removeIf { it in statesDiff.removed }
list.addAll(statesDiff.added)
val cashStates: ObservableList<StateAndRef<Cash.State>> = cashStatesDiff.fold(FXCollections.observableArrayList()) { list: MutableList<StateAndRef<Cash.State>>, (added, removed) ->
list.removeIf { it in removed }
list.addAll(added)
}.distinctBy { it.ref }
val cash = cashStates.map { it.state.data.amount }
companion object {
private fun Collection<StateAndRef<ContractState>>.filterCashStateAndRefs(): List<StateAndRef<Cash.State>> {
return this.map { stateAndRef ->
return this.mapNotNull { stateAndRef ->
if (stateAndRef.state.data is Cash.State) {
// Kotlin doesn't unify here for some reason
uncheckedCast<StateAndRef<ContractState>, StateAndRef<Cash.State>>(stateAndRef)
} else {
null
}
}.filterNotNull()
}
}
}
}

View File

@ -10,16 +10,7 @@
package net.corda.client.jfx.model
import javafx.beans.property.ObjectProperty
import javafx.beans.value.ObservableValue
import javafx.beans.value.WritableValue
import javafx.collections.ObservableList
import net.corda.core.internal.uncheckedCast
import org.reactfx.EventSink
import org.reactfx.EventStream
import rx.Observable
import rx.Observer
import rx.subjects.Subject
import java.util.*
import kotlin.reflect.KClass
@ -84,7 +75,7 @@ object Models {
fun <M : Any> initModel(klass: KClass<M>) = modelStore.getOrPut(klass) { klass.java.newInstance() }
fun <M : Any> get(klass: KClass<M>, origin: KClass<*>): M {
dependencyGraph.getOrPut(origin) { mutableSetOf<KClass<*>>() }.add(klass)
dependencyGraph.getOrPut(origin) { mutableSetOf() }.add(klass)
val model = initModel(klass)
if (model.javaClass != klass.java) {
throw IllegalStateException("Model stored as ${klass.qualifiedName} has type ${model.javaClass}")

View File

@ -21,7 +21,6 @@ import org.reactfx.EventStream
import rx.Observable
import rx.Observer
import rx.subjects.Subject
import kotlin.reflect.KClass
inline fun <reified M : Any, T> observable(noinline observableProperty: (M) -> Observable<T>) =
TrackedDelegate.ObservableDelegate(M::class, observableProperty)

View File

@ -32,7 +32,7 @@ class NetworkIdentityModel {
else -> false
}
}
if(update is MapChange.Modified || update is MapChange.Added){
if (update is MapChange.Modified || update is MapChange.Added) {
list.addAll(update.node)
}
}

View File

@ -95,8 +95,8 @@ class TransactionDataModel {
private val transactions by observable(NodeMonitorModel::transactions)
private val collectedTransactions = transactions.recordInSequence().distinctBy { it.id }
private val vaultUpdates by observable(NodeMonitorModel::vaultUpdates)
private val stateMap = vaultUpdates.fold(FXCollections.observableHashMap<StateRef, StateAndRef<ContractState>>()) { map, update ->
val states = update.consumed + update.produced
private val stateMap = vaultUpdates.fold(FXCollections.observableHashMap<StateRef, StateAndRef<ContractState>>()) { map, (consumed, produced) ->
val states = consumed + produced
states.forEach { map[it.ref] = it }
}

View File

@ -80,11 +80,14 @@ class AggregatedList<A, E : Any, K : Any>(
override fun sourceChanged(c: ListChangeListener.Change<out E>) {
beginChange()
while (c.next()) {
if (c.wasPermutated()) {
when {
c.wasPermutated() -> {
// Permutation should not change aggregation
} else if (c.wasUpdated()) {
}
c.wasUpdated() -> {
// Update should not change aggregation
} else {
}
else -> {
for (removedSourceItem in c.removed) {
val removedPair = removeItem(removedSourceItem)
if (removedPair != null) {
@ -99,6 +102,7 @@ class AggregatedList<A, E : Any, K : Any>(
}
}
}
}
endChange()
}

View File

@ -16,6 +16,7 @@ import javafx.collections.ObservableList
import net.corda.client.jfx.model.ExchangeRate
import net.corda.core.contracts.Amount
import org.fxmisc.easybind.EasyBind
import org.fxmisc.easybind.monadic.MonadicBinding
import java.util.*
import java.util.stream.Collectors
@ -23,7 +24,7 @@ import java.util.stream.Collectors
* Utility bindings for the [Amount] type, similar in spirit to [Bindings]
*/
object AmountBindings {
fun <T : Any> sum(amounts: ObservableList<Amount<T>>, token: T) = EasyBind.map(
fun <T : Any> sum(amounts: ObservableList<Amount<T>>, token: T): MonadicBinding<Amount<T>> = EasyBind.map(
Bindings.createLongBinding({
amounts.stream().collect(Collectors.summingLong {
require(it.token == token)

View File

@ -31,13 +31,16 @@ class AssociatedList<K, out A, B>(
init {
sourceList.forEach {
val key = toKey(it)
backingMap.set(key, Pair(assemble(key, it), Unit))
backingMap[key] = Pair(assemble(key, it), Unit)
}
sourceList.addListener { change: ListChangeListener.Change<out A> ->
while (change.next()) {
if (change.wasPermutated()) {
} else if (change.wasUpdated()) {
} else {
when {
change.wasPermutated() -> {
}
change.wasUpdated() -> {
}
else -> {
val removedSourceMap = change.removed.associateBy(toKey)
val addedSourceMap = change.addedSubList.associateBy(toKey)
val removedMap = HashMap<K, B>()
@ -65,4 +68,5 @@ class AssociatedList<K, out A, B>(
}
}
}
}
}

View File

@ -37,9 +37,7 @@ class ChosenList<E>(
private var currentList = chosenListObservable.value
private val listener = object : ListChangeListener<E> {
override fun onChanged(change: ListChangeListener.Change<out E>) = fireChange(change)
}
private val listener = ListChangeListener<E> { change -> fireChange(change) }
init {
chosenListObservable.addListener { _: Observable -> rechoose() }
@ -49,7 +47,7 @@ class ChosenList<E>(
endChange()
}
override fun get(index: Int) = currentList.get(index)
override fun get(index: Int): E = currentList[index]
override val size: Int get() = currentList.size
private fun rechoose() {

View File

@ -62,10 +62,10 @@ class ConcatenatedList<A>(sourceList: ObservableList<ObservableList<A>>) : Trans
}
private fun startingOffsetOf(listIndex: Int): Int {
if (listIndex == 0) {
return 0
return if (listIndex == 0) {
0
} else {
return nestedIndexOffsets[listIndex - 1]
nestedIndexOffsets[listIndex - 1]
}
}
@ -84,11 +84,11 @@ class ConcatenatedList<A>(sourceList: ObservableList<ObservableList<A>>) : Trans
// firstTouched is the result list index of the beginning of the permutation.
val firstTouched = startingOffset + change.from
// We first set the non-permuted indices.
for (i in 0..firstTouched - 1) {
for (i in 0 until firstTouched) {
permutation[i] = i
}
// Then the permuted ones.
for (i in firstTouched..startingOffset + change.to - 1) {
for (i in firstTouched until startingOffset + change.to) {
permutation[startingOffset + i] = change.getPermutation(i)
}
nextPermutation(firstTouched, startingOffset + change.to, permutation)
@ -97,7 +97,7 @@ class ConcatenatedList<A>(sourceList: ObservableList<ObservableList<A>>) : Trans
// by the startingOffsetOf the nested list.
val listIndex = indexMap[wrapped]!!.first
val startingOffset = startingOffsetOf(listIndex)
for (i in change.from..change.to - 1) {
for (i in change.from until change.to) {
nextUpdate(startingOffset + i)
}
} else {
@ -154,7 +154,7 @@ class ConcatenatedList<A>(sourceList: ObservableList<ObservableList<A>>) : Trans
val newSubNestedIndexOffsets = IntArray(change.to - change.from)
val firstTouched = if (change.from == 0) 0 else nestedIndexOffsets[change.from - 1]
var currentOffset = firstTouched
for (i in 0..change.to - change.from - 1) {
for (i in 0 until change.to - change.from) {
currentOffset += source[change.from + i].size
newSubNestedIndexOffsets[i] = currentOffset
}
@ -162,24 +162,24 @@ class ConcatenatedList<A>(sourceList: ObservableList<ObservableList<A>>) : Trans
val concatenatedPermutation = IntArray(newSubNestedIndexOffsets.last())
// Set the non-permuted part
var offset = 0
for (i in 0..change.from - 1) {
for (i in 0 until change.from) {
val nestedList = source[i]
for (j in offset..offset + nestedList.size - 1) {
for (j in offset until offset + nestedList.size) {
concatenatedPermutation[j] = j
}
offset += nestedList.size
}
// Now the permuted part
for (i in 0..newSubNestedIndexOffsets.size - 1) {
for (i in 0 until newSubNestedIndexOffsets.size) {
val startingOffset = startingOffsetOf(change.from + i)
val permutedListIndex = change.getPermutation(change.from + i)
val permutedOffset = (if (permutedListIndex == 0) 0 else newSubNestedIndexOffsets[permutedListIndex - 1])
for (j in 0..source[permutedListIndex].size - 1) {
for (j in 0 until source[permutedListIndex].size) {
concatenatedPermutation[startingOffset + j] = permutedOffset + j
}
}
// Record permuted offsets
for (i in 0..newSubNestedIndexOffsets.size - 1) {
for (i in 0 until newSubNestedIndexOffsets.size) {
nestedIndexOffsets[change.from + i] = newSubNestedIndexOffsets[i]
}
nextPermutation(firstTouched, newSubNestedIndexOffsets.last(), concatenatedPermutation)
@ -248,7 +248,7 @@ class ConcatenatedList<A>(sourceList: ObservableList<ObservableList<A>>) : Trans
if (firstInvalidatedPosition < source.size) {
val firstInvalid = firstInvalidatedPosition
var offset = if (firstInvalid == 0) 0 else nestedIndexOffsets[firstInvalid - 1]
for (i in firstInvalid..source.size - 1) {
for (i in firstInvalid until source.size) {
offset += source[i].size
if (i < nestedIndexOffsets.size) {
nestedIndexOffsets[i] = offset
@ -266,10 +266,10 @@ class ConcatenatedList<A>(sourceList: ObservableList<ObservableList<A>>) : Trans
override val size: Int
get() {
recalculateOffsets()
if (nestedIndexOffsets.size > 0) {
return nestedIndexOffsets.last()
return if (nestedIndexOffsets.size > 0) {
nestedIndexOffsets.last()
} else {
return 0
0
}
}
@ -283,17 +283,17 @@ class ConcatenatedList<A>(sourceList: ObservableList<ObservableList<A>>) : Trans
comparison = { offset -> compareValues(offset, index) }
)
if (listIndex >= 0) {
return if (listIndex >= 0) {
var nonEmptyListIndex = listIndex + 1
while (source[nonEmptyListIndex].isEmpty()) {
nonEmptyListIndex++
}
return source[nonEmptyListIndex][0]
source[nonEmptyListIndex][0]
} else {
// The element is in the range of this list
val rangeListIndex = -listIndex - 1
val subListOffset = index - startingOffsetOf(rangeListIndex)
return source[rangeListIndex][subListOffset]
source[rangeListIndex][subListOffset]
}
}

View File

@ -65,7 +65,7 @@ class FlattenedList<A>(val sourceList: ObservableList<out ObservableValue<out A>
val from = c.from
val to = c.to
val permutation = IntArray(to, { c.getPermutation(it) })
indexMap.replaceAll { _, pair -> Pair(permutation[pair.first], pair.second) }
indexMap.replaceAll { _, (first, second) -> Pair(permutation[first], second) }
nextPermutation(from, to, permutation)
} else if (c.wasUpdated()) {
throw UnsupportedOperationException("FlattenedList doesn't support Update changes")
@ -119,7 +119,7 @@ class FlattenedList<A>(val sourceList: ObservableList<out ObservableValue<out A>
assert(sourceList.size == indexMap.size)
}
override fun get(index: Int) = sourceList.get(index).value
override fun get(index: Int): A = sourceList[index].value
override fun getSourceIndex(index: Int) = index

View File

@ -26,8 +26,8 @@ class LeftOuterJoinedMap<K : Any, A, B, C>(
) : ReadOnlyBackedObservableMapBase<K, C, SimpleObjectProperty<B?>>() {
init {
leftTable.forEach { entry ->
val rightValueProperty = SimpleObjectProperty(rightTable.get(entry.key))
backingMap.set(entry.key, Pair(assemble(entry.key, entry.value, rightValueProperty), rightValueProperty))
val rightValueProperty = SimpleObjectProperty(rightTable[entry.key])
backingMap[entry.key] = Pair(assemble(entry.key, entry.value, rightValueProperty), rightValueProperty)
}
leftTable.addListener { change: MapChangeListener.Change<out K, out A> ->
@ -39,10 +39,10 @@ class LeftOuterJoinedMap<K : Any, A, B, C>(
}
if (change.wasAdded()) {
val rightValue = rightTable.get(change.key)
val rightValue = rightTable[change.key]
val rightValueProperty = SimpleObjectProperty(rightValue)
val newValue = assemble(change.key, change.valueAdded, rightValueProperty)
backingMap.set(change.key, Pair(newValue, rightValueProperty))
backingMap[change.key] = Pair(newValue, rightValueProperty)
addedValue = newValue
}
@ -50,11 +50,11 @@ class LeftOuterJoinedMap<K : Any, A, B, C>(
}
rightTable.addListener { change: MapChangeListener.Change<out K, out B> ->
if (change.wasRemoved() && !change.wasAdded()) {
backingMap.get(change.key)?.second?.set(null)
backingMap[change.key]?.second?.set(null)
}
if (change.wasAdded()) {
backingMap.get(change.key)?.second?.set(change.valueAdded)
backingMap[change.key]?.second?.set(change.valueAdded)
}
}
}

View File

@ -15,7 +15,6 @@ import javafx.collections.ObservableList
import javafx.collections.transformation.TransformationList
import java.util.*
/**
* This is a variant of [EasyBind.map] where the mapped list is backed, therefore the mapping function will only be run
* when an element is inserted or updated.

View File

@ -40,7 +40,7 @@ private fun onError(th: Throwable) {
*/
fun <A, B> Observable<A>.foldToObservableValue(initial: B, folderFun: (A, B) -> B): ObservableValue<B> {
val result = SimpleObjectProperty<B>(initial)
subscribe ({
subscribe({
Platform.runLater {
result.set(folderFun(it, result.get()))
}

View File

@ -52,10 +52,10 @@ fun <A, B> ObservableValue<out A>.map(function: (A) -> B): ObservableValue<B> =
* re-run the function.
*/
fun <A, B> ObservableList<out A>.map(cached: Boolean = true, function: (A) -> B): ObservableList<B> {
if (cached) {
return MappedList(this, function)
return if (cached) {
MappedList(this, function)
} else {
return EasyBind.map(this, function)
EasyBind.map(this, function)
}
}
@ -130,11 +130,7 @@ fun <A> ObservableList<out A>.filter(predicate: ObservableValue<(A) -> Boolean>)
*/
fun <A> ObservableList<out A?>.filterNotNull(): ObservableList<A> {
//TODO This is a tactical work round for an issue with SAM conversion (https://youtrack.jetbrains.com/issue/ALL-1552) so that the M10 explorer works.
return uncheckedCast(uncheckedCast<Any, ObservableList<A?>>(this).filtered(object : Predicate<A?> {
override fun test(t: A?): Boolean {
return t != null
}
}))
return uncheckedCast(uncheckedCast<Any, ObservableList<A?>>(this).filtered { t -> t != null })
}
/**
@ -257,8 +253,8 @@ fun <A : Any, B : Any, C, K : Any> ObservableList<A>.leftOuterJoin(
assemble: (A, ObservableList<B>) -> C
): ObservableList<C> {
val joinedMap = leftOuterJoin(rightTable, leftToJoinKey, rightToJoinKey)
return joinedMap.getObservableValues().map { pair ->
pair.first.map { assemble(it, pair.second) }
return joinedMap.getObservableValues().map { (first, second) ->
first.map { assemble(it, second) }
}.concatenate()
}
@ -281,11 +277,9 @@ fun <A : Any, B : Any, K : Any> ObservableList<A>.leftOuterJoin(
): ObservableMap<K, Pair<ObservableList<A>, ObservableList<B>>> {
val leftTableMap = associateByAggregation(leftToJoinKey)
val rightTableMap = rightTable.associateByAggregation(rightToJoinKey)
val joinedMap: ObservableMap<K, Pair<ObservableList<A>, ObservableList<B>>> =
LeftOuterJoinedMap(leftTableMap, rightTableMap) { _, left, rightValue ->
return LeftOuterJoinedMap(leftTableMap, rightTableMap) { _, left, rightValue ->
Pair(left, ChosenList(rightValue.map { it ?: FXCollections.emptyObservableList() }, "ChosenList from leftOuterJoin"))
}
return joinedMap
}
fun <A> ObservableList<A>.getValueAt(index: Int): ObservableValue<A?> {

View File

@ -56,7 +56,7 @@ open class ReadOnlyBackedObservableMapBase<K, A, B> : ObservableMap<K, A> {
override fun containsValue(value: A) = backingMap.any { it.value.first == value }
override fun get(key: K) = backingMap.get(key)?.first
override fun get(key: K) = backingMap[key]?.first
override fun isEmpty() = backingMap.isEmpty()

View File

@ -43,14 +43,14 @@ class ReplayedList<A>(sourceList: ObservableList<A>) : TransformationList<A, A>(
}
nextPermutation(from, to, permutation)
} else if (c.wasUpdated()) {
for (i in c.from..c.to - 1) {
for (i in c.from until c.to) {
replayedList[i] = c.list[i]
nextUpdate(i)
}
} else {
if (c.wasRemoved()) {
val removePosition = c.from
for (i in 0..c.removedSize - 1) {
for (i in 0 until c.removedSize) {
replayedList.removeAt(removePosition)
}
nextRemove(c.from, c.removed)
@ -58,7 +58,7 @@ class ReplayedList<A>(sourceList: ObservableList<A>) : TransformationList<A, A>(
if (c.wasAdded()) {
val addStart = c.from
val addEnd = c.to
for (i in addStart..addEnd - 1) {
for (i in addStart until addEnd) {
replayedList.add(i, c.list[i])
}
nextAdd(addStart, addEnd)

View File

@ -29,9 +29,10 @@ class ExchangeRateModelTest {
private fun assertEquals(one: Amount<Currency>, another: Amount<Currency>) {
assertEquals(one.token, another.token)
assertTrue("$one != $another", {(one.toDecimal() - another.toDecimal()).abs() < BigDecimal(0.01) })
assertTrue("$one != $another", { (one.toDecimal() - another.toDecimal()).abs() < BigDecimal(0.01) })
}
}
@Test
fun `perform fx testing`() {
val tenSwissies = Amount(10, BigDecimal.ONE, CHF)

View File

@ -19,9 +19,9 @@ import kotlin.test.fail
class AggregatedListTest {
lateinit var sourceList: ObservableList<Int>
lateinit var aggregatedList: ObservableList<Pair<Int, ObservableList<Int>>>
lateinit var replayedList: ObservableList<Pair<Int, ObservableList<Int>>>
private lateinit var sourceList: ObservableList<Int>
private lateinit var aggregatedList: ObservableList<Pair<Int, ObservableList<Int>>>
private lateinit var replayedList: ObservableList<Pair<Int, ObservableList<Int>>>
@Before
fun setup() {

View File

@ -34,14 +34,13 @@ class ConcatenatedListTest {
fun <A> ConcatenatedList<A>.checkInvariants() {
assertEquals(nestedIndexOffsets.size, source.size)
var currentOffset = 0
for (i in 0..source.size - 1) {
for (i in 0 until source.size) {
currentOffset += source[i].size
assertEquals(nestedIndexOffsets[i], currentOffset)
}
assertEquals(indexMap.size, source.size)
for (entry in indexMap) {
val (wrapped, pair) = entry
for ((wrapped, pair) in indexMap) {
val index = pair.first
val foundListIndices = ArrayList<Int>()
source.forEachIndexed { i, list ->
@ -134,11 +133,7 @@ class ConcatenatedListTest {
assertEquals(replayedList[2], "b")
assertEquals(replayedList[3], "c")
sourceList.sortWith(object : Comparator<ObservableList<String>> {
override fun compare(p0: ObservableList<String>, p1: ObservableList<String>): Int {
return p0.size - p1.size
}
})
sourceList.sortWith(Comparator<ObservableList<String>> { p0, p1 -> p0.size - p1.size })
concatenatedList.checkInvariants()
assertEquals(replayedList.size, 4)
assertEquals(replayedList[0], "hello")
@ -147,11 +142,7 @@ class ConcatenatedListTest {
assertEquals(replayedList[3], "b")
sourceList.add(0, FXCollections.observableArrayList("d", "e", "f"))
sourceList.sortWith(object : Comparator<ObservableList<String>> {
override fun compare(p0: ObservableList<String>, p1: ObservableList<String>): Int {
return p0.size - p1.size
}
})
sourceList.sortWith(Comparator<ObservableList<String>> { p0, p1 -> p0.size - p1.size })
concatenatedList.checkInvariants()
assertEquals(replayedList.size, 7)
assertEquals(replayedList[0], "hello")

View File

@ -44,7 +44,6 @@ class MappedListTest {
assertEquals(replayedList[0], 7)
assertEquals(replayedList[1], 5)
assertEquals(replayedList[2], 3)
}
@Test

View File

@ -20,14 +20,14 @@ import kotlin.test.assertEquals
class ReplayedMap<K, A>(sourceMap: ObservableMap<K, A>) : ReadOnlyBackedObservableMapBase<K, A, Unit>() {
init {
sourceMap.forEach {
backingMap.set(it.key, Pair(it.value, Unit))
backingMap[it.key] = Pair(it.value, Unit)
}
sourceMap.addListener { change: MapChangeListener.Change<out K, out A> ->
if (change.wasRemoved()) {
assertEquals(backingMap.remove(change.key)!!.first, change.valueRemoved)
}
if (change.wasAdded()) {
backingMap.set(change.key, Pair(change.valueAdded, Unit))
backingMap[change.key] = Pair(change.valueAdded, Unit)
}
fireChange(change)
}

View File

@ -11,10 +11,6 @@
package net.corda.client.rpc.internal
import co.paralleluniverse.common.util.SameThreadExecutor
import com.esotericsoftware.kryo.Kryo
import com.esotericsoftware.kryo.Serializer
import com.esotericsoftware.kryo.io.Input
import com.esotericsoftware.kryo.io.Output
import com.github.benmanes.caffeine.cache.Cache
import com.github.benmanes.caffeine.cache.Caffeine
import com.github.benmanes.caffeine.cache.RemovalCause
@ -44,18 +40,27 @@ import net.corda.nodeapi.internal.DeduplicationChecker
import org.apache.activemq.artemis.api.core.ActiveMQException
import org.apache.activemq.artemis.api.core.RoutingType
import org.apache.activemq.artemis.api.core.SimpleString
import org.apache.activemq.artemis.api.core.client.*
import org.apache.activemq.artemis.api.core.client.ActiveMQClient.DEFAULT_ACK_BATCH_SIZE
import org.apache.activemq.artemis.api.core.client.ClientConsumer
import org.apache.activemq.artemis.api.core.client.ClientMessage
import org.apache.activemq.artemis.api.core.client.ClientProducer
import org.apache.activemq.artemis.api.core.client.ClientSession
import org.apache.activemq.artemis.api.core.client.ClientSessionFactory
import org.apache.activemq.artemis.api.core.client.FailoverEventType
import org.apache.activemq.artemis.api.core.client.ServerLocator
import rx.Notification
import rx.Observable
import rx.subjects.UnicastSubject
import java.lang.reflect.InvocationHandler
import java.lang.reflect.Method
import java.time.Instant
import java.util.*
import java.util.concurrent.*
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
import java.util.concurrent.ScheduledExecutorService
import java.util.concurrent.ScheduledFuture
import java.util.concurrent.TimeUnit
import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.atomic.AtomicInteger
import java.util.concurrent.atomic.AtomicLong
import kotlin.reflect.jvm.javaMethod
@ -162,7 +167,7 @@ class RPCClientProxyHandler(
private val serializationContextWithObservableContext = RpcClientObservableSerializer.createContext(serializationContext, observableContext)
private fun createRpcObservableMap(): RpcObservableMap {
val onObservableRemove = RemovalListener<InvocationId, UnicastSubject<Notification<*>>> { key, value, cause ->
val onObservableRemove = RemovalListener<InvocationId, UnicastSubject<Notification<*>>> { key, _, cause ->
val observableId = key!!
val rpcCallSite = callSiteMap?.remove(observableId)
if (cause == RemovalCause.COLLECTED) {
@ -454,7 +459,7 @@ class RPCClientProxyHandler(
log.debug("Trying to connect using ${transport.params}")
try {
if (serverLocator != null && !serverLocator.isClosed) {
if (!serverLocator.isClosed) {
sessionFactory = serverLocator.createSessionFactory(transport)
} else {
log.warn("Stopping reconnect attempts.")

View File

@ -55,7 +55,6 @@ class KryoClientSerializationScheme : AbstractKryoSerializationScheme() {
},
if (classLoader != null) AMQP_P2P_CONTEXT.withClassLoader(classLoader) else AMQP_P2P_CONTEXT,
rpcClientContext = if (classLoader != null) KRYO_RPC_CLIENT_CONTEXT.withClassLoader(classLoader) else KRYO_RPC_CLIENT_CONTEXT)
}
}
}

View File

@ -57,7 +57,7 @@ object RpcClientObservableSerializer : Serializer<Observable<*>>() {
}.dematerialize()
}
private fun Input.readInvocationId() : Trace.InvocationId? {
private fun Input.readInvocationId(): Trace.InvocationId? {
val value = readString() ?: return null
val timestamp = readLong()

View File

@ -228,7 +228,7 @@ class StandaloneCordaRPClientTest {
flowHandle.returnValue.get()
val balance = rpcProxy.getCashBalance(USD)
println("Balance: " + balance)
println("Balance: $balance")
assertEquals(629.DOLLARS, balance)
}

View File

@ -59,7 +59,7 @@ class RPCConcurrencyTests : AbstractRPCTest() {
override fun newLatch(numberOfDowns: Int): Long {
val id = random63BitValue()
val latch = CountDownLatch(numberOfDowns)
latches.put(id, latch)
latches[id] = latch
return id
}

View File

@ -68,7 +68,7 @@ class RPCFailureTests {
}
@Test
fun `unserializable`() = rpc {
fun unserializable() = rpc {
assertThatThrownBy { it.getUnserializable() }.isInstanceOf(KryoException::class.java)
}

View File

@ -16,11 +16,11 @@ class RepeatingBytesInputStream(val bytesToRepeat: ByteArray, val numberOfBytes:
private var bytesLeft = numberOfBytes
override fun available() = bytesLeft
override fun read(): Int {
if (bytesLeft == 0) {
return -1
return if (bytesLeft == 0) {
-1
} else {
bytesLeft--
return bytesToRepeat[(numberOfBytes - bytesLeft) % bytesToRepeat.size].toInt()
bytesToRepeat[(numberOfBytes - bytesLeft) % bytesToRepeat.size].toInt()
}
}

View File

@ -90,7 +90,7 @@ class SwapIdentitiesFlow(private val otherParty: Party,
// TODO: for increased privacy, we should create one anonymous key per output state.
val identities = LinkedHashMap<Party, AnonymousParty>()
if (serviceHub.myInfo.isLegalIdentity(otherParty)) {
identities.put(otherParty, legalIdentityAnonymous.party.anonymise())
identities[otherParty] = legalIdentityAnonymous.party.anonymise()
} else {
val otherSession = initiateFlow(otherParty)
val data = buildDataToSign(legalIdentityAnonymous)

View File

@ -119,7 +119,7 @@ class IdentitySyncFlowTests {
* Very lightweight wrapping flow to trigger the counterparty flow that receives the identities.
*/
@InitiatingFlow
class Initiator(private val otherSide: Party, private val tx: WireTransaction): FlowLogic<Boolean>() {
class Initiator(private val otherSide: Party, private val tx: WireTransaction) : FlowLogic<Boolean>() {
@Suspendable
override fun call(): Boolean {
val session = initiateFlow(otherSide)
@ -130,7 +130,7 @@ class IdentitySyncFlowTests {
}
@InitiatedBy(IdentitySyncFlowTests.Initiator::class)
class Receive(private val otherSideSession: FlowSession): FlowLogic<Unit>() {
class Receive(private val otherSideSession: FlowSession) : FlowLogic<Unit>() {
@Suspendable
override fun call() {
subFlow(IdentitySyncFlow.Receive(otherSideSession))

View File

@ -8,7 +8,7 @@
# Distribution of this file or any portion thereof via any medium without the express permission of R3 is strictly prohibited.
#
gradlePluginsVersion=4.0.15
gradlePluginsVersion=4.0.19
kotlinVersion=1.2.41
platformVersion=4
guavaVersion=21.0

View File

@ -93,7 +93,7 @@ public class Base58 {
* @throws AddressFormatException if the given string is not a valid base58 string
*/
public static byte[] decode(String input) throws AddressFormatException {
if (input.length() == 0) {
if (input.isEmpty()) {
return new byte[0];
}
// Convert the base58-encoded ASCII chars to a base58 byte sequence (base58 digits).

View File

@ -20,7 +20,8 @@ public interface IdentifiableException {
/**
* @return the ID of the error, or null if the error doesn't have it set (yet).
*/
default @Nullable Long getErrorId() {
@Nullable
default Long getErrorId() {
return null;
}
}

View File

@ -18,10 +18,10 @@ object CordaOID {
/** Assigned to R3, see http://www.oid-info.com/cgi-bin/display?oid=1.3.6.1.4.1.50530&action=display */
const val R3_ROOT = "1.3.6.1.4.1.50530"
/** OIDs issued for the Corda platform */
const val CORDA_PLATFORM = R3_ROOT + ".1"
const val CORDA_PLATFORM = "$R3_ROOT.1"
/**
* Identifier for the X.509 certificate extension specifying the Corda role. See
* https://r3-cev.atlassian.net/wiki/spaces/AWG/pages/156860572/Certificate+identity+type+extension for details.
*/
const val X509_EXTENSION_CORDA_ROLE = CORDA_PLATFORM + ".1"
const val X509_EXTENSION_CORDA_ROLE = "$CORDA_PLATFORM.1"
}

View File

@ -46,12 +46,12 @@ internal fun <V, W> firstOf(futures: Array<out CordaFuture<out V>>, log: Logger,
val winnerChosen = AtomicBoolean()
futures.forEach {
it.then {
if (winnerChosen.compareAndSet(false, true)) {
resultFuture.capture { handler(it) }
} else if (it.isCancelled) {
when {
winnerChosen.compareAndSet(false, true) -> resultFuture.capture { handler(it) }
it.isCancelled -> {
// Do nothing.
} else {
it.match({}, { log.error(shortCircuitedTaskFailedMessage, it) })
}
else -> it.match({}, { log.error(shortCircuitedTaskFailedMessage, it) })
}
}
}

View File

@ -87,7 +87,6 @@ data class Actor(val id: Id, val serviceId: AuthServiceId, val owningLegalIdenti
*/
@CordaSerializable
data class Id(val value: String)
}
/**

View File

@ -37,7 +37,7 @@ data class Trace(val invocationId: InvocationId, val sessionId: SessionId) {
class InvocationId(value: String, timestamp: Instant) : Id<String>(value, TYPE, timestamp) {
companion object {
private val TYPE = "Invocation"
private const val TYPE = "Invocation"
/**
* Creates an invocation id using a [java.util.UUID] as value and [Instant.now] as timestamp.
@ -54,7 +54,7 @@ data class Trace(val invocationId: InvocationId, val sessionId: SessionId) {
class SessionId(value: String, timestamp: Instant) : Id<String>(value, TYPE, timestamp) {
companion object {
private val TYPE = "Session"
private const val TYPE = "Session"
/**
* Creates a session id using a [java.util.UUID] as value and [Instant.now] as timestamp.

View File

@ -260,7 +260,7 @@ data class Amount<T : Any>(val quantity: Long, val displayTokenSize: BigDecimal,
val residualTokens = quantity - (commonTokensPerPartition * partitions)
val splitAmount = Amount(commonTokensPerPartition, displayTokenSize, token)
val splitAmountPlusOne = Amount(commonTokensPerPartition + 1L, displayTokenSize, token)
return (0..partitions - 1).map { if (it < residualTokens) splitAmountPlusOne else splitAmount }.toList()
return (0 until partitions).map { if (it < residualTokens) splitAmountPlusOne else splitAmount }.toList()
}
/**

View File

@ -20,11 +20,11 @@ import net.corda.core.serialization.CordaSerializable
* @property additionalContracts Additional contract names contained within the JAR.
*/
@CordaSerializable
class ContractAttachment @JvmOverloads constructor (val attachment: Attachment, val contract: ContractClassName, val additionalContracts: Set<ContractClassName> = emptySet(), val uploader: String? = null) : Attachment by attachment {
class ContractAttachment @JvmOverloads constructor(val attachment: Attachment, val contract: ContractClassName, val additionalContracts: Set<ContractClassName> = emptySet(), val uploader: String? = null) : Attachment by attachment {
val allContracts: Set<ContractClassName> get() = additionalContracts + contract
override fun toString(): String {
return "ContractAttachment(attachment=${attachment.id}, contracts='${allContracts}', uploader='${uploader}')"
return "ContractAttachment(attachment=${attachment.id}, contracts='$allContracts', uploader='$uploader')"
}
}

View File

@ -30,7 +30,7 @@ import java.util.*
object Requirements {
/** Throws [IllegalArgumentException] if the given expression evaluates to false. */
@Suppress("NOTHING_TO_INLINE") // Inlining this takes it out of our committed ABI.
infix inline fun String.using(expr: Boolean) {
inline infix fun String.using(expr: Boolean) {
if (!expr) throw IllegalArgumentException("Failed requirement: $this")
}
}

View File

@ -206,7 +206,7 @@ data class Command<T : CommandData>(val value: T, val signers: List<PublicKey>)
constructor(data: T, key: PublicKey) : this(data, listOf(key))
private fun commandDataToString() = value.toString().let { if (it.contains("@")) it.replace('$', '.').split("@")[0] else it }
override fun toString() = "${commandDataToString()} with pubkeys ${signers.map { it.toStringShort() }.joinToString()}"
override fun toString() = "${commandDataToString()} with pubkeys ${signers.joinToString { it.toStringShort() }}"
}
/** A common move command for contract states which can change owner. */

View File

@ -118,8 +118,10 @@ sealed class TransactionVerificationException(val txId: SecureHash, message: Str
/** Whether the inputs or outputs list contains an encumbrance issue, see [TransactionMissingEncumbranceException]. */
@CordaSerializable
enum class Direction {
/** Issue in the inputs list */ INPUT,
/** Issue in the outputs list */ OUTPUT
/** Issue in the inputs list */
INPUT,
/** Issue in the outputs list */
OUTPUT
}
// We could revisit and throw this more appropriate type in a future release that uses targetVersion to

View File

@ -110,7 +110,7 @@ class CompositeKey private constructor(val threshold: Int, children: List<NodeAn
// We can't print the node details, because doing so involves serializing the node, which we can't
// do because of the cyclic graph.
require(!curVisitedMap.contains(node)) { "Cycle detected for CompositeKey" }
curVisitedMap.put(node, true)
curVisitedMap[node] = true
node.cycleDetection(curVisitedMap)
}
}
@ -126,7 +126,7 @@ class CompositeKey private constructor(val threshold: Int, children: List<NodeAn
fun checkValidity() {
if (validated) return
val visitedMap = IdentityHashMap<CompositeKey, Boolean>()
visitedMap.put(this, true)
visitedMap[this] = true
cycleDetection(visitedMap) // Graph cycle testing on the root node.
checkConstraints()
for ((node, _) in children) {
@ -281,15 +281,17 @@ class CompositeKey private constructor(val threshold: Int, children: List<NodeAn
fun build(threshold: Int? = null): PublicKey {
require(threshold == null || threshold > 0)
val n = children.size
return if (n > 1)
CompositeKey(threshold ?: children.map { (_, weight) -> weight }.sum(), children)
else if (n == 1) {
return when {
n > 1 -> CompositeKey(threshold ?: children.map { (_, weight) -> weight }.sum(), children)
n == 1 -> {
require(threshold == null || threshold == children.first().weight)
{ "Trying to build invalid CompositeKey, threshold value different than weight of single child node." }
// Returning the only child node which is [PublicKey] itself. We need to avoid single-key [CompositeKey] instances,
// as there are scenarios where developers expected the underlying key and its composite versions to be equivalent.
children.first().node
} else throw IllegalStateException("Trying to build CompositeKey without child nodes.")
}
else -> throw IllegalStateException("Trying to build CompositeKey without child nodes.")
}
}
}
}

View File

@ -58,8 +58,8 @@ sealed class MerkleTree {
* @return Tree root.
*/
private tailrec fun buildMerkleTree(lastNodesList: List<MerkleTree>): MerkleTree {
if (lastNodesList.size == 1) {
return lastNodesList[0] // Root reached.
return if (lastNodesList.size == 1) {
lastNodesList[0] // Root reached.
} else {
val newLevelHashes: MutableList<MerkleTree> = ArrayList()
val n = lastNodesList.size
@ -71,7 +71,7 @@ sealed class MerkleTree {
val combined = Node(newHash, left, right)
newLevelHashes.add(combined)
}
return buildMerkleTree(newLevelHashes)
buildMerkleTree(newLevelHashes)
}
}
}

View File

@ -28,5 +28,4 @@ object NullKeys {
/** A signature with a key and value of zero. Useful when you want a signature object that you know won't ever be used. */
val NULL_SIGNATURE = TransactionSignature(ByteArray(32), NullPublicKey, SignatureMetadata(1, -1))
}

View File

@ -46,7 +46,7 @@ open class SignedData<T : Any>(val raw: SerializedBytes<T>, val sig: DigitalSign
* @throws IllegalArgumentException if the data is invalid.
*/
@Throws(IllegalArgumentException::class)
open protected fun verifyData(data: T) {
protected open fun verifyData(data: T) {
// By default we accept anything
}
}

View File

@ -80,7 +80,7 @@ abstract class AbstractStateReplacementFlow {
val finalTx = stx + signatures
serviceHub.recordTransactions(finalTx)
return stx.resolveBaseTransaction(serviceHub).outRef<T>(0)
return stx.resolveBaseTransaction(serviceHub).outRef(0)
}
/**
@ -88,7 +88,7 @@ abstract class AbstractStateReplacementFlow {
*
* @return the transaction
*/
abstract protected fun assembleTx(): UpgradeTx
protected abstract fun assembleTx(): UpgradeTx
/**
* Initiate sessions with parties we want signatures from.
@ -186,7 +186,7 @@ abstract class AbstractStateReplacementFlow {
* The proposal is returned if acceptable, otherwise a [StateReplacementException] is thrown.
*/
@Throws(StateReplacementException::class)
abstract protected fun verifyProposal(stx: SignedTransaction, proposal: Proposal<T>)
protected abstract fun verifyProposal(stx: SignedTransaction, proposal: Proposal<T>)
private fun checkMySignatureRequired(stx: SignedTransaction) {
// TODO: use keys from the keyManagementService instead

View File

@ -88,7 +88,8 @@ class CollectSignaturesFlow @JvmOverloads constructor(val partiallySignedTx: Sig
}
@Suspendable override fun call(): SignedTransaction {
@Suspendable
override fun call(): SignedTransaction {
// Check the signatures which have already been provided and that the transaction is valid.
// Usually just the Initiator and possibly an oracle would have signed at this point.
val myKeys: Iterable<PublicKey> = myOptionalKeys ?: listOf(ourIdentity.owningKey)
@ -216,7 +217,8 @@ abstract class SignTransactionFlow(val otherSideSession: FlowSession,
fun tracker() = ProgressTracker(RECEIVING, VERIFYING, SIGNING)
}
@Suspendable override fun call(): SignedTransaction {
@Suspendable
override fun call(): SignedTransaction {
progressTracker.currentStep = RECEIVING
// Receive transaction and resolve dependencies, check sufficient signatures is disabled as we don't have all signatures.
val stx = subFlow(ReceiveTransactionFlow(otherSideSession, checkSufficientSignatures = false))
@ -253,12 +255,13 @@ abstract class SignTransactionFlow(val otherSideSession: FlowSession,
return stx + mySignatures
}
@Suspendable private fun checkSignatures(stx: SignedTransaction) {
@Suspendable
private fun checkSignatures(stx: SignedTransaction) {
// We set `ignoreUnrecognisedParties` to `true` in `groupPublicKeysByWellKnownParty`. This is because we don't
// need to recognise all keys, but just the initiator's.
val signingWellKnownIdentities = groupPublicKeysByWellKnownParty(serviceHub, stx.sigs.map(TransactionSignature::by), true)
require(otherSideSession.counterparty in signingWellKnownIdentities) {
"The Initiator of CollectSignaturesFlow must have signed the transaction. Found ${signingWellKnownIdentities}, expected ${otherSideSession}"
"The Initiator of CollectSignaturesFlow must have signed the transaction. Found $signingWellKnownIdentities, expected $otherSideSession"
}
val signed = stx.sigs.map { it.by }
val allSigners = stx.tx.requiredSigningKeys
@ -288,9 +291,10 @@ abstract class SignTransactionFlow(val otherSideSession: FlowSession,
*/
@Suspendable
@Throws(FlowException::class)
abstract protected fun checkTransaction(stx: SignedTransaction)
protected abstract fun checkTransaction(stx: SignedTransaction)
@Suspendable private fun checkMySignaturesRequired(stx: SignedTransaction, signingKeys: Iterable<PublicKey>) {
@Suspendable
private fun checkMySignaturesRequired(stx: SignedTransaction, signingKeys: Iterable<PublicKey>) {
require(signingKeys.all { it in stx.tx.requiredSigningKeys }) {
"A signature was requested for a key that isn't part of the required signing keys for transaction ${stx.id}"
}

View File

@ -36,6 +36,7 @@ open class FlowException(message: String?, cause: Throwable?) :
constructor(message: String?) : this(message, null)
constructor(cause: Throwable?) : this(cause?.toString(), cause)
constructor() : this(null, null)
var originalErrorId: Long? = null
override fun getErrorId(): Long? = originalErrorId
}
@ -50,5 +51,6 @@ class UnexpectedFlowEndException(message: String, cause: Throwable?, val origina
CordaRuntimeException(message, cause), IdentifiableException {
constructor(message: String, cause: Throwable?) : this(message, cause, null)
constructor(message: String) : this(message, null)
override fun getErrorId(): Long? = originalErrorId
}

View File

@ -60,7 +60,8 @@ sealed class FlowInitiator : Principal {
* class hierarchy (which is now deprecated). The returned object has less information than it could have, so
* prefer to use fetch an invocation context directly if you can (e.g. in [net.corda.core.messaging.StateMachineInfo])
*/
val invocationContext: InvocationContext get() {
val invocationContext: InvocationContext
get() {
val unknownName = CordaX500Name("UNKNOWN", "UNKNOWN", "GB")
var actor: Actor? = null
val origin: InvocationOrigin

View File

@ -128,7 +128,8 @@ data class CordaX500Name(val commonName: String?,
private var _x500Principal: X500Principal? = null
/** Return the [X500Principal] equivalent of this name. */
val x500Principal: X500Principal get() {
val x500Principal: X500Principal
get() {
return _x500Principal ?: X500Principal(this.x500Name.encoded).also { _x500Principal = it }
}

View File

@ -55,7 +55,10 @@ object Emoji {
val CODE_FREE: String = codePointsString(0x1F193)
@JvmStatic
val CODE_SOON: String = codePointsString(0x1F51C)
@JvmStatic
val CODE_DEVELOPER: String = codePointsString(0x1F469, 0x200D, 0x1F4BB)
@JvmStatic
val CODE_WARNING_SIGN: String = codePointsString(0x26A0, 0xFE0F)
/**
* When non-null, toString() methods are allowed to use emoji in the output as we're going to render them to a
@ -75,6 +78,8 @@ object Emoji {
val lightBulb: String get() = if (emojiMode.get() != null) "$CODE_LIGHTBULB " else ""
val free: String get() = if (emojiMode.get() != null) "$CODE_FREE " else ""
val soon: String get() = if (emojiMode.get() != null) "$CODE_SOON " else ""
val developer: String get() = if (emojiMode.get() != null) "$CODE_DEVELOPER " else ""
val warningSign: String get() = if (emojiMode.get() != null) "$CODE_WARNING_SIGN " else "!"
// These have old/non-emoji symbols with better platform support.
val greenTick: String get() = if (emojiMode.get() != null) "$CODE_GREEN_TICK " else ""

View File

@ -145,7 +145,6 @@ sealed class FetchDataFlow<T : NamedByHash, in W : Any>(
}
}
/**
* Given a set of hashes either loads from from local storage or requests them from the other peer. Downloaded
* attachments are saved to local storage automatically.

View File

@ -61,7 +61,8 @@ sealed class FlowIORequest<out R : Any> {
val shouldRetrySend: Boolean
) : FlowIORequest<Map<FlowSession, SerializedBytes<Any>>>() {
override fun toString() = "SendAndReceive(${sessionToMessage.mapValues { (key, value) ->
"$key=${value.hash}" }}, shouldRetrySend=$shouldRetrySend)"
"$key=${value.hash}"
}}, shouldRetrySend=$shouldRetrySend)"
}
/**

View File

@ -13,10 +13,12 @@ package net.corda.core.internal
import co.paralleluniverse.fibers.Suspendable
import net.corda.core.DoNotImplement
import net.corda.core.concurrent.CordaFuture
import net.corda.core.flows.*
import net.corda.core.identity.Party
import net.corda.core.identity.PartyAndCertificate
import net.corda.core.context.InvocationContext
import net.corda.core.flows.FlowLogic
import net.corda.core.flows.FlowSession
import net.corda.core.flows.FlowStackSnapshot
import net.corda.core.flows.StateMachineRunId
import net.corda.core.identity.Party
import net.corda.core.node.ServiceHub
import org.slf4j.Logger

View File

@ -49,10 +49,10 @@ class LazyPool<A>(
lifeCycle.requireState(State.STARTED)
poolSemaphore.acquire()
val pooled = poolQueue.poll()
if (pooled == null) {
return newInstance()
return if (pooled == null) {
newInstance()
} else {
return clearIfNeeded(pooled)
clearIfNeeded(pooled)
}
}

View File

@ -76,6 +76,6 @@ class LazyStickyPool<A : Any>(
}
fun close(): Iterable<A> {
return boxes.map { it.instance?.poll() }.filterNotNull()
return boxes.mapNotNull { it.instance?.poll() }
}
}

View File

@ -10,4 +10,4 @@
package net.corda.core.internal
val STRUCTURAL_STEP_PREFIX = "Structural step change in child of "
const val STRUCTURAL_STEP_PREFIX = "Structural step change in child of "

View File

@ -39,7 +39,7 @@ class X509EdDSAEngine : Signature {
override fun engineInitVerify(publicKey: PublicKey) {
val parsedKey = try {
publicKey as? EdDSAPublicKey ?: EdDSAPublicKey(X509EncodedKeySpec(publicKey.encoded))
} catch(e: Exception) {
} catch (e: Exception) {
throw (InvalidKeyException(e.message))
}
engine.initVerify(parsedKey)
@ -53,9 +53,9 @@ class X509EdDSAEngine : Signature {
override fun engineGetParameters(): AlgorithmParameters = engine.parameters
override fun engineSetParameter(params: AlgorithmParameterSpec) = engine.setParameter(params)
@Suppress("DEPRECATION")
@Suppress("DEPRECATION", "OverridingDeprecatedMember")
override fun engineGetParameter(param: String): Any = engine.getParameter(param)
@Suppress("DEPRECATION")
@Suppress("DEPRECATION", "OverridingDeprecatedMember")
override fun engineSetParameter(param: String, value: Any?) = engine.setParameter(param, value)
}

View File

@ -152,7 +152,7 @@ interface OpenFuture<V> : ValueOrException<V>, CordaFuture<V>
internal class CordaFutureImpl<V>(private val impl: CompletableFuture<V> = CompletableFuture()) : Future<V> by impl, OpenFuture<V> {
companion object {
private val defaultLog = contextLogger()
internal val listenerFailedMessage = "Future listener failed:"
internal const val listenerFailedMessage = "Future listener failed:"
}
override fun set(value: V) = impl.complete(value)

View File

@ -64,7 +64,6 @@ interface FlowProgressHandle<A> : FlowHandle<A> {
override fun close()
}
@CordaSerializable
data class FlowHandleImpl<A>(
override val id: StateMachineRunId,

View File

@ -36,5 +36,4 @@ interface AppServiceHub : ServiceHub {
* TODO it is assumed here that the flow object has an appropriate classloader.
*/
fun <T> startTrackedFlow(flow: FlowLogic<T>): FlowProgressHandle<T>
}

View File

@ -41,7 +41,8 @@ data class NodeInfo(val addresses: List<NetworkHostAndPort>,
require(platformVersion > 0) { "Platform version must be at least 1" }
}
@Transient private var _legalIdentities: List<Party>? = null
@Transient
private var _legalIdentities: List<Party>? = null
/**
* An ordered list of legal identities supported by this node. The node will always have at least one, so if you

View File

@ -253,7 +253,7 @@ object Builder {
fun <R> Field.functionPredicate(predicate: ColumnPredicate<R>, groupByColumns: List<Column<Any, R>>? = null, orderBy: Sort.Direction? = null) = info().functionPredicate(predicate, groupByColumns, orderBy)
fun <R> FieldInfo.functionPredicate(predicate: ColumnPredicate<R>, groupByColumns: List<Column<Any, R>>? = null, orderBy: Sort.Direction? = null)
= CriteriaExpression.AggregateFunctionExpression(Column<Any, R>(this), predicate, groupByColumns, orderBy)
= CriteriaExpression.AggregateFunctionExpression(Column(this), predicate, groupByColumns, orderBy)
fun <O, R : Comparable<R>> KProperty1<O, R?>.comparePredicate(operator: BinaryComparisonOperator, value: R) = predicate(compare(operator, value))
@Deprecated("Does not support fields from a MappedSuperclass. Use equivalent on a FieldInfo.")
@ -377,7 +377,7 @@ object Builder {
@JvmStatic
@JvmOverloads
fun <R> FieldInfo.sum(groupByColumns: List<FieldInfo>? = null, orderBy: Sort.Direction? = null) =
functionPredicate(ColumnPredicate.AggregateFunction<R>(AggregateFunctionType.SUM), groupByColumns?.map { Column<Any, R>(it) }, orderBy)
functionPredicate(ColumnPredicate.AggregateFunction(AggregateFunctionType.SUM), groupByColumns?.map { Column<Any, R>(it) }, orderBy)
fun <O, R> KProperty1<O, R?>.count() = functionPredicate(ColumnPredicate.AggregateFunction(AggregateFunctionType.COUNT))
@JvmStatic
@ -397,7 +397,7 @@ object Builder {
@JvmStatic
@JvmOverloads
fun <R> FieldInfo.avg(groupByColumns: List<FieldInfo>? = null, orderBy: Sort.Direction? = null) =
functionPredicate(ColumnPredicate.AggregateFunction<R>(AggregateFunctionType.AVG), groupByColumns?.map { Column<Any, R>(it) }, orderBy)
functionPredicate(ColumnPredicate.AggregateFunction(AggregateFunctionType.AVG), groupByColumns?.map { Column<Any, R>(it) }, orderBy)
fun <O, R> KProperty1<O, R?>.min(groupByColumns: List<KProperty1<O, R>>? = null, orderBy: Sort.Direction? = null) =
functionPredicate(ColumnPredicate.AggregateFunction(AggregateFunctionType.MIN), groupByColumns?.map { Column(it) }, orderBy)
@ -410,7 +410,7 @@ object Builder {
@JvmStatic
@JvmOverloads
fun <R> FieldInfo.min(groupByColumns: List<FieldInfo>? = null, orderBy: Sort.Direction? = null) =
functionPredicate(ColumnPredicate.AggregateFunction<R>(AggregateFunctionType.MIN), groupByColumns?.map { Column<Any, R>(it) }, orderBy)
functionPredicate(ColumnPredicate.AggregateFunction(AggregateFunctionType.MIN), groupByColumns?.map { Column<Any, R>(it) }, orderBy)
fun <O, R> KProperty1<O, R?>.max(groupByColumns: List<KProperty1<O, R>>? = null, orderBy: Sort.Direction? = null) =
functionPredicate(ColumnPredicate.AggregateFunction(AggregateFunctionType.MAX), groupByColumns?.map { Column(it) }, orderBy)
@ -423,7 +423,7 @@ object Builder {
@JvmStatic
@JvmOverloads
fun <R> FieldInfo.max(groupByColumns: List<FieldInfo>? = null, orderBy: Sort.Direction? = null) =
functionPredicate(ColumnPredicate.AggregateFunction<R>(AggregateFunctionType.MAX), groupByColumns?.map { Column<Any, R>(it) }, orderBy)
functionPredicate(ColumnPredicate.AggregateFunction(AggregateFunctionType.MAX), groupByColumns?.map { Column<Any, R>(it) }, orderBy)
private fun Field.info(): FieldInfo = FieldInfo(name, declaringClass)
}

View File

@ -31,7 +31,7 @@ object CommonSchemaV1 : MappedSchema(schemaFamily = CommonSchema.javaClass, vers
override val migrationResource = "common.changelog-master"
@MappedSuperclass
open class LinearState(
class LinearState(
/** [ContractState] attributes */
/** X500Name of participant parties **/
@ -56,7 +56,7 @@ object CommonSchemaV1 : MappedSchema(schemaFamily = CommonSchema.javaClass, vers
}
@MappedSuperclass
open class FungibleState(
class FungibleState(
/** [ContractState] attributes */
/** X500Name of participant parties **/

View File

@ -89,7 +89,8 @@ open class MappedSchema(schemaFamily: Class<*>,
* [StateRef] will be set to the correct value by the framework (there's no need to set during mapping generation by the state itself).
*/
@MappedSuperclass
@CordaSerializable open class PersistentState(@EmbeddedId var stateRef: PersistentStateRef? = null) : StatePersistable
@CordaSerializable
class PersistentState(@EmbeddedId var stateRef: PersistentStateRef? = null) : StatePersistable
/**
* Embedded [StateRef] representation used in state mapping.

View File

@ -24,11 +24,11 @@ interface SerializationCustomSerializer<OBJ, PROXY> {
* Should facilitate the conversion of the third party object into the serializable
* local class specified by [PROXY]
*/
fun toProxy(obj: OBJ) : PROXY
fun toProxy(obj: OBJ): PROXY
/**
* Should facilitate the conversion of the proxy object into a new instance of the
* unserializable type
*/
fun fromProxy(proxy: PROXY) : OBJ
fun fromProxy(proxy: PROXY): OBJ
}

View File

@ -222,17 +222,17 @@ data class ContractUpgradeLedgerTransaction(
* Outputs are computed by running the contract upgrade logic on input states. This is done eagerly so that the
* transaction is verified during construction.
*/
override val outputs: List<TransactionState<ContractState>> = inputs.map { input ->
override val outputs: List<TransactionState<ContractState>> = inputs.map { (state) ->
// TODO: if there are encumbrance states in the inputs, just copy them across without modifying
val upgradedState = upgradedContract.upgrade(input.state.data)
val inputConstraint = input.state.constraint
val upgradedState = upgradedContract.upgrade(state.data)
val inputConstraint = state.constraint
val outputConstraint = when (inputConstraint) {
is HashAttachmentConstraint -> HashAttachmentConstraint(upgradedContractAttachment.id)
WhitelistedByZoneAttachmentConstraint -> WhitelistedByZoneAttachmentConstraint
else -> throw IllegalArgumentException("Unsupported input contract constraint $inputConstraint")
}
// TODO: re-map encumbrance pointers
input.state.copy(
state.copy(
data = upgradedState,
contract = upgradedContractClassName,
constraint = outputConstraint

View File

@ -116,7 +116,7 @@ class WireTransaction(componentGroups: List<ComponentGroup>, val privacySalt: Pr
resolveIdentity: (PublicKey) -> Party?,
resolveAttachment: (SecureHash) -> Attachment?,
resolveStateRef: (StateRef) -> TransactionState<*>?,
resolveContractAttachment: (TransactionState<ContractState>) -> AttachmentId?
@SuppressWarnings("unused") resolveContractAttachment: (TransactionState<ContractState>) -> AttachmentId?
): LedgerTransaction {
return toLedgerTransactionInternal(resolveIdentity, resolveAttachment, resolveStateRef, null)
}

View File

@ -41,7 +41,6 @@ fun ByteArray.toBase64(): String = Base64.getEncoder().encodeToString(this)
/** Convert a byte array to a hex (Base16) capitalized encoded [String]. */
fun ByteArray.toHex(): String = DatatypeConverter.printHexBinary(this)
// [String] encoders and decoders
/** Base58-String to the actual real [String], i.e. "JxF12TrwUP45BMd" -> "Hello World". */
@ -60,7 +59,6 @@ fun String.base64ToByteArray(): ByteArray = Base64.getDecoder().decode(this)
/** Hex-String to [ByteArray]. Accept any hex form (capitalized, lowercase, mixed). */
fun String.hexToByteArray(): ByteArray = DatatypeConverter.parseHexBinary(this)
// Encoding changers
/** Encoding changer. Base58-[String] to Base64-[String], i.e. "SGVsbG8gV29ybGQ=" -> JxF12TrwUP45BMd" */

View File

@ -116,8 +116,10 @@ interface VariablePropertyDelegate<T> : PropertyDelegate<T> {
@CordaSerializable
private class TransientProperty<out T> internal constructor(private val initialiser: () -> T) : PropertyDelegate<T> {
@Transient private var initialised = false
@Transient private var value: T? = null
@Transient
private var initialised = false
@Transient
private var value: T? = null
@Synchronized
override operator fun getValue(thisRef: Any?, property: KProperty<*>): T {

View File

@ -71,11 +71,11 @@ class ProgressTracker(vararg steps: Step) {
// Sentinel objects. Overrides equals() to survive process restarts and serialization.
object UNSTARTED : Step("Unstarted") {
override fun equals(other: Any?) = other is UNSTARTED
override fun equals(other: Any?) = other === UNSTARTED
}
object DONE : Step("Done") {
override fun equals(other: Any?) = other is DONE
override fun equals(other: Any?) = other === DONE
}
@CordaSerializable

View File

@ -50,7 +50,6 @@ fun <T : Any> SerializedBytes<Any>.checkPayloadIs(type: Class<T>): Untrustworthy
} catch (ex: Exception) {
throw IllegalArgumentException("Payload invalid", ex)
}
return type.castIfPossible(payloadData)?.let { UntrustworthyData(it) } ?:
throw IllegalArgumentException("We were expecting a ${type.name} but we instead got a " +
"${payloadData.javaClass.name} (${payloadData})")
return type.castIfPossible(payloadData)?.let { UntrustworthyData(it) } ?: throw IllegalArgumentException("We were expecting a ${type.name} but we instead got a " +
"${payloadData.javaClass.name} ($payloadData)")
}

View File

@ -15,6 +15,6 @@ import java.util.*
class UuidGenerator {
companion object {
fun next() : UUID = UUID.randomUUID()
fun next(): UUID = UUID.randomUUID()
}
}

View File

@ -35,7 +35,7 @@ public class FlowsInJavaTest {
private Party bob;
@Before
public void setUp() throws Exception {
public void setUp() {
aliceNode = mockNet.createPartyNode(TestConstants.ALICE_NAME);
bobNode = mockNet.createPartyNode(TestConstants.BOB_NAME);
bob = singleIdentity(bobNode.getInfo());
@ -134,7 +134,7 @@ public class FlowsInJavaTest {
@Suspendable
@Override
public Void call() throws FlowException {
public Void call() {
FlowSession session = initiateFlow(otherParty);
session.receive(Primitives.unwrap(receiveType));
return null;

View File

@ -51,7 +51,6 @@ class AttachmentTest {
}
assertEquals(1, closeCalls)
}
}
class UniqueIdentifierTests {
@ -83,5 +82,4 @@ class UniqueIdentifierTests {
assertEquals(ids[1], ids[2])
assertEquals(ids[1].hashCode(), ids[2].hashCode())
}
}

View File

@ -136,6 +136,5 @@ class X509NameConstraintsTest {
pathValidator.validate(certPath, params)
true
}
}
}

View File

@ -13,7 +13,6 @@ package net.corda.core.flows
import co.paralleluniverse.fibers.Suspendable
import net.corda.core.contracts.Attachment
import net.corda.core.crypto.SecureHash
import net.corda.core.crypto.sha256
import net.corda.core.identity.Party
import net.corda.core.internal.FetchAttachmentsFlow
import net.corda.core.internal.FetchDataFlow
@ -92,7 +91,7 @@ class AttachmentTests {
}
@Test
fun `missing`() {
fun missing() {
val aliceNode = mockNet.createPartyNode(ALICE_NAME)
val bobNode = mockNet.createPartyNode(BOB_NAME)
aliceNode.registerInitiatedFlow(FetchAttachmentsResponse::class.java)

View File

@ -23,7 +23,11 @@ import net.corda.core.transactions.TransactionBuilder
import net.corda.core.utilities.getOrThrow
import net.corda.node.internal.StartedNode
import net.corda.testing.contracts.DummyContract
import net.corda.testing.core.*
import net.corda.testing.core.ALICE_NAME
import net.corda.testing.core.BOB_NAME
import net.corda.testing.core.CHARLIE_NAME
import net.corda.testing.core.TestIdentity
import net.corda.testing.core.singleIdentity
import net.corda.testing.internal.rigorousMock
import net.corda.testing.node.MockServices
import net.corda.testing.node.internal.InternalMockNetwork
@ -32,7 +36,6 @@ import net.corda.testing.node.internal.startFlow
import org.junit.After
import org.junit.Before
import org.junit.Test
import kotlin.reflect.KClass
import kotlin.test.assertFailsWith
class CollectSignaturesFlowTests {
@ -86,9 +89,11 @@ class CollectSignaturesFlowTests {
@InitiatedBy(TestFlow.Initiator::class)
class Responder(private val otherSideSession: FlowSession) : FlowLogic<Unit>() {
@Suspendable override fun call() {
@Suspendable
override fun call() {
val signFlow = object : SignTransactionFlow(otherSideSession) {
@Suspendable override fun checkTransaction(stx: SignedTransaction) = requireThat {
@Suspendable
override fun checkTransaction(stx: SignedTransaction) = requireThat {
val tx = stx.tx
val ltx = tx.toLedgerTransaction(serviceHub)
"There should only be one output state" using (tx.outputs.size == 1)

View File

@ -19,7 +19,7 @@ import kotlin.test.assertNotEquals
class PartyTest {
@Test
fun `equality`() {
fun equality() {
val key = entropyToKeyPair(BigInteger.valueOf(20170207L)).public
val differentKey = entropyToKeyPair(BigInteger.valueOf(7201702L)).public
val anonymousParty = AnonymousParty(key)

View File

@ -21,7 +21,6 @@ import org.junit.Test
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import kotlin.streams.toList
import kotlin.test.assertEquals
class AbstractAttachmentTest {

View File

@ -71,7 +71,7 @@ class LegalNameValidatorTest {
}
// Latin capital letter turned m
assertFailsWith<IllegalArgumentException> {
LegalNameValidator.validateOrganization( "Test\u019CLtd", LegalNameValidator.Validation.FULL)
LegalNameValidator.validateOrganization("Test\u019CLtd", LegalNameValidator.Validation.FULL)
}
// Latin small letter turned e
assertFailsWith<IllegalArgumentException> {
@ -94,7 +94,7 @@ class LegalNameValidatorTest {
}
// Latin capital letter turned m
assertFailsWith<IllegalArgumentException> {
LegalNameValidator.validateNameAttribute( "Test\u019CLtd", LegalNameValidator.Validation.FULL)
LegalNameValidator.validateNameAttribute("Test\u019CLtd", LegalNameValidator.Validation.FULL)
}
// Latin small letter turned e
assertFailsWith<IllegalArgumentException> {

View File

@ -24,7 +24,7 @@ import kotlin.test.assertFailsWith
class VaultUpdateTests {
private companion object {
val DUMMY_PROGRAM_ID = "net.corda.core.node.VaultUpdateTests.DummyContract"
const val DUMMY_PROGRAM_ID = "net.corda.core.node.VaultUpdateTests.DummyContract"
val DUMMY_NOTARY = TestIdentity(DUMMY_NOTARY_NAME, 20).party
val emptyUpdate = Vault.Update(emptySet(), emptySet(), type = Vault.UpdateType.GENERAL)
}
@ -68,7 +68,7 @@ class VaultUpdateTests {
@Test
fun `nothing plus something is something`() {
val before = emptyUpdate
val after = before + Vault.Update<ContractState>(setOf(stateAndRef0, stateAndRef1), setOf(stateAndRef2, stateAndRef3))
val after = before + Vault.Update(setOf(stateAndRef0, stateAndRef1), setOf(stateAndRef2, stateAndRef3))
val expected = Vault.Update<ContractState>(setOf(stateAndRef0, stateAndRef1), setOf(stateAndRef2, stateAndRef3))
assertEquals(expected, after)
}
@ -76,7 +76,7 @@ class VaultUpdateTests {
@Test
fun `something plus consume state 0 is something without state 0 output`() {
val before = Vault.Update<ContractState>(setOf(stateAndRef2, stateAndRef3), setOf(stateAndRef0, stateAndRef1))
val after = before + Vault.Update<ContractState>(setOf(stateAndRef0), setOf())
val after = before + Vault.Update(setOf(stateAndRef0), setOf())
val expected = Vault.Update<ContractState>(setOf(stateAndRef2, stateAndRef3), setOf(stateAndRef1))
assertEquals(expected, after)
}
@ -84,7 +84,7 @@ class VaultUpdateTests {
@Test
fun `something plus produce state 4 is something with additional state 4 output`() {
val before = Vault.Update<ContractState>(setOf(stateAndRef2, stateAndRef3), setOf(stateAndRef0, stateAndRef1))
val after = before + Vault.Update<ContractState>(setOf(), setOf(stateAndRef4))
val after = before + Vault.Update(setOf(), setOf(stateAndRef4))
val expected = Vault.Update<ContractState>(setOf(stateAndRef2, stateAndRef3), setOf(stateAndRef0, stateAndRef1, stateAndRef4))
assertEquals(expected, after)
}
@ -92,7 +92,7 @@ class VaultUpdateTests {
@Test
fun `something plus consume states 0 and 1, and produce state 4, is something without state 0 and 1 outputs and only state 4 output`() {
val before = Vault.Update<ContractState>(setOf(stateAndRef2, stateAndRef3), setOf(stateAndRef0, stateAndRef1))
val after = before + Vault.Update<ContractState>(setOf(stateAndRef0, stateAndRef1), setOf(stateAndRef4))
val after = before + Vault.Update(setOf(stateAndRef0, stateAndRef1), setOf(stateAndRef4))
val expected = Vault.Update<ContractState>(setOf(stateAndRef2, stateAndRef3), setOf(stateAndRef4))
assertEquals(expected, after)
}

View File

@ -52,6 +52,7 @@ private fun createAttachmentData(content: String) = ByteArrayOutputStream().appl
private fun Attachment.extractContent() = ByteArrayOutputStream().apply { extractFile("content", this) }.toString(UTF_8.name())
@SuppressWarnings("deprecation")
private fun StartedNode<*>.saveAttachment(content: String) = database.transaction {
attachments.importAttachment(createAttachmentData(content).inputStream())
}

View File

@ -93,7 +93,7 @@ class TransactionSerializationTests {
stx.verifyRequiredSignatures()
// Corrupt the data and ensure the signature catches the problem.
val bytesField = stx.id::bytes.javaField?.apply { setAccessible(true) }
val bytesField = stx.id::bytes.javaField?.apply { isAccessible = true }
val bytes = bytesField?.get(stx.id) as ByteArray
bytes[5] = bytes[5].inc()

View File

@ -134,7 +134,8 @@ class CompatibleTransactionTests {
@Test
fun `WireTransaction constructors and compatibility`() {
val wireTransactionOldConstructor = WireTransaction(inputs, attachments, outputs, commands, notary, timeWindow, privacySalt)
val groups = WireTransaction.createComponentGroups(inputs, outputs, commands, attachments, notary, timeWindow)
val wireTransactionOldConstructor = WireTransaction(groups, privacySalt)
assertEquals(wireTransactionA, wireTransactionOldConstructor)
// Malformed tx - attachments is not List<SecureHash>. For this example, we mistakenly added input-state (StateRef) serialised objects with ATTACHMENTS_GROUP.ordinal.
@ -396,7 +397,7 @@ class CompatibleTransactionTests {
assertFailsWith<IllegalStateException> { WireTransaction(componentGroups = componentGroupsLessSigners, privacySalt = PrivacySalt()) }
// Test if there is no command to sign.
val commandsNoKey1= listOf(dummyCommand(DUMMY_KEY_2.public))
val commandsNoKey1 = listOf(dummyCommand(DUMMY_KEY_2.public))
val componentGroupsNoKey1ToSign = listOf(
inputGroup,
@ -409,7 +410,7 @@ class CompatibleTransactionTests {
)
val wtxNoKey1 = WireTransaction(componentGroups = componentGroupsNoKey1ToSign, privacySalt = PrivacySalt())
val allCommandsNoKey1Ftx= wtxNoKey1.buildFilteredTransaction(Predicate(::filterCommandsOnly))
val allCommandsNoKey1Ftx = wtxNoKey1.buildFilteredTransaction(Predicate(::filterCommandsOnly))
allCommandsNoKey1Ftx.checkCommandVisibility(DUMMY_KEY_1.public) // This will pass, because there are indeed no commands to sign in the original transaction.
}
@ -500,7 +501,7 @@ class CompatibleTransactionTests {
// Remove both last signer (KEY1) and related command.
// Update partial Merkle tree for signers.
val updatedFilteredComponentsNoLastCommandAndSigners = listOf(noLastCommandDataGroup, noLastSignerGroup)
val ftxNoLastCommandAndSigners = ftxConstructor.invoke(key1CommandsFtx.id, updatedFilteredComponentsNoLastCommandAndSigners, key1CommandsFtx.groupHashes) as FilteredTransaction
val ftxNoLastCommandAndSigners = ftxConstructor.invoke(key1CommandsFtx.id, updatedFilteredComponentsNoLastCommandAndSigners, key1CommandsFtx.groupHashes)
// verify() will pass as the transaction is well-formed.
ftxNoLastCommandAndSigners.verify()
// checkCommandVisibility() will not pass, because checkAllComponentsVisible(ComponentGroupEnum.SIGNERS_GROUP) will fail.
@ -509,7 +510,7 @@ class CompatibleTransactionTests {
// Remove last signer for which there is no pointer from a visible commandData. This is the case of Key2.
// Do not change partial Merkle tree for signers.
// This time the object can be constructed as there is no pointer mismatch.
val ftxNoLastSigner = ftxConstructor.invoke(key2CommandsFtx.id, updatedFilteredComponentsNoSignersKey2SamePMT, key2CommandsFtx.groupHashes) as FilteredTransaction
val ftxNoLastSigner = ftxConstructor.invoke(key2CommandsFtx.id, updatedFilteredComponentsNoSignersKey2SamePMT, key2CommandsFtx.groupHashes)
// verify() will fail as we didn't change the partial Merkle tree.
assertFailsWith<FilteredTransactionVerificationException> { ftxNoLastSigner.verify() }
// checkCommandVisibility() will not pass.
@ -517,7 +518,7 @@ class CompatibleTransactionTests {
// Remove last signer for which there is no pointer from a visible commandData. This is the case of Key2.
// Update partial Merkle tree for signers.
val ftxNoLastSignerB = ftxConstructor.invoke(key2CommandsFtx.id, updatedFilteredComponentsNoSignersKey2, key2CommandsFtx.groupHashes) as FilteredTransaction
val ftxNoLastSignerB = ftxConstructor.invoke(key2CommandsFtx.id, updatedFilteredComponentsNoSignersKey2, key2CommandsFtx.groupHashes)
// verify() will pass, the transaction is well-formed.
ftxNoLastSignerB.verify()
// But, checkAllComponentsVisible() will not pass.
@ -542,14 +543,14 @@ class CompatibleTransactionTests {
val alterFilteredComponents = listOf(key1CommandsFtx.filteredComponentGroups[0], alterSignerGroup)
// Do not update groupHashes.
val ftxAlterSigner = ftxConstructor.invoke(key1CommandsFtx.id, alterFilteredComponents, key1CommandsFtx.groupHashes) as FilteredTransaction
val ftxAlterSigner = ftxConstructor.invoke(key1CommandsFtx.id, alterFilteredComponents, key1CommandsFtx.groupHashes)
// Visible components in signers group cannot be verified against their partial Merkle tree.
assertFailsWith<FilteredTransactionVerificationException> { ftxAlterSigner.verify() }
// Also, checkAllComponentsVisible() will not pass (groupHash matching will fail).
assertFailsWith<ComponentVisibilityException> { ftxAlterSigner.checkCommandVisibility(DUMMY_KEY_1.public) }
// Update groupHashes.
val ftxAlterSignerB = ftxConstructor.invoke(key1CommandsFtx.id, alterFilteredComponents, key1CommandsFtx.groupHashes.subList(0, 6) + alterMTree.hash) as FilteredTransaction
val ftxAlterSignerB = ftxConstructor.invoke(key1CommandsFtx.id, alterFilteredComponents, key1CommandsFtx.groupHashes.subList(0, 6) + alterMTree.hash)
// Visible components in signers group cannot be verified against their partial Merkle tree.
assertFailsWith<FilteredTransactionVerificationException> { ftxAlterSignerB.verify() }
// Also, checkAllComponentsVisible() will not pass (top level Merkle tree cannot be verified against transaction's id).

View File

@ -32,7 +32,7 @@ import org.junit.Test
import java.time.Instant
import java.time.temporal.ChronoUnit
val TEST_TIMELOCK_ID = "net.corda.core.transactions.TransactionEncumbranceTests\$DummyTimeLock"
const val TEST_TIMELOCK_ID = "net.corda.core.transactions.TransactionEncumbranceTests\$DummyTimeLock"
class TransactionEncumbranceTests {
private companion object {

View File

@ -10,6 +10,12 @@ Unreleased
* Node will now gracefully fail to start if ``devMode`` is true and ``compatibilityZoneURL`` is specified.
* Added smart detection logic for the development mode setting and an option to override it from the command line.
* Fixed an error thrown by NodeVaultService upon recording a transaction with a number of inputs greater than the default page size.
* Fixed incorrect computation of ``totalStates`` from ``otherResults`` in ``NodeVaultService``.
* Changes to the JSON/YAML serialisation format from ``JacksonSupport``, which also applies to the node shell:
* ``Instant`` and ``Date`` objects are serialised as ISO-8601 formatted strings rather than timestamps

View File

@ -172,9 +172,12 @@ absolute path to the node's base directory.
:devMode: This flag sets the node to run in development mode. On startup, if the keystore ``<workspace>/certificates/sslkeystore.jks``
does not exist, a developer keystore will be used if ``devMode`` is true. The node will exit if ``devMode`` is false
and the keystore does not exist. ``devMode`` also turns on background checking of flow checkpoints to shake out any
bugs in the checkpointing process. Also, if ``devMode`` is true, Hibernate will try to automatically create the schema required by Corda
or update an existing schema in the SQL database; if ``devMode`` is false, Hibernate will simply validate an existing schema
failing on node start if this schema is either not present or not compatible.
bugs in the checkpointing process.
Also, if ``devMode`` is true, Hibernate will try to automatically create the schema required by Corda
or update an existing schema in the SQL database; if ``devMode`` is false, Hibernate will simply validate the existing schema,
failing on node start if the schema is either not present or not compatible.
If no value is specified in the node config file, the node will attempt to detect if it's running on a developer machine and set ``devMode=true`` in that case.
This value can be overridden from the command line using the ``--dev-mode`` option.
:detectPublicIp: This flag toggles the auto IP detection behaviour, it is enabled by default. On startup the node will
attempt to discover its externally visible IP address first by looking for any public addresses on its network

View File

@ -476,7 +476,7 @@ public class FlowCookbookJava {
subFlow(new SendStateAndRefFlow(counterpartySession, dummyStates));
// On the receive side ...
List<StateAndRef<DummyState>> resolvedStateAndRef = subFlow(new ReceiveStateAndRefFlow<DummyState>(counterpartySession));
List<StateAndRef<DummyState>> resolvedStateAndRef = subFlow(new ReceiveStateAndRefFlow<>(counterpartySession));
// DOCEND 14
try {

View File

@ -60,7 +60,7 @@ public class CommercialPaper implements Contract {
requireThat(require -> {
require.using("the paper must have matured", time.isAfter(input.getMaturityDate()));
require.using("the received amount equals the face value", received == input.getFaceValue());
require.using("the paper must be destroyed", outputs.size() == 0);
require.using("the paper must be destroyed", outputs.isEmpty());
require.using("the transaction is signed by the owner of the CP", cmd.getSigners().contains(input.getOwner().getOwningKey()));
return null;
});

View File

@ -153,9 +153,8 @@ object TopupIssuerFlow {
// now invoke Cash subflow to Move issued assetType to issue requester
progressTracker.currentStep = TRANSFERRING
val moveCashFlow = CashPaymentFlow(amount, issueTo, anonymous = false)
val moveTx = subFlow(moveCashFlow)
// NOTE: CashFlow PayCash calls FinalityFlow which performs a Broadcast (which stores a local copy of the txn to the ledger)
return moveTx
return subFlow(moveCashFlow)
}
}
}

View File

@ -33,7 +33,7 @@ enum class WorkflowState {
REJECTED
}
val TRADE_APPROVAL_PROGRAM_ID = "net.corda.docs.TradeApprovalContract"
const val TRADE_APPROVAL_PROGRAM_ID = "net.corda.docs.TradeApprovalContract"
/**
* Minimal contract to encode a simple workflow with one initial state and two possible eventual states.

Some files were not shown because too many files have changed in this diff Show More