mirror of
https://github.com/corda/corda.git
synced 2025-06-20 08:03:53 +00:00
Minor: auto-format of module: core
This commit is contained in:
@ -360,6 +360,7 @@ inline fun <reified T : ContractState> Iterable<StateAndRef<ContractState>>.filt
|
||||
@CordaSerializable
|
||||
data class PartyAndReference(val party: AnonymousParty, val reference: OpaqueBytes) {
|
||||
constructor(party: Party, reference: OpaqueBytes) : this(party.toAnonymous(), reference)
|
||||
|
||||
override fun toString() = "${party}$reference"
|
||||
}
|
||||
|
||||
|
@ -104,6 +104,7 @@ sealed class TransactionVerificationException(val tx: LedgerTransaction, cause:
|
||||
class SignersMissing(tx: LedgerTransaction, val missing: List<CompositeKey>) : TransactionVerificationException(tx, null) {
|
||||
override fun toString(): String = "Signers missing: ${missing.joinToString()}"
|
||||
}
|
||||
|
||||
class DuplicateInputStates(tx: LedgerTransaction, val duplicates: Set<StateRef>) : TransactionVerificationException(tx, null) {
|
||||
override fun toString(): String = "Duplicate inputs: ${duplicates.joinToString()}"
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ abstract class AbstractParty(val owningKey: CompositeKey) {
|
||||
|
||||
/** Anonymised parties do not include any detail apart from owning key, so equality is dependent solely on the key */
|
||||
override fun equals(other: Any?): Boolean = other is AbstractParty && this.owningKey == other.owningKey
|
||||
|
||||
override fun hashCode(): Int = owningKey.hashCode()
|
||||
abstract fun toAnonymous(): AnonymousParty
|
||||
abstract fun nameOrNull(): String?
|
||||
|
@ -12,7 +12,10 @@ import net.i2p.crypto.eddsa.spec.EdDSANamedCurveTable
|
||||
import net.i2p.crypto.eddsa.spec.EdDSAPrivateKeySpec
|
||||
import net.i2p.crypto.eddsa.spec.EdDSAPublicKeySpec
|
||||
import java.math.BigInteger
|
||||
import java.security.*
|
||||
import java.security.KeyPair
|
||||
import java.security.PrivateKey
|
||||
import java.security.PublicKey
|
||||
import java.security.SignatureException
|
||||
|
||||
/** A wrapper around a digital signature. */
|
||||
@CordaSerializable
|
||||
|
@ -25,6 +25,7 @@ import java.security.PublicKey
|
||||
class Party(val name: String, owningKey: CompositeKey) : AbstractParty(owningKey) {
|
||||
/** A helper constructor that converts the given [PublicKey] in to a [CompositeKey] with a single node */
|
||||
constructor(name: String, owningKey: PublicKey) : this(name, owningKey.composite)
|
||||
|
||||
override fun toAnonymous(): AnonymousParty = AnonymousParty(owningKey)
|
||||
override fun toString() = "${owningKey.toBase58String()} (${name})"
|
||||
override fun nameOrNull(): String? = name
|
||||
|
@ -1,6 +1,8 @@
|
||||
package net.corda.core.crypto
|
||||
|
||||
import java.security.*
|
||||
import java.security.KeyFactory
|
||||
import java.security.KeyPairGeneratorSpi
|
||||
import java.security.Signature
|
||||
import java.security.spec.AlgorithmParameterSpec
|
||||
|
||||
/**
|
||||
|
@ -1,8 +1,6 @@
|
||||
package net.corda.core.crypto
|
||||
|
||||
import net.corda.core.serialization.opaque
|
||||
import java.security.InvalidKeyException
|
||||
import java.security.PublicKey
|
||||
import java.security.SignatureException
|
||||
|
||||
/**
|
||||
|
@ -23,11 +23,10 @@ import org.bouncycastle.pkcs.PKCS10CertificationRequest
|
||||
import org.bouncycastle.pkcs.jcajce.JcaPKCS10CertificationRequestBuilder
|
||||
import org.bouncycastle.util.IPAddress
|
||||
import org.bouncycastle.util.io.pem.PemReader
|
||||
import java.io.ByteArrayInputStream
|
||||
import java.io.FileReader
|
||||
import java.io.FileWriter
|
||||
import java.io.InputStream
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
import java.math.BigInteger
|
||||
import java.net.InetAddress
|
||||
import java.nio.file.Path
|
||||
|
@ -196,7 +196,9 @@ abstract class FlowLogic<out T> {
|
||||
*/
|
||||
var stateMachine: FlowStateMachine<*>
|
||||
get() = _stateMachine ?: throw IllegalStateException("This can only be done after the flow has been started.")
|
||||
set(value) { _stateMachine = value }
|
||||
set(value) {
|
||||
_stateMachine = value
|
||||
}
|
||||
|
||||
// This points to the outermost flow and is changed when a subflow is invoked.
|
||||
private var sessionFlow: FlowLogic<*> = this
|
||||
|
@ -13,6 +13,7 @@ sealed class PartyInfo {
|
||||
data class Node(val node: NodeInfo) : PartyInfo() {
|
||||
override val party get() = node.legalIdentity
|
||||
}
|
||||
|
||||
data class Service(val service: ServiceEntry) : PartyInfo() {
|
||||
override val party get() = service.identity
|
||||
}
|
||||
|
@ -1,9 +1,8 @@
|
||||
package net.corda.core.schemas.requery.converters
|
||||
|
||||
import io.requery.Converter
|
||||
|
||||
import java.sql.*
|
||||
import java.time.*
|
||||
import java.sql.Timestamp
|
||||
import java.time.Instant
|
||||
|
||||
/**
|
||||
* Converts from a [Instant] to a [java.sql.Timestamp] for Java 8. Note that
|
||||
@ -12,19 +11,29 @@ import java.time.*
|
||||
*/
|
||||
class InstantConverter : Converter<Instant, Timestamp> {
|
||||
|
||||
override fun getMappedType(): Class<Instant> { return Instant::class.java }
|
||||
override fun getMappedType(): Class<Instant> {
|
||||
return Instant::class.java
|
||||
}
|
||||
|
||||
override fun getPersistedType(): Class<Timestamp> { return Timestamp::class.java }
|
||||
override fun getPersistedType(): Class<Timestamp> {
|
||||
return Timestamp::class.java
|
||||
}
|
||||
|
||||
override fun getPersistedSize(): Int? { return null }
|
||||
override fun getPersistedSize(): Int? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun convertToPersisted(value: Instant?): Timestamp? {
|
||||
if (value == null) { return null }
|
||||
if (value == null) {
|
||||
return null
|
||||
}
|
||||
return Timestamp.from(value)
|
||||
}
|
||||
|
||||
override fun convertToMapped(type: Class<out Instant>, value: Timestamp?): Instant? {
|
||||
if (value == null) { return null }
|
||||
if (value == null) {
|
||||
return null
|
||||
}
|
||||
return value.toInstant()
|
||||
}
|
||||
}
|
@ -9,20 +9,30 @@ import net.corda.core.crypto.SecureHash
|
||||
*/
|
||||
class StateRefConverter : Converter<StateRef, Pair<String, Int>> {
|
||||
|
||||
override fun getMappedType(): Class<StateRef> { return StateRef::class.java }
|
||||
override fun getMappedType(): Class<StateRef> {
|
||||
return StateRef::class.java
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun getPersistedType(): Class<Pair<String,Int>> { return Pair::class.java as Class<Pair<String,Int>> }
|
||||
override fun getPersistedType(): Class<Pair<String, Int>> {
|
||||
return Pair::class.java as Class<Pair<String, Int>>
|
||||
}
|
||||
|
||||
override fun getPersistedSize(): Int? { return null }
|
||||
override fun getPersistedSize(): Int? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun convertToPersisted(value: StateRef?): Pair<String, Int>? {
|
||||
if (value == null) { return null }
|
||||
if (value == null) {
|
||||
return null
|
||||
}
|
||||
return Pair(value.txhash.toString(), value.index)
|
||||
}
|
||||
|
||||
override fun convertToMapped(type: Class<out StateRef>, value: Pair<String, Int>?): StateRef? {
|
||||
if (value == null) { return null }
|
||||
if (value == null) {
|
||||
return null
|
||||
}
|
||||
return StateRef(SecureHash.parse(value.first), value.second)
|
||||
}
|
||||
}
|
@ -1,14 +1,8 @@
|
||||
package net.corda.core.schemas.requery.converters
|
||||
|
||||
import io.requery.Converter
|
||||
import io.requery.converter.EnumOrdinalConverter
|
||||
import io.requery.sql.Mapping
|
||||
import net.corda.core.contracts.ContractState
|
||||
import net.corda.core.node.services.Vault
|
||||
|
||||
import java.sql.*
|
||||
import java.time.*
|
||||
|
||||
/**
|
||||
* Converter which persists a [Vault.StateStatus] enum using its enum ordinal representation
|
||||
*/
|
||||
|
@ -14,7 +14,6 @@ import net.corda.core.serialization.p2PKryo
|
||||
import net.corda.core.serialization.serialize
|
||||
import net.corda.core.utilities.Emoji
|
||||
import java.security.PublicKey
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* A transaction ready for serialisation, without any signatures attached. A WireTransaction is usually wrapped
|
||||
|
@ -41,6 +41,7 @@ class FinalityFlow(val transactions: Iterable<SignedTransaction>,
|
||||
object NOTARISING : ProgressTracker.Step("Requesting signature by notary service") {
|
||||
override fun childProgressTracker() = NotaryFlow.Client.tracker()
|
||||
}
|
||||
|
||||
object BROADCASTING : ProgressTracker.Step("Broadcasting transaction to participants")
|
||||
|
||||
// TODO: Make all tracker() methods @JvmStatic
|
||||
@ -90,6 +91,7 @@ class FinalityFlow(val transactions: Iterable<SignedTransaction>,
|
||||
return needsNotarisation && hasNoNotarySignature(stx)
|
||||
|
||||
}
|
||||
|
||||
private fun hasNoNotarySignature(stx: SignedTransaction): Boolean {
|
||||
val notaryKey = stx.tx.notary?.owningKey
|
||||
val signers = stx.sigs.map { it.by }.toSet()
|
||||
|
@ -5,7 +5,6 @@ import net.corda.core.crypto.CompositeKey
|
||||
import net.corda.core.crypto.Party
|
||||
import net.corda.core.crypto.composite
|
||||
import net.corda.core.flows.FlowLogic
|
||||
import net.corda.core.node.ServiceHub
|
||||
import net.corda.core.serialization.CordaSerializable
|
||||
import net.corda.core.utilities.unwrap
|
||||
import java.security.cert.Certificate
|
||||
|
@ -1,15 +1,13 @@
|
||||
package net.corda.core.flows;
|
||||
|
||||
import co.paralleluniverse.fibers.Suspendable;
|
||||
import net.corda.core.crypto.Party;
|
||||
import net.corda.testing.node.MockNetwork;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import co.paralleluniverse.fibers.*;
|
||||
import net.corda.core.crypto.*;
|
||||
import net.corda.testing.node.*;
|
||||
import org.junit.*;
|
||||
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
|
||||
import static org.assertj.core.api.AssertionsForClassTypes.*;
|
||||
|
||||
public class FlowsInJavaTest {
|
||||
|
||||
|
@ -17,9 +17,13 @@ import org.junit.Assert.assertNotEquals
|
||||
import org.junit.Test
|
||||
import java.security.KeyFactory
|
||||
import java.security.Security
|
||||
import java.security.spec.PKCS8EncodedKeySpec
|
||||
import java.security.spec.X509EncodedKeySpec
|
||||
import java.util.*
|
||||
import java.security.spec.*
|
||||
import kotlin.test.*
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertNotNull
|
||||
import kotlin.test.assertTrue
|
||||
import kotlin.test.fail
|
||||
|
||||
/**
|
||||
* Run tests for cryptographic algorithms
|
||||
|
@ -27,6 +27,7 @@ class EncodingUtilsTest {
|
||||
assertEquals("", emptyByteArray.toBase64())
|
||||
assertEquals("", emptyByteArray.toHex())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `encoding 7 zero bytes`() {
|
||||
val sevenZeroByteArray = ByteArray(7)
|
||||
|
@ -103,6 +103,7 @@ class PartialMerkleTreeTest {
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
val mt = testTx.buildFilteredTransaction(::filtering)
|
||||
val leaves = mt.filteredLeaves
|
||||
val d = WireTransaction.deserialize(testTx.serialized)
|
||||
|
@ -7,7 +7,6 @@ import java.security.Security
|
||||
import java.security.SignatureException
|
||||
import java.time.Instant
|
||||
import kotlin.test.assertTrue
|
||||
import kotlin.test.fail
|
||||
|
||||
/**
|
||||
* Digital signature MetaData tests
|
||||
|
@ -12,7 +12,6 @@ import net.corda.core.utilities.DUMMY_NOTARY
|
||||
import net.corda.testing.MEGA_CORP
|
||||
import net.corda.testing.node.MockAttachmentStorage
|
||||
import org.apache.commons.io.IOUtils
|
||||
import org.junit.After
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
@ -4,6 +4,7 @@ import com.esotericsoftware.kryo.Kryo
|
||||
import com.google.common.primitives.Ints
|
||||
import net.corda.core.crypto.*
|
||||
import net.corda.core.messaging.Ack
|
||||
import net.corda.node.services.persistence.NodeAttachmentService
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.assertj.core.api.Assertions.assertThatThrownBy
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider
|
||||
@ -11,14 +12,13 @@ import org.bouncycastle.pqc.jcajce.provider.BouncyCastlePQCProvider
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.io.ByteArrayInputStream
|
||||
import java.io.InputStream
|
||||
import java.security.Security
|
||||
import java.time.Instant
|
||||
import java.util.*
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertTrue
|
||||
import net.corda.node.services.persistence.NodeAttachmentService
|
||||
import java.io.ByteArrayInputStream
|
||||
|
||||
class KryoTests {
|
||||
|
||||
|
Reference in New Issue
Block a user