Merged in mike-small-cleanups (pull request #215)

Small cleanups
This commit is contained in:
Mike Hearn 2016-07-11 18:50:45 +02:00
commit 04c6449f92
49 changed files with 85 additions and 116 deletions

View File

@ -1,11 +1,12 @@
import com.google.common.io.ByteStreams import com.google.common.io.ByteStreams
import java.nio.file.Files import java.nio.file.Files
import java.nio.file.Paths import java.nio.file.Paths
import java.nio.file.StandardCopyOption import java.nio.file.StandardCopyOption
import java.nio.file.attribute.FileTime import java.nio.file.attribute.FileTime
import java.util.zip.ZipEntry import java.util.zip.ZipEntry
import java.util.zip.ZipOutputStream
import java.util.zip.ZipFile import java.util.zip.ZipFile
import java.util.zip.ZipOutputStream
buildscript { buildscript {
repositories { repositories {

View File

@ -1,9 +1,9 @@
package com.r3corda.core.node package com.r3corda.core.node
import com.r3corda.core.contracts.ContractState import com.r3corda.core.contracts.ContractState
import com.r3corda.core.crypto.Party
import com.r3corda.core.contracts.PartyAndReference import com.r3corda.core.contracts.PartyAndReference
import com.r3corda.core.contracts.TransactionBuilder import com.r3corda.core.contracts.TransactionBuilder
import com.r3corda.core.crypto.Party
interface DummyContractBackdoor { interface DummyContractBackdoor {
fun generateInitial(owner: PartyAndReference, magicNumber: Int, notary: Party): TransactionBuilder fun generateInitial(owner: PartyAndReference, magicNumber: Int, notary: Party): TransactionBuilder

View File

@ -1,13 +1,10 @@
package com.r3corda.contracts; package com.r3corda.contracts;
import com.r3corda.core.contracts.Amount; import com.r3corda.core.contracts.*;
import com.r3corda.core.contracts.ContractState;
import com.r3corda.core.contracts.PartyAndReference;
import com.r3corda.core.contracts.Issued;
import java.security.*; import java.security.*;
import java.time.*; import java.time.*;
import java.util.Currency; import java.util.*;
/* This is an interface solely created to demonstrate that the same kotlin tests can be run against /* This is an interface solely created to demonstrate that the same kotlin tests can be run against
* either a Java implementation of the CommercialPaper or a kotlin implementation. * either a Java implementation of the CommercialPaper or a kotlin implementation.

View File

@ -1,24 +1,18 @@
package com.r3corda.contracts; package com.r3corda.contracts;
import com.google.common.collect.ImmutableList; import com.google.common.collect.*;
import com.r3corda.contracts.asset.Cash; import com.r3corda.contracts.asset.*;
import com.r3corda.contracts.asset.CashKt;
import com.r3corda.contracts.asset.InsufficientBalanceException;
import com.r3corda.core.contracts.*; import com.r3corda.core.contracts.*;
import com.r3corda.core.contracts.TransactionForContract.InOutGroup; import com.r3corda.core.contracts.TransactionForContract.*;
import com.r3corda.core.crypto.NullPublicKey; import com.r3corda.core.crypto.*;
import com.r3corda.core.crypto.Party; import org.jetbrains.annotations.*;
import com.r3corda.core.crypto.SecureHash;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.security.PublicKey; import java.security.*;
import java.time.Instant; import java.time.*;
import java.util.Currency; import java.util.*;
import java.util.List;
import static com.r3corda.core.contracts.ContractsDSL.requireSingleCommand; import static com.r3corda.core.contracts.ContractsDSL.*;
import static kotlin.collections.CollectionsKt.single; import static kotlin.collections.CollectionsKt.*;
/** /**

View File

@ -80,12 +80,12 @@ class CommercialPaper : Contract {
// it for cash on or after the maturity date. // it for cash on or after the maturity date.
val command = tx.commands.requireSingleCommand<CommercialPaper.Commands>() val command = tx.commands.requireSingleCommand<CommercialPaper.Commands>()
// If it's an issue, we can't take notary from inputs, so it must be specified in the command // If it's an issue, we can't take notary from inputs, so it must be specified in the command
val timestamp: TimestampCommand? = if (command.value is Commands.Issue) val cmdVal = command.value
tx.getTimestampBy((command.value as Commands.Issue).notary) val timestamp: TimestampCommand? = when (cmdVal) {
else if (command.value is Commands.Redeem) is Commands.Issue -> tx.getTimestampBy(cmdVal.notary)
tx.getTimestampBy((command.value as Commands.Redeem).notary) is Commands.Redeem -> tx.getTimestampBy(cmdVal.notary)
else else -> null
null }
for ((inputs, outputs, key) in groups) { for ((inputs, outputs, key) in groups) {
when (command.value) { when (command.value) {

View File

@ -498,6 +498,7 @@ class InterestRateSwap() : Contract {
val command = tx.commands.requireSingleCommand<InterestRateSwap.Commands>() val command = tx.commands.requireSingleCommand<InterestRateSwap.Commands>()
// TODO: This needs to either be the notary used for the inputs, or otherwise // TODO: This needs to either be the notary used for the inputs, or otherwise
// derived as the correct notary // derived as the correct notary
@Suppress("DEPRECATION")
val time = tx.commands.getTimestampByName("Mock Company 0", "Notary Service", "Bank A")?.midpoint val time = tx.commands.getTimestampByName("Mock Company 0", "Notary Service", "Bank A")?.midpoint
if (time == null) throw IllegalArgumentException("must be timestamped") if (time == null) throw IllegalArgumentException("must be timestamped")

View File

@ -2,11 +2,7 @@ package com.r3corda.contracts.asset
import com.r3corda.core.contracts.* import com.r3corda.core.contracts.*
import com.r3corda.core.crypto.Party import com.r3corda.core.crypto.Party
import com.r3corda.core.crypto.SecureHash
import com.r3corda.core.crypto.toStringShort
import com.r3corda.core.utilities.Emoji
import java.security.PublicKey import java.security.PublicKey
import java.security.SecureRandom
import java.util.* import java.util.*
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,7 +1,6 @@
package com.r3corda.contracts.asset package com.r3corda.contracts.asset
import com.r3corda.core.contracts.Amount import com.r3corda.core.contracts.Amount
import com.r3corda.core.contracts.Issued
import com.r3corda.core.contracts.OwnableState import com.r3corda.core.contracts.OwnableState
import java.security.PublicKey import java.security.PublicKey

View File

@ -1,12 +1,12 @@
package com.r3corda.contracts.asset; package com.r3corda.contracts.asset;
import com.r3corda.core.contracts.PartyAndReference; import com.r3corda.core.contracts.*;
import com.r3corda.core.serialization.OpaqueBytes; import com.r3corda.core.serialization.*;
import kotlin.Unit; import kotlin.*;
import org.junit.Test; import org.junit.*;
import static com.r3corda.core.testing.CoreTestUtils.*;
import static com.r3corda.core.contracts.ContractsDSL.*; import static com.r3corda.core.contracts.ContractsDSL.*;
import static com.r3corda.core.testing.CoreTestUtils.*;
/** /**
* This is an incomplete Java replica of CashTests.kt to show how to use the Java test DSL * This is an incomplete Java replica of CashTests.kt to show how to use the Java test DSL

View File

@ -1,7 +1,6 @@
package com.r3corda.contracts.asset package com.r3corda.contracts.asset
import com.r3corda.contracts.asset.Obligation.Lifecycle import com.r3corda.contracts.asset.Obligation.Lifecycle
import com.r3corda.contracts.testing.*
import com.r3corda.core.contracts.* import com.r3corda.core.contracts.*
import com.r3corda.core.crypto.SecureHash import com.r3corda.core.crypto.SecureHash
import com.r3corda.core.testing.* import com.r3corda.core.testing.*
@ -11,7 +10,10 @@ import java.security.PublicKey
import java.time.Duration import java.time.Duration
import java.time.Instant import java.time.Instant
import java.util.* import java.util.*
import kotlin.test.* import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
import kotlin.test.assertNotEquals
import kotlin.test.assertTrue
class ObligationTests { class ObligationTests {
val defaultIssuer = MEGA_CORP.ref(1) val defaultIssuer = MEGA_CORP.ref(1)

View File

@ -142,7 +142,7 @@ inline fun <T> logElapsedTime(label: String, logger: Logger? = null, body: () ->
* *
* val ii = state.locked { i } * val ii = state.locked { i }
*/ */
class ThreadBox<T>(content: T, val lock: ReentrantLock = ReentrantLock()) { class ThreadBox<out T>(content: T, val lock: ReentrantLock = ReentrantLock()) {
val content = content val content = content
inline fun <R> locked(body: T.() -> R): R = lock.withLock { body(content) } inline fun <R> locked(body: T.() -> R): R = lock.withLock { body(content) }
inline fun <R> alreadyLocked(body: T.() -> R): R { inline fun <R> alreadyLocked(body: T.() -> R): R {
@ -164,7 +164,7 @@ abstract class RetryableException(message: String) : Exception(message)
* will not be serialized to disk, and if it's missing (or the first time it's accessed), the initializer will be * will not be serialized to disk, and if it's missing (or the first time it's accessed), the initializer will be
* used to set it up. Note that the initializer will be called with the TransientProperty object locked. * used to set it up. Note that the initializer will be called with the TransientProperty object locked.
*/ */
class TransientProperty<T>(private val initializer: () -> T) { class TransientProperty<out T>(private val initializer: () -> T) {
@Transient private var v: T? = null @Transient private var v: T? = null
@Synchronized @Synchronized

View File

@ -132,7 +132,7 @@ interface IssuanceDefinition
* *
* @param P the type of product underlying the definition, for example [Currency]. * @param P the type of product underlying the definition, for example [Currency].
*/ */
data class Issued<P>( data class Issued<out P>(
val issuer: PartyAndReference, val issuer: PartyAndReference,
val product: P val product: P
) )

View File

@ -17,7 +17,6 @@ sealed class TransactionType {
* Note: Presence of _signatures_ is not checked, only the public keys to be signed for. * Note: Presence of _signatures_ is not checked, only the public keys to be signed for.
*/ */
fun verify(tx: TransactionForVerification) { fun verify(tx: TransactionForVerification) {
val missing = verifySigners(tx) val missing = verifySigners(tx)
if (missing.isNotEmpty()) throw TransactionVerificationException.SignersMissing(tx, missing.toList()) if (missing.isNotEmpty()) throw TransactionVerificationException.SignersMissing(tx, missing.toList())

View File

@ -2,6 +2,7 @@ package com.r3corda.core.contracts
import com.r3corda.core.crypto.Party import com.r3corda.core.crypto.Party
import com.r3corda.core.crypto.SecureHash import com.r3corda.core.crypto.SecureHash
import com.r3corda.core.crypto.toStringShort
import java.security.PublicKey import java.security.PublicKey
import java.util.* import java.util.*
@ -158,7 +159,7 @@ data class TransactionForContract(val inputs: List<ContractState>,
* up on both sides of the transaction, but the values must be summed independently per currency. Grouping can * up on both sides of the transaction, but the values must be summed independently per currency. Grouping can
* be used to simplify this logic. * be used to simplify this logic.
*/ */
data class InOutGroup<T : ContractState, K : Any>(val inputs: List<T>, val outputs: List<T>, val groupingKey: K) data class InOutGroup<out T : ContractState, out K : Any>(val inputs: List<T>, val outputs: List<T>, val groupingKey: K)
/** Get the timestamp command for this transaction, using the notary from the input states. */ /** Get the timestamp command for this transaction, using the notary from the input states. */
val timestamp: TimestampCommand? val timestamp: TimestampCommand?
@ -168,9 +169,9 @@ data class TransactionForContract(val inputs: List<ContractState>,
fun getTimestampBy(timestampingAuthority: Party): TimestampCommand? = commands.getTimestampBy(timestampingAuthority) fun getTimestampBy(timestampingAuthority: Party): TimestampCommand? = commands.getTimestampBy(timestampingAuthority)
/** Simply calls [commands.getTimestampByName] as a shortcut to make code completion more intuitive. */ /** Simply calls [commands.getTimestampByName] as a shortcut to make code completion more intuitive. */
@Suppress("DEPRECATION")
@Deprecated(message = "Timestamping authority should always be notary for the transaction") @Deprecated(message = "Timestamping authority should always be notary for the transaction")
fun getTimestampByName(vararg authorityName: String): TimestampCommand? = commands.getTimestampByName(*authorityName) fun getTimestampByName(vararg authorityName: String): TimestampCommand? = commands.getTimestampByName(*authorityName)
} }
class TransactionResolutionException(val hash: SecureHash) : Exception() class TransactionResolutionException(val hash: SecureHash) : Exception()
@ -179,6 +180,8 @@ class TransactionConflictException(val conflictRef: StateRef, val tx1: LedgerTra
sealed class TransactionVerificationException(val tx: TransactionForVerification, cause: Throwable?) : Exception(cause) { sealed class TransactionVerificationException(val tx: TransactionForVerification, cause: Throwable?) : Exception(cause) {
class ContractRejection(tx: TransactionForVerification, val contract: Contract, cause: Throwable?) : TransactionVerificationException(tx, cause) class ContractRejection(tx: TransactionForVerification, val contract: Contract, cause: Throwable?) : TransactionVerificationException(tx, cause)
class MoreThanOneNotary(tx: TransactionForVerification) : TransactionVerificationException(tx, null) class MoreThanOneNotary(tx: TransactionForVerification) : TransactionVerificationException(tx, null)
class SignersMissing(tx: TransactionForVerification, missing: List<PublicKey>) : TransactionVerificationException(tx, null) class SignersMissing(tx: TransactionForVerification, val missing: List<PublicKey>) : TransactionVerificationException(tx, null) {
override fun toString() = "Signers missing: ${missing.map { it.toStringShort() }}"
}
class InvalidNotaryChange(tx: TransactionForVerification) : TransactionVerificationException(tx, null) class InvalidNotaryChange(tx: TransactionForVerification) : TransactionVerificationException(tx, null)
} }

View File

@ -6,7 +6,7 @@ import com.r3corda.core.contracts.ContractState
import com.r3corda.core.contracts.TransactionForContract import com.r3corda.core.contracts.TransactionForContract
import java.util.* import java.util.*
interface GroupVerify<S, T : Any> { interface GroupVerify<in S, in T : Any> {
/** /**
* *
* @return the set of commands that are consumed IF this clause is matched, and cannot be used to match a * @return the set of commands that are consumed IF this clause is matched, and cannot be used to match a

View File

@ -19,7 +19,7 @@ fun newSecureRandom(): SecureRandom {
} }
// "sealed" here means there can't be any subclasses other than the ones defined here. // "sealed" here means there can't be any subclasses other than the ones defined here.
sealed class SecureHash private constructor(bits: ByteArray) : OpaqueBytes(bits) { sealed class SecureHash(bits: ByteArray) : OpaqueBytes(bits) {
class SHA256(bits: ByteArray) : SecureHash(bits) { class SHA256(bits: ByteArray) : SecureHash(bits) {
init { init {
require(bits.size == 32) require(bits.size == 32)

View File

@ -5,7 +5,6 @@ import com.r3corda.core.contracts.Contract
import com.r3corda.core.crypto.Party import com.r3corda.core.crypto.Party
import com.r3corda.core.messaging.MessagingService import com.r3corda.core.messaging.MessagingService
import com.r3corda.core.node.NodeInfo import com.r3corda.core.node.NodeInfo
import com.r3corda.core.node.services.ServiceType
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
import java.security.PublicKey import java.security.PublicKey

View File

@ -24,7 +24,7 @@ import org.slf4j.Logger
* If you'd like to use another ProtocolLogic class as a component of your own, construct it on the fly and then pass * If you'd like to use another ProtocolLogic class as a component of your own, construct it on the fly and then pass
* it to the [subProtocol] method. It will return the result of that protocol when it completes. * it to the [subProtocol] method. It will return the result of that protocol when it completes.
*/ */
abstract class ProtocolLogic<T> { abstract class ProtocolLogic<out T> {
/** Reference to the [Fiber] instance that is the top level controller for the entire flow. */ /** Reference to the [Fiber] instance that is the top level controller for the entire flow. */
lateinit var psm: ProtocolStateMachine<*> lateinit var psm: ProtocolStateMachine<*>

View File

@ -326,7 +326,7 @@ fun createKryo(k: Kryo = Kryo()): Kryo {
// no-arg constructor available. // no-arg constructor available.
instantiatorStrategy = DefaultInstantiatorStrategy(StdInstantiatorStrategy()) instantiatorStrategy = DefaultInstantiatorStrategy(StdInstantiatorStrategy())
register(Arrays.asList("").javaClass, ArraysAsListSerializer()); register(Arrays.asList("").javaClass, ArraysAsListSerializer())
// Because we like to stick a Kryo object in a ThreadLocal to speed things up a bit, we can end up trying to // Because we like to stick a Kryo object in a ThreadLocal to speed things up a bit, we can end up trying to
// serialise the Kryo object itself when suspending a fiber. That's dumb, useless AND can cause crashes, so // serialise the Kryo object itself when suspending a fiber. That's dumb, useless AND can cause crashes, so

View File

@ -4,7 +4,6 @@ import com.r3corda.core.contracts.Contract
import com.r3corda.core.contracts.LinearState import com.r3corda.core.contracts.LinearState
import com.r3corda.core.crypto.SecureHash import com.r3corda.core.crypto.SecureHash
import java.security.PublicKey import java.security.PublicKey
import java.util.*
class DummyLinearState( class DummyLinearState(
override val thread: SecureHash = SecureHash.randomSHA256(), override val thread: SecureHash = SecureHash.randomSHA256(),

View File

@ -72,7 +72,7 @@ class NonEmptySet<T>(initial: T) : MutableSet<T> {
override fun hashCode(): Int = set.hashCode() override fun hashCode(): Int = set.hashCode()
override fun toString(): String = set.toString() override fun toString(): String = set.toString()
inner class Iterator<T>(val iterator: MutableIterator<T>) : MutableIterator<T> { inner class Iterator<out T>(val iterator: MutableIterator<T>) : MutableIterator<T> {
override fun hasNext(): Boolean = iterator.hasNext() override fun hasNext(): Boolean = iterator.hasNext()
override fun next(): T = iterator.next() override fun next(): T = iterator.next()
override fun remove() = override fun remove() =

View File

@ -16,8 +16,8 @@ class RecordingMap<K, V>(private val wrappedMap: MutableMap<K, V>,
// If/when Kotlin supports data classes inside sealed classes, that would be preferable to this. // If/when Kotlin supports data classes inside sealed classes, that would be preferable to this.
interface Record interface Record
data class Get<K>(val key: K) : Record data class Get<out K>(val key: K) : Record
data class Put<K, V>(val key: K, val value: V) : Record data class Put<out K, out V>(val key: K, val value: V) : Record
private val _records = Collections.synchronizedList(ArrayList<Record>()) private val _records = Collections.synchronizedList(ArrayList<Record>())

View File

@ -11,7 +11,7 @@ package com.r3corda.core.utilities
* - Are any objects *reachable* from this object mismatched or not what you expected? * - Are any objects *reachable* from this object mismatched or not what you expected?
* - Is it suspiciously large or small? * - Is it suspiciously large or small?
*/ */
class UntrustworthyData<T>(private val fromUntrustedWorld: T) { class UntrustworthyData<out T>(private val fromUntrustedWorld: T) {
val data: T val data: T
@Deprecated("Accessing the untrustworthy data directly without validating it first is a bad idea") @Deprecated("Accessing the untrustworthy data directly without validating it first is a bad idea")
get() = fromUntrustedWorld get() = fromUntrustedWorld

View File

@ -25,7 +25,7 @@ import java.util.*
* @param T The ultimate type of the data being fetched. * @param T The ultimate type of the data being fetched.
* @param W The wire type of the data being fetched, for when it isn't the same as the ultimate type. * @param W The wire type of the data being fetched, for when it isn't the same as the ultimate type.
*/ */
abstract class FetchDataProtocol<T : NamedByHash, W : Any>( abstract class FetchDataProtocol<T : NamedByHash, in W : Any>(
protected val requests: Set<SecureHash>, protected val requests: Set<SecureHash>,
protected val otherSide: Party) : ProtocolLogic<FetchDataProtocol.Result<T>>() { protected val otherSide: Party) : ProtocolLogic<FetchDataProtocol.Result<T>>() {
@ -34,7 +34,7 @@ abstract class FetchDataProtocol<T : NamedByHash, W : Any>(
class DownloadedVsRequestedDataMismatch(val requested: SecureHash, val got: SecureHash) : BadAnswer() class DownloadedVsRequestedDataMismatch(val requested: SecureHash, val got: SecureHash) : BadAnswer()
data class Request(val hashes: List<SecureHash>, override val replyToParty: Party, override val sessionID: Long) : PartyRequestMessage data class Request(val hashes: List<SecureHash>, override val replyToParty: Party, override val sessionID: Long) : PartyRequestMessage
data class Result<T : NamedByHash>(val fromDisk: List<T>, val downloaded: List<T>) data class Result<out T : NamedByHash>(val fromDisk: List<T>, val downloaded: List<T>)
@Suspendable @Suspendable
override fun call(): Result<T> { override fun call(): Result<T> {

View File

@ -44,7 +44,7 @@ object TwoPartyDealProtocol {
} }
// This object is serialised to the network and is the first protocol message the seller sends to the buyer. // This object is serialised to the network and is the first protocol message the seller sends to the buyer.
data class Handshake<T>( data class Handshake<out T>(
val payload: T, val payload: T,
val publicKey: PublicKey, val publicKey: PublicKey,
val sessionID: Long val sessionID: Long
@ -58,7 +58,7 @@ object TwoPartyDealProtocol {
* There's a good chance we can push at least some of this logic down into core protocol logic * There's a good chance we can push at least some of this logic down into core protocol logic
* and helper methods etc. * and helper methods etc.
*/ */
abstract class Primary<U>(override val progressTracker: ProgressTracker = Primary.tracker()) : ProtocolLogic<SignedTransaction>() { abstract class Primary<out U>(override val progressTracker: ProgressTracker = Primary.tracker()) : ProtocolLogic<SignedTransaction>() {
companion object { companion object {
object AWAITING_PROPOSAL : ProgressTracker.Step("Handshaking and awaiting transaction proposal") object AWAITING_PROPOSAL : ProgressTracker.Step("Handshaking and awaiting transaction proposal")

View File

@ -26,7 +26,7 @@ import java.security.PublicKey
* use the new updated state for future transactions. * use the new updated state for future transactions.
*/ */
abstract class AbstractStateReplacementProtocol<T> { abstract class AbstractStateReplacementProtocol<T> {
interface Proposal<T> { interface Proposal<out T> {
val stateRef: StateRef val stateRef: StateRef
val modification: T val modification: T
val stx: SignedTransaction val stx: SignedTransaction

View File

@ -1,13 +1,10 @@
package com.r3corda.core.protocols; package com.r3corda.core.protocols;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.*;
import org.junit.Test; import org.junit.*;
import java.util.HashMap; import java.util.*;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
public class ProtocolLogicRefFromJavaTest { public class ProtocolLogicRefFromJavaTest {

View File

@ -6,7 +6,6 @@ import com.r3corda.core.testing.DUMMY_NOTARY
import com.r3corda.core.testing.MEGA_CORP_KEY import com.r3corda.core.testing.MEGA_CORP_KEY
import org.junit.Test import org.junit.Test
import java.security.KeyPair import java.security.KeyPair
import java.security.SecureRandom
import kotlin.test.assertEquals import kotlin.test.assertEquals
class TransactionGraphSearchTests { class TransactionGraphSearchTests {

View File

@ -7,7 +7,6 @@ import com.r3corda.core.node.services.testing.MockStorageService
import com.r3corda.core.testing.* import com.r3corda.core.testing.*
import org.junit.Test import org.junit.Test
import java.security.PublicKey import java.security.PublicKey
import java.security.SecureRandom
import java.util.* import java.util.*
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith import kotlin.test.assertFailsWith

View File

@ -1,8 +1,8 @@
package com.r3corda.core.crypto package com.r3corda.core.crypto
import java.math.BigInteger
import java.util.Arrays
import org.junit.Test import org.junit.Test
import java.math.BigInteger
import java.util.*
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertTrue import kotlin.test.assertTrue
import kotlin.test.fail import kotlin.test.fail
@ -32,7 +32,7 @@ class Base58Test {
@Test @Test
fun testDecode() { fun testDecode() {
val testbytes = "Hello World".toByteArray() val testbytes = "Hello World".toByteArray()
val actualbytes = Base58.decode("JxF12TrwUP45BMd"); val actualbytes = Base58.decode("JxF12TrwUP45BMd")
assertTrue(String(actualbytes)) { Arrays.equals(testbytes, actualbytes) } assertTrue(String(actualbytes)) { Arrays.equals(testbytes, actualbytes) }
assertTrue("1") { Arrays.equals(ByteArray(1), Base58.decode("1")) } assertTrue("1") { Arrays.equals(ByteArray(1), Base58.decode("1")) }

View File

@ -9,7 +9,6 @@ import com.r3corda.core.testing.*
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import java.security.PublicKey import java.security.PublicKey
import java.security.SecureRandom
import java.security.SignatureException import java.security.SignatureException
import java.util.* import java.util.*
import kotlin.test.assertEquals import kotlin.test.assertEquals

View File

@ -43,8 +43,8 @@ class NonEmptySetTest {
.suppressing(CollectionAddAllTester::class.java.getMethod("testAddAll_nullCollectionReference")) .suppressing(CollectionAddAllTester::class.java.getMethod("testAddAll_nullCollectionReference"))
// Disable tests that try to remove everything: // Disable tests that try to remove everything:
.suppressing(CollectionRemoveAllTester::class.java.getMethod("testRemoveAll_nullCollectionReferenceNonEmptySubject")) .suppressing(CollectionRemoveAllTester::class.java.getMethod("testRemoveAll_nullCollectionReferenceNonEmptySubject"))
.suppressing(CollectionClearTester::class.java.getMethods().toList()) .suppressing(CollectionClearTester::class.java.methods.toList())
.suppressing(CollectionRetainAllTester::class.java.getMethods().toList()) .suppressing(CollectionRetainAllTester::class.java.methods.toList())
.createTestSuite() .createTestSuite()
} }

View File

@ -69,7 +69,7 @@ function ThemeNav () {
}) })
.on('click', "[data-toggle='rst-current-version']", function() { .on('click', "[data-toggle='rst-current-version']", function() {
$("[data-toggle='rst-versions']").toggleClass("shift-up"); $("[data-toggle='rst-versions']").toggleClass("shift-up");
}) });
// Make tables responsive // Make tables responsive
$("table.docutils:not(.field-list)") $("table.docutils:not(.field-list)")
@ -139,12 +139,11 @@ function ThemeNav () {
parent_li.siblings().find('li.current').removeClass('current'); parent_li.siblings().find('li.current').removeClass('current');
parent_li.find('> ul li.current').removeClass('current'); parent_li.find('> ul li.current').removeClass('current');
parent_li.toggleClass('current'); parent_li.toggleClass('current');
} };
return nav; return nav;
}; }
module.exports.ThemeNav = ThemeNav();
module.exports.ThemeNav = ThemeNav();
if (typeof(window) != 'undefined') { if (typeof(window) != 'undefined') {
window.SphinxRtdTheme = { StickyNav: module.exports.ThemeNav }; window.SphinxRtdTheme = { StickyNav: module.exports.ThemeNav };

View File

@ -191,7 +191,7 @@ var Stemmer = function() {
w = firstch.toLowerCase() + w.substr(1); w = firstch.toLowerCase() + w.substr(1);
return w; return w;
} }
} };
@ -564,7 +564,7 @@ var Search = {
$u.each(_o, function(o) { $u.each(_o, function(o) {
var _files = o.files; var _files = o.files;
if (_files === undefined) if (_files === undefined)
return return;
if (_files.length === undefined) if (_files.length === undefined)
_files = [_files]; _files = [_files];
@ -574,7 +574,7 @@ var Search = {
for (j = 0; j < _files.length; j++) { for (j = 0; j < _files.length; j++) {
file = _files[j]; file = _files[j];
if (!(file in scoreMap)) if (!(file in scoreMap))
scoreMap[file] = {} scoreMap[file] = {};
scoreMap[file][word] = o.score; scoreMap[file][word] = o.score;
} }
}); });

View File

@ -5,7 +5,6 @@ import com.google.common.util.concurrent.ListenableFuture
import com.google.common.util.concurrent.SettableFuture import com.google.common.util.concurrent.SettableFuture
import com.r3corda.core.RunOnCallerThread import com.r3corda.core.RunOnCallerThread
import com.r3corda.core.contracts.SignedTransaction import com.r3corda.core.contracts.SignedTransaction
import com.r3corda.core.contracts.StateRef
import com.r3corda.core.crypto.Party import com.r3corda.core.crypto.Party
import com.r3corda.core.messaging.MessagingService import com.r3corda.core.messaging.MessagingService
import com.r3corda.core.messaging.runOnNextMessage import com.r3corda.core.messaging.runOnNextMessage
@ -48,14 +47,12 @@ import com.r3corda.node.services.wallet.NodeWalletService
import com.r3corda.node.utilities.ANSIProgressObserver import com.r3corda.node.utilities.ANSIProgressObserver
import com.r3corda.node.utilities.AddOrRemove import com.r3corda.node.utilities.AddOrRemove
import com.r3corda.node.utilities.AffinityExecutor import com.r3corda.node.utilities.AffinityExecutor
import com.r3corda.protocols.TwoPartyDealProtocol
import org.slf4j.Logger import org.slf4j.Logger
import java.nio.file.FileAlreadyExistsException import java.nio.file.FileAlreadyExistsException
import java.nio.file.Files import java.nio.file.Files
import java.nio.file.Path import java.nio.file.Path
import java.security.KeyPair import java.security.KeyPair
import java.time.Clock import java.time.Clock
import java.time.Duration
import java.util.* import java.util.*
/** /**

View File

@ -3,7 +3,6 @@ package com.r3corda.node.internal
import com.codahale.metrics.JmxReporter import com.codahale.metrics.JmxReporter
import com.google.common.net.HostAndPort import com.google.common.net.HostAndPort
import com.r3corda.core.messaging.MessagingService import com.r3corda.core.messaging.MessagingService
import com.r3corda.core.node.CordaPluginRegistry
import com.r3corda.core.node.NodeInfo import com.r3corda.core.node.NodeInfo
import com.r3corda.core.node.ServiceHub import com.r3corda.core.node.ServiceHub
import com.r3corda.core.node.services.ServiceType import com.r3corda.core.node.services.ServiceType
@ -30,7 +29,6 @@ import java.net.InetSocketAddress
import java.nio.channels.FileLock import java.nio.channels.FileLock
import java.nio.file.Path import java.nio.file.Path
import java.time.Clock import java.time.Clock
import java.util.*
import javax.management.ObjectName import javax.management.ObjectName
class ConfigurationException(message: String) : Exception(message) class ConfigurationException(message: String) : Exception(message)

View File

@ -8,16 +8,12 @@ import com.google.common.io.CountingInputStream
import com.r3corda.core.contracts.Attachment import com.r3corda.core.contracts.Attachment
import com.r3corda.core.crypto.SecureHash import com.r3corda.core.crypto.SecureHash
import com.r3corda.core.extractZipFile import com.r3corda.core.extractZipFile
import com.r3corda.node.services.api.AcceptsFileUpload
import com.r3corda.core.node.services.AttachmentStorage import com.r3corda.core.node.services.AttachmentStorage
import com.r3corda.core.utilities.loggerFor import com.r3corda.core.utilities.loggerFor
import com.r3corda.node.services.api.AcceptsFileUpload
import java.io.FilterInputStream import java.io.FilterInputStream
import java.io.InputStream import java.io.InputStream
import java.nio.file.FileAlreadyExistsException import java.nio.file.*
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import java.nio.file.StandardCopyOption
import java.util.* import java.util.*
import java.util.jar.JarInputStream import java.util.jar.JarInputStream
import javax.annotation.concurrent.ThreadSafe import javax.annotation.concurrent.ThreadSafe

View File

@ -2,7 +2,6 @@ package com.r3corda.node.services.persistence
import com.r3corda.core.crypto.Party import com.r3corda.core.crypto.Party
import com.r3corda.core.node.services.AttachmentStorage import com.r3corda.core.node.services.AttachmentStorage
import com.r3corda.core.node.services.StorageService
import com.r3corda.core.node.services.TransactionStorage import com.r3corda.core.node.services.TransactionStorage
import com.r3corda.core.node.services.TxWritableStorageService import com.r3corda.core.node.services.TxWritableStorageService
import com.r3corda.core.serialization.SingletonSerializeAsToken import com.r3corda.core.serialization.SingletonSerializeAsToken

View File

@ -1,8 +1,8 @@
package com.r3corda.node.servlets package com.r3corda.node.servlets
import com.r3corda.node.services.api.AcceptsFileUpload
import com.r3corda.node.internal.Node
import com.r3corda.core.utilities.loggerFor import com.r3corda.core.utilities.loggerFor
import com.r3corda.node.internal.Node
import com.r3corda.node.services.api.AcceptsFileUpload
import org.apache.commons.fileupload.servlet.ServletFileUpload import org.apache.commons.fileupload.servlet.ServletFileUpload
import java.util.* import java.util.*
import javax.servlet.http.HttpServlet import javax.servlet.http.HttpServlet

View File

@ -49,7 +49,7 @@ abstract class MutableClock : Clock() {
*/ */
val mutations: Observable<Long> by lazy { val mutations: Observable<Long> by lazy {
Observable.create({ subscriber: Subscriber<in Long> -> Observable.create({ subscriber: Subscriber<in Long> ->
if (!subscriber.isUnsubscribed()) { if (!subscriber.isUnsubscribed) {
mutationObservers.add(subscriber) mutationObservers.add(subscriber)
// This is not very intuitive, but subscribing to a subscriber observes unsubscribes. // This is not very intuitive, but subscribing to a subscriber observes unsubscribes.
subscriber.add(Subscriptions.create { mutationObservers.remove(subscriber) }) subscriber.add(Subscriptions.create { mutationObservers.remove(subscriber) })

View File

@ -29,7 +29,7 @@ object JsonSupport {
fun createDefaultMapper(identities: IdentityService): ObjectMapper { fun createDefaultMapper(identities: IdentityService): ObjectMapper {
val mapper = ServiceHubObjectMapper(identities) val mapper = ServiceHubObjectMapper(identities)
mapper.enable(SerializationFeature.INDENT_OUTPUT); mapper.enable(SerializationFeature.INDENT_OUTPUT)
mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY) mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
mapper.enable(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS) mapper.enable(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)

View File

@ -4,8 +4,6 @@ package com.r3corda.node.messaging
import com.r3corda.core.messaging.Message import com.r3corda.core.messaging.Message
import com.r3corda.core.messaging.TopicStringValidator import com.r3corda.core.messaging.TopicStringValidator
import com.r3corda.core.messaging.send
import com.r3corda.core.serialization.deserialize
import com.r3corda.node.internal.testing.MockNetwork import com.r3corda.node.internal.testing.MockNetwork
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test

View File

@ -9,11 +9,7 @@ import com.r3corda.node.services.persistence.NodeAttachmentService
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import java.nio.charset.Charset import java.nio.charset.Charset
import java.nio.file.FileAlreadyExistsException import java.nio.file.*
import java.nio.file.FileSystem
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.StandardOpenOption
import java.util.jar.JarEntry import java.util.jar.JarEntry
import java.util.jar.JarOutputStream import java.util.jar.JarOutputStream
import kotlin.test.assertEquals import kotlin.test.assertEquals

View File

@ -12,10 +12,10 @@ import com.r3corda.core.serialization.OpaqueBytes
import com.r3corda.core.testing.* import com.r3corda.core.testing.*
import com.r3corda.core.utilities.BriefLogFormatter import com.r3corda.core.utilities.BriefLogFormatter
import com.r3corda.node.services.wallet.NodeWalletService import com.r3corda.node.services.wallet.NodeWalletService
import org.assertj.core.api.Assertions.assertThatThrownBy
import org.junit.After import org.junit.After
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.assertj.core.api.Assertions.assertThatThrownBy;
import java.util.* import java.util.*
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertNull import kotlin.test.assertNull

View File

@ -32,7 +32,7 @@ var Node.styleClass: String
get() = getAttribute("ui.class") get() = getAttribute("ui.class")
fun createGraph(name: String, styles: String): SingleGraph { fun createGraph(name: String, styles: String): SingleGraph {
System.setProperty("org.graphstream.ui.renderer", "org.graphstream.ui.j2dviewer.J2DGraphRenderer"); System.setProperty("org.graphstream.ui.renderer", "org.graphstream.ui.j2dviewer.J2DGraphRenderer")
return SingleGraph(name).apply { return SingleGraph(name).apply {
stylesheet = styles stylesheet = styles
setAttribute("ui.quality") setAttribute("ui.quality")

View File

@ -3,7 +3,9 @@ package com.r3corda.node.visualiser
import com.r3corda.core.contracts.CommandData import com.r3corda.core.contracts.CommandData
import com.r3corda.core.contracts.ContractState import com.r3corda.core.contracts.ContractState
import com.r3corda.core.crypto.SecureHash import com.r3corda.core.crypto.SecureHash
import com.r3corda.core.testing.* import com.r3corda.core.testing.LedgerDSL
import com.r3corda.core.testing.TestLedgerDSLInterpreter
import com.r3corda.core.testing.TestTransactionDSLInterpreter
import org.graphstream.graph.Edge import org.graphstream.graph.Edge
import org.graphstream.graph.Node import org.graphstream.graph.Node
import org.graphstream.graph.implementations.SingleGraph import org.graphstream.graph.implementations.SingleGraph

View File

@ -51,7 +51,7 @@ class TraderDemoTest {
"--base-directory", baseDirectory "--base-directory", baseDirectory
) )
val proc = spawn("com.r3corda.demos.TraderDemoKt", args, "TradeDemoSeller") val proc = spawn("com.r3corda.demos.TraderDemoKt", args, "TradeDemoSeller")
assertExitOrKill(proc); assertExitOrKill(proc)
assertEquals(proc.exitValue(), 0) assertEquals(proc.exitValue(), 0)
} }

View File

@ -12,7 +12,7 @@ fun spawn(className: String, args: List<String>, appName: String): Process {
val builder = ProcessBuilder(javaArgs + args) val builder = ProcessBuilder(javaArgs + args)
builder.redirectError(Paths.get("error.$className.log").toFile()) builder.redirectError(Paths.get("error.$className.log").toFile())
builder.inheritIO() builder.inheritIO()
val process = builder.start(); val process = builder.start()
return process return process
} }

View File

@ -10,7 +10,7 @@ import java.util.concurrent.TimeUnit
private val client by lazy { private val client by lazy {
OkHttpClient.Builder() OkHttpClient.Builder()
.connectTimeout(5, TimeUnit.SECONDS) .connectTimeout(5, TimeUnit.SECONDS)
.readTimeout(60, TimeUnit.SECONDS).build(); .readTimeout(60, TimeUnit.SECONDS).build()
} }
fun putJson(url: URL, data: String) : Boolean { fun putJson(url: URL, data: String) : Boolean {
@ -27,12 +27,12 @@ fun uploadFile(url: URL, file: String) : Boolean {
val body = MultipartBody.Builder() val body = MultipartBody.Builder()
.setType(MultipartBody.FORM) .setType(MultipartBody.FORM)
.addFormDataPart("rates", "example.rates.txt", RequestBody.create(MediaType.parse("text/plain"), file)) .addFormDataPart("rates", "example.rates.txt", RequestBody.create(MediaType.parse("text/plain"), file))
.build(); .build()
return makeRequest(Request.Builder().url(url).post(body).build()) return makeRequest(Request.Builder().url(url).post(body).build())
} }
private fun makeRequest(request: Request): Boolean { private fun makeRequest(request: Request): Boolean {
val response = client.newCall(request).execute(); val response = client.newCall(request).execute()
if (!response.isSuccessful) { if (!response.isSuccessful) {
println("Could not fulfill HTTP request. Status Code: ${response.code()}. Message: ${response.body()}") println("Could not fulfill HTTP request. Status Code: ${response.code()}. Message: ${response.body()}")