Moved TestConstants.kt from core into test-utils

This commit is contained in:
Shams Asari 2017-07-04 13:56:51 +01:00
parent 3176ecfecf
commit 2973755bc8
109 changed files with 300 additions and 306 deletions

View File

@ -21,10 +21,10 @@ import net.corda.core.node.services.ServiceInfo
import net.corda.core.node.services.Vault
import net.corda.core.serialization.OpaqueBytes
import net.corda.core.transactions.SignedTransaction
import net.corda.core.utilities.ALICE
import net.corda.core.utilities.BOB
import net.corda.core.utilities.CHARLIE
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.ALICE
import net.corda.testing.BOB
import net.corda.testing.CHARLIE
import net.corda.testing.DUMMY_NOTARY
import net.corda.flows.CashExitFlow
import net.corda.flows.CashIssueFlow
import net.corda.flows.CashPaymentFlow

View File

@ -7,7 +7,7 @@ import net.corda.core.messaging.*
import net.corda.core.node.services.ServiceInfo
import net.corda.core.random63BitValue
import net.corda.core.serialization.OpaqueBytes
import net.corda.core.utilities.ALICE
import net.corda.testing.ALICE
import net.corda.flows.CashException
import net.corda.flows.CashIssueFlow
import net.corda.flows.CashPaymentFlow

View File

@ -20,7 +20,6 @@ import net.corda.core.node.services.vault.SortAttribute
import net.corda.core.seconds
import net.corda.core.serialization.OpaqueBytes
import net.corda.core.sizedInputStreamAndHash
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.core.utilities.loggerFor
import net.corda.flows.CashIssueFlow
import net.corda.flows.CashPaymentFlow
@ -28,6 +27,7 @@ import net.corda.nodeapi.User
import net.corda.smoketesting.NodeConfig
import net.corda.smoketesting.NodeProcess
import org.apache.commons.io.output.NullOutputStream
import org.bouncycastle.asn1.x500.X500Name
import org.junit.After
import org.junit.Before
import org.junit.Test
@ -54,7 +54,7 @@ class StandaloneCordaRPClientTest {
private lateinit var notaryNode: NodeInfo
private val notaryConfig = NodeConfig(
party = DUMMY_NOTARY,
legalName = X500Name("CN=Notary Service,O=R3,OU=corda,L=Zurich,C=CH"),
p2pPort = port.andIncrement,
rpcPort = port.andIncrement,
webPort = port.andIncrement,
@ -115,7 +115,7 @@ class StandaloneCordaRPClientTest {
@Test
fun `test network map`() {
assertEquals(DUMMY_NOTARY.name, notaryNode.legalIdentity.name)
assertEquals(notaryConfig.legalName, notaryNode.legalIdentity.name)
}
@Test

View File

@ -3,8 +3,8 @@ package net.corda.core.contracts
import net.corda.core.contracts.testing.DummyContract
import net.corda.core.contracts.testing.DummyContractV2
import net.corda.core.crypto.SecureHash
import net.corda.core.utilities.ALICE
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.ALICE
import net.corda.testing.DUMMY_NOTARY
import org.junit.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue

View File

@ -5,8 +5,8 @@ import net.corda.core.contracts.testing.DummyState
import net.corda.core.crypto.newSecureRandom
import net.corda.core.transactions.SignedTransaction
import net.corda.core.transactions.WireTransaction
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.core.utilities.DUMMY_NOTARY_KEY
import net.corda.testing.DUMMY_NOTARY
import net.corda.testing.DUMMY_NOTARY_KEY
import net.corda.testing.MEGA_CORP_KEY
import net.corda.testing.MEGA_CORP_PUBKEY
import net.corda.testing.node.MockServices

View File

@ -11,7 +11,7 @@ import net.corda.core.serialization.SerializedBytes
import net.corda.core.transactions.LedgerTransaction
import net.corda.core.transactions.SignedTransaction
import net.corda.core.transactions.WireTransaction
import net.corda.core.utilities.*
import net.corda.testing.*
import org.junit.Test
import java.security.KeyPair
import kotlin.test.assertEquals

View File

@ -9,9 +9,9 @@ import net.corda.core.identity.Party
import net.corda.core.serialization.p2PKryo
import net.corda.core.serialization.serialize
import net.corda.core.transactions.WireTransaction
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.core.utilities.DUMMY_PUBKEY_1
import net.corda.core.utilities.TEST_TX_TIME
import net.corda.testing.DUMMY_NOTARY
import net.corda.testing.DUMMY_PUBKEY_1
import net.corda.testing.TEST_TX_TIME
import net.corda.testing.*
import org.junit.Test
import java.security.PublicKey

View File

@ -6,7 +6,7 @@ import net.corda.core.getOrThrow
import net.corda.core.identity.Party
import net.corda.core.serialization.opaque
import net.corda.core.transactions.SignedTransaction
import net.corda.core.utilities.DUMMY_NOTARY_KEY
import net.corda.testing.DUMMY_NOTARY_KEY
import net.corda.flows.ResolveTransactionsFlow
import net.corda.node.utilities.transaction
import net.corda.testing.MEGA_CORP

View File

@ -1,7 +1,7 @@
package net.corda.core.identity
import net.corda.core.crypto.entropyToKeyPair
import net.corda.core.utilities.ALICE
import net.corda.testing.ALICE
import org.junit.Test
import java.math.BigInteger
import kotlin.test.assertEquals

View File

@ -10,7 +10,7 @@ import net.corda.core.identity.Party
import net.corda.core.node.services.AttachmentStorage
import net.corda.core.serialization.*
import net.corda.core.transactions.TransactionBuilder
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.DUMMY_NOTARY
import net.corda.testing.MEGA_CORP
import net.corda.testing.node.MockAttachmentStorage
import org.apache.commons.io.IOUtils

View File

@ -4,7 +4,7 @@ import net.corda.core.contracts.*
import net.corda.core.crypto.SecureHash
import net.corda.core.identity.AbstractParty
import net.corda.core.node.services.Vault
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.DUMMY_NOTARY
import org.junit.Test
import kotlin.test.assertEquals

View File

@ -3,8 +3,8 @@ package net.corda.core.serialization
import com.esotericsoftware.kryo.Kryo
import com.google.common.primitives.Ints
import net.corda.core.crypto.*
import net.corda.core.utilities.ALICE
import net.corda.core.utilities.BOB
import net.corda.testing.ALICE
import net.corda.testing.BOB
import net.corda.node.services.messaging.Ack
import net.corda.node.services.persistence.NodeAttachmentService
import net.corda.testing.BOB_PUBKEY

View File

@ -5,7 +5,6 @@ import net.corda.core.crypto.SecureHash
import net.corda.core.identity.AbstractParty
import net.corda.core.seconds
import net.corda.core.transactions.TransactionBuilder
import net.corda.core.utilities.*
import net.corda.testing.*
import net.corda.testing.node.MockServices
import org.junit.Before

View File

@ -3,9 +3,9 @@ package net.corda.flows
import net.corda.core.getOrThrow
import net.corda.core.identity.AbstractParty
import net.corda.core.identity.Party
import net.corda.core.utilities.ALICE
import net.corda.core.utilities.BOB
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.ALICE
import net.corda.testing.BOB
import net.corda.testing.DUMMY_NOTARY
import net.corda.testing.node.MockNetwork
import org.junit.Before
import org.junit.Test

View File

@ -17,6 +17,9 @@ UNRELEASED
* ``ServiceHub.storageService`` has been removed. ``attachments`` and ``validatedTransactions`` are now direct members of
``ServiceHub``.
* Mock identity constants used in tests, such as ``ALICE``, ``BOB``, ``DUMMY_NOTARY``, have moved to ``net.corda.testing``
in the ``test-utils`` module.
Milestone 13
------------

View File

@ -9,9 +9,9 @@ import net.corda.core.messaging.startFlow
import net.corda.core.node.services.ServiceInfo
import net.corda.core.node.services.Vault
import net.corda.core.serialization.OpaqueBytes
import net.corda.core.utilities.ALICE
import net.corda.core.utilities.BOB
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.ALICE
import net.corda.testing.BOB
import net.corda.testing.DUMMY_NOTARY
import net.corda.flows.CashIssueFlow
import net.corda.flows.CashPaymentFlow
import net.corda.testing.driver.driver

View File

@ -36,7 +36,7 @@ import java.util.List;
import java.util.Set;
import static net.corda.core.contracts.ContractsDSL.requireThat;
import static net.corda.core.utilities.TestConstants.getDUMMY_PUBKEY_1;
import static net.corda.testing.TestConstants.getDUMMY_PUBKEY_1;
// We group our two flows inside a singleton object to indicate that they work
// together.

View File

@ -12,8 +12,8 @@ import net.corda.core.serialization.CordaSerializable
import net.corda.core.serialization.OpaqueBytes
import net.corda.core.serialization.SerializationCustomization
import net.corda.core.transactions.SignedTransaction
import net.corda.core.utilities.ALICE
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.ALICE
import net.corda.testing.DUMMY_NOTARY
import net.corda.flows.CashExitFlow
import net.corda.flows.CashIssueFlow
import net.corda.flows.CashPaymentFlow

View File

@ -18,7 +18,7 @@ import net.corda.core.transactions.LedgerTransaction
import net.corda.core.transactions.SignedTransaction
import net.corda.core.transactions.TransactionBuilder
import net.corda.core.transactions.WireTransaction
import net.corda.core.utilities.DUMMY_PUBKEY_1
import net.corda.testing.DUMMY_PUBKEY_1
import net.corda.core.utilities.ProgressTracker
import net.corda.core.utilities.ProgressTracker.Step
import net.corda.core.utilities.UntrustworthyData

View File

@ -5,8 +5,8 @@ import net.corda.core.getOrThrow
import net.corda.core.node.services.ServiceInfo
import net.corda.core.serialization.OpaqueBytes
import net.corda.core.toFuture
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.core.utilities.DUMMY_NOTARY_KEY
import net.corda.testing.DUMMY_NOTARY
import net.corda.testing.DUMMY_NOTARY_KEY
import net.corda.flows.CashIssueFlow
import net.corda.node.services.network.NetworkMapService
import net.corda.node.services.transactions.ValidatingNotaryService

View File

@ -11,8 +11,8 @@ import net.corda.core.node.services.queryBy
import net.corda.core.node.services.vault.QueryCriteria
import net.corda.core.node.services.vault.and
import net.corda.core.toFuture
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.core.utilities.DUMMY_NOTARY_KEY
import net.corda.testing.DUMMY_NOTARY
import net.corda.testing.DUMMY_NOTARY_KEY
import net.corda.node.services.network.NetworkMapService
import net.corda.node.services.transactions.ValidatingNotaryService
import net.corda.node.utilities.transaction

View File

@ -4,7 +4,7 @@ import net.corda.contracts.BusinessCalendar
import net.corda.contracts.FixOf
import net.corda.contracts.Frequency
import net.corda.contracts.Tenor
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.DUMMY_NOTARY
import net.corda.testing.transaction
import org.junit.Ignore
import org.junit.Test

View File

@ -2,7 +2,7 @@ package net.corda.contracts.universal
import net.corda.contracts.FixOf
import net.corda.contracts.Tenor
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.DUMMY_NOTARY
import net.corda.testing.transaction
import org.junit.Ignore
import org.junit.Test

View File

@ -2,7 +2,7 @@ package net.corda.contracts.universal
import net.corda.core.crypto.generateKeyPair
import net.corda.core.identity.Party
import net.corda.core.utilities.ALICE
import net.corda.testing.ALICE
import net.corda.testing.MEGA_CORP
import net.corda.testing.MINI_CORP
import org.junit.Test

View File

@ -1,6 +1,6 @@
package net.corda.contracts.universal
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.DUMMY_NOTARY
import net.corda.testing.transaction
import org.junit.Ignore
import org.junit.Test

View File

@ -1,6 +1,6 @@
package net.corda.contracts.universal
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.DUMMY_NOTARY
import net.corda.testing.transaction
import org.junit.Ignore
import org.junit.Test

View File

@ -3,7 +3,7 @@ package net.corda.contracts.universal
import net.corda.contracts.FixOf
import net.corda.contracts.Frequency
import net.corda.contracts.Tenor
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.DUMMY_NOTARY
import net.corda.testing.transaction
import org.junit.Ignore
import org.junit.Test

View File

@ -1,7 +1,7 @@
package net.corda.contracts.universal
import net.corda.contracts.Frequency
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.DUMMY_NOTARY
import net.corda.testing.transaction
import org.junit.Test
import java.time.Instant

View File

@ -2,7 +2,7 @@ package net.corda.contracts.universal
import net.corda.contracts.Frequency
import net.corda.contracts.Tenor
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.DUMMY_NOTARY
import net.corda.testing.transaction
import org.junit.Ignore
import org.junit.Test

View File

@ -1,6 +1,6 @@
package net.corda.contracts.universal
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.DUMMY_NOTARY
import net.corda.testing.transaction
import org.junit.Test
import java.time.Instant

View File

@ -19,8 +19,6 @@ import net.corda.core.serialization.CordaSerializable
import net.corda.core.transactions.TransactionBuilder
import net.corda.core.utilities.Emoji
import net.corda.core.utilities.NonEmptySet
import net.corda.core.utilities.TEST_TX_TIME
import net.corda.core.utilities.nonEmptySetOf
import org.bouncycastle.asn1.x500.X500Name
import java.math.BigInteger
import java.security.PublicKey
@ -727,8 +725,3 @@ infix fun <T : Any> Obligation.State<T>.`issued by`(party: AbstractParty) = copy
val DUMMY_OBLIGATION_ISSUER_KEY by lazy { entropyToKeyPair(BigInteger.valueOf(10)) }
/** A dummy, randomly generated issuer party by the name of "Snake Oil Issuer" */
val DUMMY_OBLIGATION_ISSUER by lazy { Party(X500Name("CN=Snake Oil Issuer,O=R3,OU=corda,L=London,C=GB"), DUMMY_OBLIGATION_ISSUER_KEY.public) }
val Issued<Currency>.OBLIGATION_DEF: Obligation.Terms<Currency>
get() = Obligation.Terms(nonEmptySetOf(Cash().legalContractReference), nonEmptySetOf(this), TEST_TX_TIME)
val Amount<Issued<Currency>>.OBLIGATION: Obligation.State<Currency>
get() = Obligation.State(Obligation.Lifecycle.NORMAL, DUMMY_OBLIGATION_ISSUER, token.OBLIGATION_DEF, quantity, NULL_PARTY)

View File

@ -8,8 +8,8 @@ import org.junit.Test;
import static net.corda.core.contracts.ContractsDSL.DOLLARS;
import static net.corda.core.contracts.ContractsDSL.issuedBy;
import static net.corda.core.utilities.TestConstants.getDUMMY_PUBKEY_1;
import static net.corda.core.utilities.TestConstants.getDUMMY_PUBKEY_2;
import static net.corda.testing.TestConstants.getDUMMY_PUBKEY_1;
import static net.corda.testing.TestConstants.getDUMMY_PUBKEY_2;
import static net.corda.testing.CoreTestUtils.*;
/**

View File

@ -1,7 +1,7 @@
package net.corda.contracts
import net.corda.contracts.asset.*
import net.corda.contracts.testing.fillWithSomeTestCash
import net.corda.testing.contracts.fillWithSomeTestCash
import net.corda.core.contracts.*
import net.corda.core.days
import net.corda.core.identity.AnonymousParty
@ -10,7 +10,6 @@ import net.corda.core.node.services.Vault
import net.corda.core.node.services.VaultService
import net.corda.core.seconds
import net.corda.core.transactions.SignedTransaction
import net.corda.core.utilities.*
import net.corda.node.utilities.configureDatabase
import net.corda.node.utilities.transaction
import net.corda.testing.*

View File

@ -1,6 +1,6 @@
package net.corda.contracts.asset
import net.corda.contracts.testing.fillWithSomeTestCash
import net.corda.testing.contracts.fillWithSomeTestCash
import net.corda.core.contracts.*
import net.corda.core.contracts.testing.DummyState
import net.corda.core.crypto.SecureHash

View File

@ -6,6 +6,7 @@ import net.corda.contracts.asset.Obligation.Lifecycle
import net.corda.core.contracts.*
import net.corda.core.contracts.testing.DummyState
import net.corda.core.crypto.SecureHash
import net.corda.core.hours
import net.corda.core.crypto.testing.NULL_PARTY
import net.corda.core.identity.AbstractParty
import net.corda.core.identity.AnonymousParty
@ -15,6 +16,7 @@ import net.corda.testing.*
import net.corda.testing.node.MockServices
import org.junit.Test
import java.time.Duration
import java.time.Instant
import java.time.temporal.ChronoUnit
import java.util.*
import kotlin.test.assertEquals
@ -23,14 +25,14 @@ import kotlin.test.assertNotEquals
import kotlin.test.assertTrue
class ObligationTests {
val defaultRef = OpaqueBytes(ByteArray(1, { 1 }))
val defaultRef = OpaqueBytes.of(1)
val defaultIssuer = MEGA_CORP.ref(defaultRef)
val oneMillionDollars = 1000000.DOLLARS `issued by` defaultIssuer
val trustedCashContract = nonEmptySetOf(SecureHash.randomSHA256() as SecureHash)
val megaIssuedDollars = nonEmptySetOf(Issued(defaultIssuer, USD))
val megaIssuedPounds = nonEmptySetOf(Issued(defaultIssuer, GBP))
val fivePm = TEST_TX_TIME.truncatedTo(ChronoUnit.DAYS).plus(17, ChronoUnit.HOURS)
val sixPm = fivePm.plus(1, ChronoUnit.HOURS)
val fivePm: Instant = TEST_TX_TIME.truncatedTo(ChronoUnit.DAYS) + 17.hours
val sixPm: Instant = fivePm + 1.hours
val megaCorpDollarSettlement = Obligation.Terms(trustedCashContract, megaIssuedDollars, fivePm)
val megaCorpPoundSettlement = megaCorpDollarSettlement.copy(acceptableIssuedProducts = megaIssuedPounds)
val inState = Obligation.State(
@ -871,4 +873,9 @@ class ObligationTests {
val actual = sumAmountsDue(balanced)
assertEquals(expected, actual)
}
val Issued<Currency>.OBLIGATION_DEF: Obligation.Terms<Currency>
get() = Obligation.Terms(nonEmptySetOf(Cash().legalContractReference), nonEmptySetOf(this), TEST_TX_TIME)
val Amount<Issued<Currency>>.OBLIGATION: Obligation.State<Currency>
get() = Obligation.State(Obligation.Lifecycle.NORMAL, DUMMY_OBLIGATION_ISSUER, token.OBLIGATION_DEF, quantity, NULL_PARTY)
}

View File

@ -1,7 +1,7 @@
package net.corda.flows
import com.google.common.util.concurrent.ListenableFuture
import net.corda.contracts.testing.calculateRandomlySizedAmounts
import net.corda.testing.contracts.calculateRandomlySizedAmounts
import net.corda.core.contracts.Amount
import net.corda.core.contracts.DOLLARS
import net.corda.core.contracts.currency
@ -13,7 +13,7 @@ import net.corda.core.map
import net.corda.core.serialization.OpaqueBytes
import net.corda.core.toFuture
import net.corda.core.transactions.SignedTransaction
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.DUMMY_NOTARY
import net.corda.flows.IssuerFlow.IssuanceRequester
import net.corda.testing.BOC
import net.corda.testing.MEGA_CORP

View File

@ -8,12 +8,14 @@ description 'Corda node database schemas'
dependencies {
compile project(':core')
testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
testCompile "junit:junit:$junit_version"
// Requery: SQL based query & persistence for Kotlin
kapt "io.requery:requery-processor:$requery_version"
testCompile project(':test-utils')
testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
testCompile "junit:junit:$junit_version"
// For H2 database support in persistence
testCompile "com.h2database:h2:$h2_version"
}

View File

@ -21,11 +21,11 @@ import net.corda.core.schemas.requery.converters.VaultStateStatusConverter
import net.corda.core.serialization.deserialize
import net.corda.core.serialization.serialize
import net.corda.core.transactions.LedgerTransaction
import net.corda.core.utilities.ALICE
import net.corda.core.utilities.BOB
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.core.utilities.DUMMY_NOTARY_KEY
import net.corda.node.services.vault.schemas.requery.*
import net.corda.testing.ALICE
import net.corda.testing.BOB
import net.corda.testing.DUMMY_NOTARY
import net.corda.testing.DUMMY_NOTARY_KEY
import org.h2.jdbcx.JdbcDataSource
import org.junit.After
import org.junit.Assert

View File

@ -8,7 +8,7 @@ import net.corda.core.getOrThrow
import net.corda.core.messaging.startFlow
import net.corda.core.node.services.ServiceInfo
import net.corda.core.node.services.ServiceType
import net.corda.core.utilities.ALICE
import net.corda.testing.ALICE
import net.corda.testing.driver.driver
import net.corda.node.internal.NodeStartup
import net.corda.node.services.startFlowPermission

View File

@ -9,8 +9,8 @@ import net.corda.core.flows.StartableByRPC
import net.corda.core.getOrThrow
import net.corda.core.identity.Party
import net.corda.core.messaging.startFlow
import net.corda.core.utilities.ALICE
import net.corda.core.utilities.BOB
import net.corda.testing.ALICE
import net.corda.testing.BOB
import net.corda.core.utilities.unwrap
import net.corda.node.services.startFlowPermission
import net.corda.nodeapi.User

View File

@ -10,8 +10,8 @@ import net.corda.core.messaging.StateMachineUpdate
import net.corda.core.messaging.startFlow
import net.corda.core.node.NodeInfo
import net.corda.core.serialization.OpaqueBytes
import net.corda.core.utilities.ALICE
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.ALICE
import net.corda.testing.DUMMY_NOTARY
import net.corda.flows.CashIssueFlow
import net.corda.flows.CashPaymentFlow
import net.corda.testing.driver.NodeHandle

View File

@ -8,7 +8,7 @@ import net.corda.core.contracts.testing.DummyContract
import net.corda.core.getOrThrow
import net.corda.core.identity.Party
import net.corda.core.map
import net.corda.core.utilities.DUMMY_BANK_A
import net.corda.testing.DUMMY_BANK_A
import net.corda.flows.NotaryError
import net.corda.flows.NotaryException
import net.corda.flows.NotaryFlow

View File

@ -6,8 +6,8 @@ import net.corda.core.flows.FlowLogic
import net.corda.core.flows.InitiatingFlow
import net.corda.core.getOrThrow
import net.corda.core.identity.Party
import net.corda.core.utilities.ALICE
import net.corda.core.utilities.BOB
import net.corda.testing.ALICE
import net.corda.testing.BOB
import net.corda.core.utilities.unwrap
import net.corda.testing.node.NodeBasedTest
import org.assertj.core.api.Assertions.assertThat

View File

@ -12,8 +12,8 @@ import net.corda.core.getOrThrow
import net.corda.core.identity.Party
import net.corda.core.messaging.CordaRPCOps
import net.corda.core.random63BitValue
import net.corda.core.utilities.ALICE
import net.corda.core.utilities.BOB
import net.corda.testing.ALICE
import net.corda.testing.BOB
import net.corda.core.utilities.unwrap
import net.corda.node.internal.Node
import net.corda.nodeapi.ArtemisMessagingComponent.Companion.INTERNAL_PREFIX

View File

@ -10,14 +10,12 @@ import net.corda.core.node.services.ServiceInfo
import net.corda.core.serialization.CordaSerializable
import net.corda.core.serialization.deserialize
import net.corda.core.serialization.serialize
import net.corda.core.utilities.*
import net.corda.node.internal.Node
import net.corda.node.services.messaging.*
import net.corda.node.services.transactions.RaftValidatingNotaryService
import net.corda.node.services.transactions.SimpleNotaryService
import net.corda.node.utilities.ServiceIdentityGenerator
import net.corda.testing.freeLocalHostAndPort
import net.corda.testing.getTestX509Name
import net.corda.testing.*
import net.corda.testing.node.NodeBasedTest
import org.assertj.core.api.Assertions.assertThat
import org.bouncycastle.asn1.x500.X500Name

View File

@ -8,7 +8,6 @@ import net.corda.core.getOrThrow
import net.corda.core.node.NodeInfo
import net.corda.core.random63BitValue
import net.corda.core.seconds
import net.corda.core.utilities.*
import net.corda.node.internal.NetworkMapInfo
import net.corda.node.services.config.configureWithDevSSLCertificate
import net.corda.node.services.messaging.sendRequest
@ -16,11 +15,9 @@ import net.corda.node.services.network.NetworkMapService
import net.corda.node.services.network.NetworkMapService.RegistrationRequest
import net.corda.node.services.network.NodeRegistration
import net.corda.node.utilities.AddOrRemove
import net.corda.testing.MOCK_HOST_AND_PORT
import net.corda.testing.MOCK_VERSION_INFO
import net.corda.testing.*
import net.corda.testing.node.NodeBasedTest
import net.corda.testing.node.SimpleNode
import net.corda.testing.testNodeConfiguration
import org.assertj.core.api.Assertions.assertThatExceptionOfType
import org.assertj.core.api.Assertions.assertThatThrownBy
import org.bouncycastle.asn1.x500.X500Name

View File

@ -24,9 +24,7 @@ import net.corda.core.serialization.SerializeAsToken
import net.corda.core.serialization.SingletonSerializeAsToken
import net.corda.core.serialization.deserialize
import net.corda.core.transactions.SignedTransaction
import net.corda.core.utilities.DUMMY_CA
import net.corda.core.utilities.debug
import net.corda.core.utilities.getTestPartyAndCertificate
import net.corda.flows.*
import net.corda.node.services.*
import net.corda.node.services.api.*
@ -71,6 +69,7 @@ import rx.Observable
import java.io.IOException
import java.lang.reflect.InvocationTargetException
import java.lang.reflect.Modifier.*
import java.math.BigInteger
import java.net.JarURLConnection
import java.net.URI
import java.nio.file.Path
@ -735,9 +734,13 @@ abstract class AbstractNode(open val configuration: NodeConfiguration,
if (myIdentity.owningKey !is CompositeKey) { // TODO: Support case where owningKey is a composite key.
keyStore.save(serviceName, privateKeyAlias, keyPair)
}
val partyAndCertificate = getTestPartyAndCertificate(myIdentity)
val dummyCaKey = entropyToKeyPair(BigInteger.valueOf(111))
val dummyCa = CertificateAndKeyPair(
X509Utilities.createSelfSignedCACertificate(X500Name("CN=Dummy CA,OU=Corda,O=R3 Ltd,L=London,C=GB"), dummyCaKey),
dummyCaKey)
val partyAndCertificate = getTestPartyAndCertificate(myIdentity, dummyCa)
// Sanity check the certificate and path
val validatorParameters = PKIXParameters(setOf(TrustAnchor(DUMMY_CA.certificate.cert, null)))
val validatorParameters = PKIXParameters(setOf(TrustAnchor(dummyCa.certificate.cert, null)))
val validator = CertPathValidator.getInstance("PKIX")
validatorParameters.isRevocationEnabled = false
validator.validate(partyAndCertificate.certPath, validatorParameters) as PKIXCertPathValidatorResult
@ -758,6 +761,13 @@ abstract class AbstractNode(open val configuration: NodeConfiguration,
return identityCertPathAndKey
}
private fun getTestPartyAndCertificate(party: Party, trustRoot: CertificateAndKeyPair): PartyAndCertificate {
val certFactory = CertificateFactory.getInstance("X509")
val certHolder = X509Utilities.createCertificate(CertificateType.IDENTITY, trustRoot.certificate, trustRoot.keyPair, party.name, party.owningKey)
val certPath = certFactory.generateCertPath(listOf(certHolder.cert, trustRoot.certificate.cert))
return PartyAndCertificate(party, certHolder, certPath)
}
protected open fun generateKeyPair() = cryptoGenerateKeyPair()
private fun createAttachmentStorage(): NodeAttachmentService {

View File

@ -3,11 +3,11 @@ package net.corda.node
import net.corda.core.copyToDirectory
import net.corda.core.createDirectories
import net.corda.core.div
import net.corda.core.utilities.ALICE
import net.corda.nodeapi.User
import net.corda.smoketesting.NodeConfig
import net.corda.smoketesting.NodeProcess
import org.assertj.core.api.Assertions.assertThat
import org.bouncycastle.asn1.x500.X500Name
import org.junit.Test
import java.nio.file.Paths
import java.util.concurrent.atomic.AtomicInteger
@ -21,7 +21,7 @@ class CordappScanningNodeProcessTest {
private val factory = NodeProcess.Factory()
private val aliceConfig = NodeConfig(
party = ALICE,
legalName = X500Name("CN=Alice Corp,O=Alice Corp,L=Madrid,C=ES"),
p2pPort = port.andIncrement,
rpcPort = port.andIncrement,
webPort = port.andIncrement,

View File

@ -25,6 +25,8 @@ import net.corda.core.transactions.WireTransaction;
import net.corda.node.services.database.HibernateConfiguration;
import net.corda.node.services.schema.NodeSchemaService;
import net.corda.schemas.CashSchemaV1;
import net.corda.testing.TestConstants;
import net.corda.testing.contracts.VaultFiller;
import net.corda.testing.node.MockServices;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.exposed.sql.Database;
@ -43,11 +45,10 @@ import java.util.stream.StreamSupport;
import static net.corda.contracts.asset.CashKt.getDUMMY_CASH_ISSUER;
import static net.corda.contracts.asset.CashKt.getDUMMY_CASH_ISSUER_KEY;
import static net.corda.contracts.testing.VaultFiller.*;
import static net.corda.core.contracts.ContractsDSL.USD;
import static net.corda.core.node.services.vault.QueryCriteriaKt.and;
import static net.corda.core.node.services.vault.QueryCriteriaKt.or;
import static net.corda.core.node.services.vault.QueryCriteriaUtilsKt.getMAX_PAGE_SIZE;
import static net.corda.core.utilities.TestConstants.getDUMMY_NOTARY;
import static net.corda.node.utilities.DatabaseSupportKt.configureDatabase;
import static net.corda.node.utilities.DatabaseSupportKt.transaction;
import static net.corda.testing.CoreTestUtils.getMEGA_CORP;
@ -70,7 +71,7 @@ public class VaultQueryJavaTests {
dataSource = dataSourceAndDatabase.getFirst();
database = dataSourceAndDatabase.getSecond();
Set<MappedSchema> customSchemas = new HashSet<>(Arrays.asList(DummyLinearStateSchemaV1.INSTANCE));
Set<MappedSchema> customSchemas = new HashSet<>(Collections.singletonList(DummyLinearStateSchemaV1.INSTANCE));
HibernateConfiguration hibernateConfig = new HibernateConfiguration(new NodeSchemaService(customSchemas));
transaction(database,
statement -> { services = new MockServices(getMEGA_CORP_KEY()) {
@ -119,7 +120,7 @@ public class VaultQueryJavaTests {
public void unconsumedLinearStates() throws VaultQueryException {
transaction(database, tx -> {
fillWithSomeTestLinearStates(services, 3);
VaultFiller.fillWithSomeTestLinearStates(services, 3);
// DOCSTART VaultJavaQueryExample0
Vault.Page<LinearState> results = vaultQuerySvc.queryBy(LinearState.class);
@ -137,9 +138,9 @@ public class VaultQueryJavaTests {
Amount<Currency> amount = new Amount<>(100, Currency.getInstance("USD"));
fillWithSomeTestCash(services,
VaultFiller.fillWithSomeTestCash(services,
new Amount<>(100, Currency.getInstance("USD")),
getDUMMY_NOTARY(),
TestConstants.getDUMMY_NOTARY(),
3,
3,
new Random(),
@ -148,7 +149,7 @@ public class VaultQueryJavaTests {
getDUMMY_CASH_ISSUER(),
getDUMMY_CASH_ISSUER_KEY() );
consumeCash(services, amount);
VaultFiller.consumeCash(services, amount);
// DOCSTART VaultJavaQueryExample1
VaultQueryCriteria criteria = new VaultQueryCriteria(Vault.StateStatus.CONSUMED);
@ -165,16 +166,16 @@ public class VaultQueryJavaTests {
public void consumedDealStatesPagedSorted() throws VaultQueryException {
transaction(database, tx -> {
Vault<LinearState> states = fillWithSomeTestLinearStates(services, 10, null);
Vault<LinearState> states = VaultFiller.fillWithSomeTestLinearStates(services, 10, null);
StateAndRef<LinearState> linearState = states.getStates().iterator().next();
UniqueIdentifier uid = linearState.component1().getData().getLinearId();
List<String> dealIds = Arrays.asList("123", "456", "789");
Vault<DealState> dealStates = fillWithSomeTestDeals(services, dealIds);
Vault<DealState> dealStates = VaultFiller.fillWithSomeTestDeals(services, dealIds);
// consume states
consumeDeals(services, (List<? extends StateAndRef<? extends DealState>>) dealStates.getStates());
consumeLinearStates(services, Arrays.asList(linearState));
VaultFiller.consumeDeals(services, (List<? extends StateAndRef<? extends DealState>>) dealStates.getStates());
VaultFiller.consumeLinearStates(services, Collections.singletonList(linearState));
// DOCSTART VaultJavaQueryExample2
Vault.StateStatus status = Vault.StateStatus.CONSUMED;
@ -183,7 +184,7 @@ public class VaultQueryJavaTests {
QueryCriteria vaultCriteria = new VaultQueryCriteria(status, contractStateTypes);
List<UniqueIdentifier> linearIds = Arrays.asList(uid);
List<UniqueIdentifier> linearIds = Collections.singletonList(uid);
QueryCriteria linearCriteriaAll = new LinearStateQueryCriteria(null, linearIds);
QueryCriteria dealCriteriaAll = new LinearStateQueryCriteria(null, null, dealIds);
@ -211,10 +212,10 @@ public class VaultQueryJavaTests {
Amount<Currency> dollars10 = new Amount<>(10, Currency.getInstance("USD"));
Amount<Currency> dollars1 = new Amount<>(1, Currency.getInstance("USD"));
fillWithSomeTestCash(services, pounds, getDUMMY_NOTARY(), 1, 1, new Random(0L), new OpaqueBytes("1".getBytes()), null, getDUMMY_CASH_ISSUER(), getDUMMY_CASH_ISSUER_KEY());
fillWithSomeTestCash(services, dollars100, getDUMMY_NOTARY(), 1, 1, new Random(0L), new OpaqueBytes("1".getBytes()), null, getDUMMY_CASH_ISSUER(), getDUMMY_CASH_ISSUER_KEY());
fillWithSomeTestCash(services, dollars10, getDUMMY_NOTARY(), 1, 1, new Random(0L), new OpaqueBytes("1".getBytes()), null, getDUMMY_CASH_ISSUER(), getDUMMY_CASH_ISSUER_KEY());
fillWithSomeTestCash(services, dollars1, getDUMMY_NOTARY(), 1, 1, new Random(0L), new OpaqueBytes("1".getBytes()), null, getDUMMY_CASH_ISSUER(), getDUMMY_CASH_ISSUER_KEY());
VaultFiller.fillWithSomeTestCash(services, pounds, TestConstants.getDUMMY_NOTARY(), 1, 1, new Random(0L), new OpaqueBytes("1".getBytes()), null, getDUMMY_CASH_ISSUER(), getDUMMY_CASH_ISSUER_KEY());
VaultFiller.fillWithSomeTestCash(services, dollars100, TestConstants.getDUMMY_NOTARY(), 1, 1, new Random(0L), new OpaqueBytes("1".getBytes()), null, getDUMMY_CASH_ISSUER(), getDUMMY_CASH_ISSUER_KEY());
VaultFiller.fillWithSomeTestCash(services, dollars10, TestConstants.getDUMMY_NOTARY(), 1, 1, new Random(0L), new OpaqueBytes("1".getBytes()), null, getDUMMY_CASH_ISSUER(), getDUMMY_CASH_ISSUER_KEY());
VaultFiller.fillWithSomeTestCash(services, dollars1, TestConstants.getDUMMY_NOTARY(), 1, 1, new Random(0L), new OpaqueBytes("1".getBytes()), null, getDUMMY_CASH_ISSUER(), getDUMMY_CASH_ISSUER_KEY());
try {
// DOCSTART VaultJavaQueryExample3
@ -249,9 +250,9 @@ public class VaultQueryJavaTests {
@Test
public void trackCashStates() {
transaction(database, tx -> {
fillWithSomeTestCash(services,
VaultFiller.fillWithSomeTestCash(services,
new Amount<>(100, Currency.getInstance("USD")),
getDUMMY_NOTARY(),
TestConstants.getDUMMY_NOTARY(),
3,
3,
new Random(),
@ -281,19 +282,19 @@ public class VaultQueryJavaTests {
public void trackDealStatesPagedSorted() {
transaction(database, tx -> {
Vault<LinearState> states = fillWithSomeTestLinearStates(services, 10, null);
Vault<LinearState> states = VaultFiller.fillWithSomeTestLinearStates(services, 10, null);
UniqueIdentifier uid = states.getStates().iterator().next().component1().getData().getLinearId();
List<String> dealIds = Arrays.asList("123", "456", "789");
fillWithSomeTestDeals(services, dealIds);
VaultFiller.fillWithSomeTestDeals(services, dealIds);
// DOCSTART VaultJavaQueryExample5
@SuppressWarnings("unchecked")
Set<Class<ContractState>> contractStateTypes = new HashSet(Arrays.asList(DealState.class, LinearState.class));
QueryCriteria vaultCriteria = new VaultQueryCriteria(Vault.StateStatus.UNCONSUMED, contractStateTypes);
List<UniqueIdentifier> linearIds = Arrays.asList(uid);
List<AbstractParty> dealParty = Arrays.asList(getMEGA_CORP());
List<UniqueIdentifier> linearIds = Collections.singletonList(uid);
List<AbstractParty> dealParty = Collections.singletonList(getMEGA_CORP());
QueryCriteria dealCriteria = new LinearStateQueryCriteria(dealParty, null, dealIds);
QueryCriteria linearCriteria = new LinearStateQueryCriteria(dealParty, linearIds, null);
QueryCriteria dealOrLinearIdCriteria = or(dealCriteria, linearCriteria);
@ -304,8 +305,8 @@ public class VaultQueryJavaTests {
Sort sorting = new Sort(ImmutableSet.of(sortByUid));
DataFeed<Vault.Page<ContractState>, Vault.Update> results = vaultQuerySvc.trackBy(ContractState.class, compositeCriteria, pageSpec, sorting);
Vault.Page<ContractState> snapshot = results.getCurrent();
Observable<Vault.Update> updates = results.getFuture();
Vault.Page<ContractState> snapshot = results.getSnapshot();
Observable<Vault.Update> updates = results.getUpdates();
// DOCEND VaultJavaQueryExample5
assertThat(snapshot.getStates()).hasSize(13);
@ -321,10 +322,10 @@ public class VaultQueryJavaTests {
@Test
public void consumedStatesDeprecated() {
transaction(database, tx -> {
Amount<Currency> amount = new Amount<>(100, Currency.getInstance("USD"));
fillWithSomeTestCash(services,
new Amount<>(100, Currency.getInstance("USD")),
getDUMMY_NOTARY(),
Amount<Currency> amount = new Amount<>(100, USD);
VaultFiller.fillWithSomeTestCash(services,
new Amount<>(100, USD),
TestConstants.getDUMMY_NOTARY(),
3,
3,
new Random(),
@ -333,7 +334,7 @@ public class VaultQueryJavaTests {
getDUMMY_CASH_ISSUER(),
getDUMMY_CASH_ISSUER_KEY() );
consumeCash(services, amount);
VaultFiller.consumeCash(services, amount);
// DOCSTART VaultDeprecatedJavaQueryExample1
@SuppressWarnings("unchecked")
@ -354,10 +355,10 @@ public class VaultQueryJavaTests {
public void consumedStatesForLinearIdDeprecated() {
transaction(database, tx -> {
Vault<LinearState> linearStates = fillWithSomeTestLinearStates(services, 4,null);
UniqueIdentifier trackUid = linearStates.getStates().iterator().next().component1().getData().getLinearId();
Vault<LinearState> linearStates = VaultFiller.fillWithSomeTestLinearStates(services, 4,null);
linearStates.getStates().iterator().next().component1().getData().getLinearId();
consumeLinearStates(services, (List<? extends StateAndRef<? extends LinearState>>) linearStates.getStates());
VaultFiller.consumeLinearStates(services, (List<? extends StateAndRef<? extends LinearState>>) linearStates.getStates());
// DOCSTART VaultDeprecatedJavaQueryExample0
@SuppressWarnings("unchecked")

View File

@ -11,7 +11,7 @@ import net.corda.core.flows.StateMachineRunId
import net.corda.core.identity.Party
import net.corda.core.node.ServiceHub
import net.corda.core.transactions.SignedTransaction
import net.corda.core.utilities.DUMMY_CA
import net.corda.testing.DUMMY_CA
import net.corda.core.utilities.UntrustworthyData
import net.corda.jackson.JacksonSupport
import net.corda.node.services.identity.InMemoryIdentityService

View File

@ -3,7 +3,7 @@ package net.corda.node.messaging
import co.paralleluniverse.fibers.Suspendable
import net.corda.contracts.CommercialPaper
import net.corda.contracts.asset.*
import net.corda.contracts.testing.fillWithSomeTestCash
import net.corda.testing.contracts.fillWithSomeTestCash
import net.corda.core.*
import net.corda.core.contracts.*
import net.corda.core.crypto.DigitalSignature

View File

@ -8,13 +8,13 @@ import net.corda.core.identity.Party
import net.corda.core.node.services.ServiceInfo
import net.corda.core.seconds
import net.corda.core.transactions.WireTransaction
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.core.utilities.getTestPartyAndCertificate
import net.corda.testing.DUMMY_NOTARY
import net.corda.flows.NotaryChangeFlow
import net.corda.flows.StateReplacementException
import net.corda.node.internal.AbstractNode
import net.corda.node.services.network.NetworkMapService
import net.corda.node.services.transactions.SimpleNotaryService
import net.corda.testing.getTestPartyAndCertificate
import net.corda.testing.node.MockNetwork
import org.assertj.core.api.Assertions.assertThatExceptionOfType
import org.bouncycastle.asn1.x500.X500Name

View File

@ -2,7 +2,7 @@ package net.corda.node.services.config
import com.google.common.net.HostAndPort
import net.corda.core.crypto.commonName
import net.corda.core.utilities.ALICE
import net.corda.testing.ALICE
import net.corda.nodeapi.User
import net.corda.testing.node.makeTestDataSourceProperties
import org.assertj.core.api.Assertions.assertThatThrownBy

View File

@ -2,10 +2,10 @@ package net.corda.node.services.database
import net.corda.contracts.asset.Cash
import net.corda.contracts.asset.DummyFungibleContract
import net.corda.contracts.testing.consumeCash
import net.corda.contracts.testing.fillWithSomeTestCash
import net.corda.contracts.testing.fillWithSomeTestDeals
import net.corda.contracts.testing.fillWithSomeTestLinearStates
import net.corda.testing.contracts.consumeCash
import net.corda.testing.contracts.fillWithSomeTestCash
import net.corda.testing.contracts.fillWithSomeTestDeals
import net.corda.testing.contracts.fillWithSomeTestLinearStates
import net.corda.core.contracts.*
import net.corda.core.crypto.toBase58String
import net.corda.core.node.services.Vault
@ -16,10 +16,10 @@ import net.corda.core.schemas.testing.DummyLinearStateSchemaV2
import net.corda.core.serialization.deserialize
import net.corda.core.serialization.storageKryo
import net.corda.core.transactions.SignedTransaction
import net.corda.core.utilities.ALICE
import net.corda.core.utilities.BOB
import net.corda.core.utilities.BOB_KEY
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.ALICE
import net.corda.testing.BOB
import net.corda.testing.BOB_KEY
import net.corda.testing.DUMMY_NOTARY
import net.corda.node.services.schema.HibernateObserver
import net.corda.node.services.schema.NodeSchemaService
import net.corda.node.services.vault.NodeVaultService

View File

@ -16,8 +16,8 @@ import net.corda.core.serialization.serialize
import net.corda.core.serialization.storageKryo
import net.corda.core.transactions.SignedTransaction
import net.corda.core.transactions.WireTransaction
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.core.utilities.DUMMY_PUBKEY_1
import net.corda.testing.DUMMY_NOTARY
import net.corda.testing.DUMMY_PUBKEY_1
import net.corda.node.services.persistence.DBTransactionStorage
import net.corda.node.services.vault.schemas.requery.Models
import net.corda.node.services.vault.schemas.requery.VaultCashBalancesEntity

View File

@ -9,9 +9,9 @@ import net.corda.core.identity.AbstractParty
import net.corda.core.node.ServiceHub
import net.corda.core.node.services.VaultService
import net.corda.core.serialization.SingletonSerializeAsToken
import net.corda.core.utilities.ALICE_KEY
import net.corda.core.utilities.DUMMY_CA
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.ALICE_KEY
import net.corda.testing.DUMMY_CA
import net.corda.testing.DUMMY_NOTARY
import net.corda.node.services.MockServiceHubInternal
import net.corda.node.services.identity.InMemoryIdentityService
import net.corda.node.services.persistence.DBCheckpointStorage

View File

@ -12,7 +12,7 @@ import net.corda.core.identity.AbstractParty
import net.corda.core.identity.Party
import net.corda.core.node.services.ServiceInfo
import net.corda.core.node.services.linearHeadsOfType
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.DUMMY_NOTARY
import net.corda.flows.FinalityFlow
import net.corda.node.services.network.NetworkMapService
import net.corda.node.services.statemachine.StateMachineManager

View File

@ -8,7 +8,7 @@ import com.google.common.util.concurrent.SettableFuture
import net.corda.core.crypto.generateKeyPair
import net.corda.core.messaging.RPCOps
import net.corda.core.node.services.DEFAULT_SESSION_ID
import net.corda.core.utilities.ALICE
import net.corda.testing.ALICE
import net.corda.core.utilities.LogHelper
import net.corda.node.services.RPCUserService
import net.corda.node.services.RPCUserServiceImpl

View File

@ -7,10 +7,10 @@ import net.corda.core.node.NodeInfo
import net.corda.core.node.services.DEFAULT_SESSION_ID
import net.corda.core.node.services.ServiceInfo
import net.corda.core.serialization.deserialize
import net.corda.core.utilities.ALICE
import net.corda.core.utilities.BOB
import net.corda.core.utilities.CHARLIE
import net.corda.core.utilities.DUMMY_MAP
import net.corda.testing.ALICE
import net.corda.testing.BOB
import net.corda.testing.CHARLIE
import net.corda.testing.DUMMY_MAP
import net.corda.node.services.config.NodeConfiguration
import net.corda.node.services.messaging.send
import net.corda.node.services.messaging.sendRequest

View File

@ -5,11 +5,9 @@ import net.corda.core.identity.AnonymousParty
import net.corda.core.identity.Party
import net.corda.core.identity.PartyAndCertificate
import net.corda.core.node.services.IdentityService
import net.corda.core.utilities.*
import net.corda.flows.AnonymisedIdentity
import net.corda.node.services.identity.InMemoryIdentityService
import net.corda.testing.ALICE_PUBKEY
import net.corda.testing.BOB_PUBKEY
import net.corda.testing.*
import org.bouncycastle.asn1.x500.X500Name
import org.junit.Test
import java.security.cert.CertificateFactory
@ -28,13 +26,13 @@ class InMemoryIdentityServiceTests {
assertNull(service.getAllIdentities().firstOrNull())
service.registerIdentity(ALICE_IDENTITY)
var expected = setOf<Party>(ALICE)
var expected = setOf(ALICE)
var actual = service.getAllIdentities().map { it.party }.toHashSet()
assertEquals(expected, actual)
// Add a second party and check we get both back
service.registerIdentity(BOB_IDENTITY)
expected = setOf<Party>(ALICE, BOB)
expected = setOf(ALICE, BOB)
actual = service.getAllIdentities().map { it.party }.toHashSet()
assertEquals(expected, actual)
}

View File

@ -3,8 +3,8 @@ package net.corda.node.services.network
import net.corda.core.getOrThrow
import net.corda.core.node.services.NetworkMapCache
import net.corda.core.node.services.ServiceInfo
import net.corda.core.utilities.ALICE
import net.corda.core.utilities.BOB
import net.corda.testing.ALICE
import net.corda.testing.BOB
import net.corda.node.utilities.transaction
import net.corda.testing.node.MockNetwork
import org.junit.After

View File

@ -8,7 +8,7 @@ import net.corda.core.crypto.testing.NullPublicKey
import net.corda.core.toFuture
import net.corda.core.transactions.SignedTransaction
import net.corda.core.transactions.WireTransaction
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.DUMMY_NOTARY
import net.corda.core.utilities.LogHelper
import net.corda.node.services.transactions.PersistentUniquenessProvider
import net.corda.node.utilities.configureDatabase

View File

@ -12,7 +12,7 @@ import net.corda.core.flows.InitiatingFlow
import net.corda.core.identity.Party
import net.corda.core.node.services.unconsumedStates
import net.corda.core.transactions.SignedTransaction
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.DUMMY_NOTARY
import net.corda.flows.BroadcastTransactionFlow.NotifyTxRequest
import net.corda.node.services.NotifyTransactionHandler
import net.corda.node.utilities.transaction

View File

@ -10,7 +10,7 @@ import net.corda.core.getOrThrow
import net.corda.core.node.services.ServiceInfo
import net.corda.core.seconds
import net.corda.core.transactions.SignedTransaction
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.DUMMY_NOTARY
import net.corda.flows.NotaryError
import net.corda.flows.NotaryException
import net.corda.flows.NotaryFlow

View File

@ -10,7 +10,7 @@ import net.corda.core.crypto.DigitalSignature
import net.corda.core.getOrThrow
import net.corda.core.node.services.ServiceInfo
import net.corda.core.transactions.SignedTransaction
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.DUMMY_NOTARY
import net.corda.flows.NotaryError
import net.corda.flows.NotaryException
import net.corda.flows.NotaryFlow

View File

@ -2,7 +2,7 @@ package net.corda.node.services.vault
import net.corda.contracts.asset.Cash
import net.corda.contracts.asset.DUMMY_CASH_ISSUER
import net.corda.contracts.testing.fillWithSomeTestCash
import net.corda.testing.contracts.fillWithSomeTestCash
import net.corda.core.contracts.*
import net.corda.core.identity.AnonymousParty
import net.corda.core.node.services.StatesNotAvailableException
@ -10,7 +10,7 @@ import net.corda.core.node.services.VaultService
import net.corda.core.node.services.unconsumedStates
import net.corda.core.serialization.OpaqueBytes
import net.corda.core.transactions.SignedTransaction
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.DUMMY_NOTARY
import net.corda.core.utilities.LogHelper
import net.corda.node.utilities.configureDatabase
import net.corda.node.utilities.transaction

View File

@ -6,7 +6,6 @@ import net.corda.contracts.DealState
import net.corda.contracts.DummyDealContract
import net.corda.contracts.asset.Cash
import net.corda.contracts.asset.DUMMY_CASH_ISSUER
import net.corda.contracts.testing.*
import net.corda.core.contracts.*
import net.corda.core.contracts.testing.DummyLinearContract
import net.corda.core.crypto.entropyToKeyPair
@ -19,9 +18,9 @@ import net.corda.core.schemas.testing.DummyLinearStateSchemaV1
import net.corda.core.seconds
import net.corda.core.serialization.OpaqueBytes
import net.corda.core.transactions.SignedTransaction
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.core.utilities.DUMMY_NOTARY_KEY
import net.corda.core.utilities.TEST_TX_TIME
import net.corda.testing.DUMMY_NOTARY
import net.corda.testing.DUMMY_NOTARY_KEY
import net.corda.testing.TEST_TX_TIME
import net.corda.node.services.database.HibernateConfiguration
import net.corda.node.services.schema.NodeSchemaService
import net.corda.node.services.vault.schemas.jpa.VaultSchemaV1
@ -32,6 +31,7 @@ import net.corda.schemas.CashSchemaV1.PersistentCashState
import net.corda.schemas.CommercialPaperSchemaV1
import net.corda.schemas.SampleCashSchemaV3
import net.corda.testing.*
import net.corda.testing.contracts.*
import net.corda.testing.node.MockServices
import net.corda.testing.node.makeTestDataSourceProperties
import org.assertj.core.api.Assertions

View File

@ -3,9 +3,9 @@ package net.corda.node.services.vault
import net.corda.contracts.DummyDealContract
import net.corda.contracts.asset.Cash
import net.corda.contracts.asset.DUMMY_CASH_ISSUER
import net.corda.contracts.testing.fillWithSomeTestCash
import net.corda.contracts.testing.fillWithSomeTestDeals
import net.corda.contracts.testing.fillWithSomeTestLinearStates
import net.corda.testing.contracts.fillWithSomeTestCash
import net.corda.testing.contracts.fillWithSomeTestDeals
import net.corda.testing.contracts.fillWithSomeTestLinearStates
import net.corda.core.contracts.*
import net.corda.core.contracts.testing.DummyLinearContract
import net.corda.core.identity.AnonymousParty
@ -13,9 +13,9 @@ import net.corda.core.node.services.VaultService
import net.corda.core.node.services.consumedStates
import net.corda.core.node.services.unconsumedStates
import net.corda.core.transactions.SignedTransaction
import net.corda.core.utilities.BOB
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.core.utilities.DUMMY_NOTARY_KEY
import net.corda.testing.BOB
import net.corda.testing.DUMMY_NOTARY
import net.corda.testing.DUMMY_NOTARY_KEY
import net.corda.core.utilities.LogHelper
import net.corda.node.utilities.configureDatabase
import net.corda.node.utilities.transaction

View File

@ -6,7 +6,7 @@ import com.nhaarman.mockito_kotlin.mock
import net.corda.core.crypto.*
import net.corda.core.exists
import net.corda.core.toTypedArray
import net.corda.core.utilities.ALICE
import net.corda.testing.ALICE
import net.corda.testing.getTestX509Name
import net.corda.testing.testNodeConfiguration
import org.bouncycastle.cert.X509CertificateHolder

View File

@ -3,9 +3,9 @@ package net.corda.attachmentdemo
import com.google.common.util.concurrent.Futures
import net.corda.core.getOrThrow
import net.corda.core.node.services.ServiceInfo
import net.corda.core.utilities.DUMMY_BANK_A
import net.corda.core.utilities.DUMMY_BANK_B
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.DUMMY_BANK_A
import net.corda.testing.DUMMY_BANK_B
import net.corda.testing.DUMMY_NOTARY
import net.corda.testing.driver.driver
import net.corda.node.services.startFlowPermission
import net.corda.node.services.transactions.SimpleNotaryService

View File

@ -20,6 +20,8 @@ import net.corda.core.sizedInputStreamAndHash
import net.corda.core.transactions.SignedTransaction
import net.corda.core.utilities.*
import net.corda.flows.FinalityFlow
import net.corda.testing.DUMMY_BANK_B
import net.corda.testing.DUMMY_NOTARY
import net.corda.testing.driver.poll
import java.io.InputStream
import java.net.HttpURLConnection

View File

@ -2,9 +2,9 @@ package net.corda.attachmentdemo
import net.corda.core.div
import net.corda.core.node.services.ServiceInfo
import net.corda.core.utilities.DUMMY_BANK_A
import net.corda.core.utilities.DUMMY_BANK_B
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.DUMMY_BANK_A
import net.corda.testing.DUMMY_BANK_B
import net.corda.testing.DUMMY_NOTARY
import net.corda.node.services.transactions.SimpleNotaryService
import net.corda.nodeapi.User
import net.corda.testing.driver.driver

View File

@ -4,11 +4,10 @@ import com.google.common.net.HostAndPort
import joptsimple.OptionParser
import net.corda.bank.api.BankOfCordaClientApi
import net.corda.bank.api.BankOfCordaWebApi.IssueRequestParams
import net.corda.core.crypto.X509Utilities
import net.corda.core.node.services.ServiceInfo
import net.corda.core.node.services.ServiceType
import net.corda.core.transactions.SignedTransaction
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.DUMMY_NOTARY
import net.corda.flows.CashExitFlow
import net.corda.flows.CashPaymentFlow
import net.corda.flows.IssuerFlow

View File

@ -6,9 +6,9 @@ import net.corda.client.rpc.CordaRPCClient
import net.corda.core.getOrThrow
import net.corda.core.node.services.ServiceInfo
import net.corda.core.toFuture
import net.corda.core.utilities.DUMMY_BANK_A
import net.corda.core.utilities.DUMMY_BANK_B
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.DUMMY_BANK_A
import net.corda.testing.DUMMY_BANK_B
import net.corda.testing.DUMMY_NOTARY
import net.corda.irs.api.NodeInterestRates
import net.corda.irs.contract.InterestRateSwap
import net.corda.irs.utilities.uploadFile

View File

@ -3,9 +3,9 @@ package net.corda.irs
import com.google.common.util.concurrent.Futures
import net.corda.core.getOrThrow
import net.corda.core.node.services.ServiceInfo
import net.corda.core.utilities.DUMMY_BANK_A
import net.corda.core.utilities.DUMMY_BANK_B
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.DUMMY_BANK_A
import net.corda.testing.DUMMY_BANK_B
import net.corda.testing.DUMMY_NOTARY
import net.corda.irs.api.NodeInterestRates
import net.corda.node.services.transactions.SimpleNotaryService
import net.corda.testing.driver.driver

View File

@ -14,8 +14,8 @@ import net.corda.core.getOrThrow
import net.corda.core.identity.Party
import net.corda.core.node.services.ServiceInfo
import net.corda.core.transactions.TransactionBuilder
import net.corda.core.utilities.ALICE
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.ALICE
import net.corda.testing.DUMMY_NOTARY
import net.corda.core.utilities.LogHelper
import net.corda.core.utilities.ProgressTracker
import net.corda.irs.flows.RatesFixFlow

View File

@ -4,9 +4,9 @@ import net.corda.contracts.*
import net.corda.core.contracts.*
import net.corda.core.seconds
import net.corda.core.transactions.SignedTransaction
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.core.utilities.DUMMY_NOTARY_KEY
import net.corda.core.utilities.TEST_TX_TIME
import net.corda.testing.DUMMY_NOTARY
import net.corda.testing.DUMMY_NOTARY_KEY
import net.corda.testing.TEST_TX_TIME
import net.corda.testing.*
import net.corda.testing.node.MockServices
import org.junit.Test

View File

@ -17,7 +17,7 @@ import net.corda.core.flows.InitiatingFlow
import net.corda.core.identity.Party
import net.corda.core.node.services.linearHeadsOfType
import net.corda.core.transactions.SignedTransaction
import net.corda.core.utilities.DUMMY_CA
import net.corda.testing.DUMMY_CA
import net.corda.flows.TwoPartyDealFlow.Acceptor
import net.corda.flows.TwoPartyDealFlow.AutoOffer
import net.corda.flows.TwoPartyDealFlow.Instigator

View File

@ -10,9 +10,9 @@ import net.corda.core.node.CityDatabase
import net.corda.core.node.WorldMapLocation
import net.corda.core.node.services.ServiceInfo
import net.corda.core.node.services.containsType
import net.corda.core.utilities.DUMMY_MAP
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.core.utilities.DUMMY_REGULATOR
import net.corda.testing.DUMMY_MAP
import net.corda.testing.DUMMY_NOTARY
import net.corda.testing.DUMMY_REGULATOR
import net.corda.core.utilities.ProgressTracker
import net.corda.irs.api.NodeInterestRates
import net.corda.node.services.config.NodeConfiguration

View File

@ -3,8 +3,8 @@ package net.corda.notarydemo
import com.google.common.net.HostAndPort
import net.corda.core.div
import net.corda.core.node.services.ServiceInfo
import net.corda.core.utilities.ALICE
import net.corda.core.utilities.BOB
import net.corda.testing.ALICE
import net.corda.testing.BOB
import net.corda.demorun.util.*
import net.corda.demorun.runNodes
import net.corda.node.services.transactions.BFTNonValidatingNotaryService

View File

@ -11,7 +11,7 @@ import net.corda.core.map
import net.corda.core.messaging.CordaRPCOps
import net.corda.core.messaging.startFlow
import net.corda.core.transactions.SignedTransaction
import net.corda.core.utilities.BOB
import net.corda.testing.BOB
import net.corda.notarydemo.flows.DummyIssueAndMove
import net.corda.notarydemo.flows.RPCStartableNotaryFlowClient
import kotlin.streams.asSequence

View File

@ -4,9 +4,9 @@ import com.google.common.net.HostAndPort
import net.corda.core.crypto.appendToCommonName
import net.corda.core.div
import net.corda.core.node.services.ServiceInfo
import net.corda.core.utilities.ALICE
import net.corda.core.utilities.BOB
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.ALICE
import net.corda.testing.BOB
import net.corda.testing.DUMMY_NOTARY
import net.corda.demorun.util.*
import net.corda.node.services.transactions.RaftValidatingNotaryService
import net.corda.node.utilities.ServiceIdentityGenerator

View File

@ -2,9 +2,9 @@ package net.corda.notarydemo
import net.corda.core.div
import net.corda.core.node.services.ServiceInfo
import net.corda.core.utilities.ALICE
import net.corda.core.utilities.BOB
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.ALICE
import net.corda.testing.BOB
import net.corda.testing.DUMMY_NOTARY
import net.corda.demorun.runNodes
import net.corda.node.services.startFlowPermission
import net.corda.node.services.transactions.ValidatingNotaryService

View File

@ -4,9 +4,9 @@ import com.google.common.util.concurrent.Futures
import com.opengamma.strata.product.common.BuySell
import net.corda.core.getOrThrow
import net.corda.core.node.services.ServiceInfo
import net.corda.core.utilities.DUMMY_BANK_A
import net.corda.core.utilities.DUMMY_BANK_B
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.DUMMY_BANK_A
import net.corda.testing.DUMMY_BANK_B
import net.corda.testing.DUMMY_NOTARY
import net.corda.testing.driver.driver
import net.corda.node.services.transactions.SimpleNotaryService
import net.corda.testing.IntegrationTestCategory

View File

@ -12,8 +12,7 @@ import net.corda.core.identity.AbstractParty
import net.corda.core.identity.Party
import net.corda.core.messaging.CordaRPCOps
import net.corda.core.messaging.startFlow
import net.corda.core.utilities.DUMMY_MAP
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.core.node.services.ServiceType
import net.corda.vega.analytics.InitialMarginTriple
import net.corda.vega.contracts.IRSState
import net.corda.vega.contracts.PortfolioState
@ -33,7 +32,6 @@ import javax.ws.rs.core.Response
//TODO: Change import namespaces vega -> ....
@Path("simmvaluationdemo")
class PortfolioApi(val rpc: CordaRPCOps) {
private val ownParty: Party get() = rpc.nodeIdentity().legalIdentity
@ -228,7 +226,7 @@ class PortfolioApi(val rpc: CordaRPCOps) {
return withParty(partyName) { party ->
withPortfolio(party) { state ->
if (state.valuation != null) {
val isValuer = state.valuer as AbstractParty == ownParty
val isValuer = state.valuer == ownParty
val rawMtm = state.valuation.presentValues.map {
it.value.amounts.first().amount
}.reduce { a, b -> a + b }
@ -254,12 +252,11 @@ class PortfolioApi(val rpc: CordaRPCOps) {
@Path("whoami")
@Produces(MediaType.APPLICATION_JSON)
fun getWhoAmI(): AvailableParties {
val (parties, partyUpdates) = rpc.networkMapUpdates()
val (parties, partyUpdates) = rpc.networkMapFeed()
partyUpdates.notUsed()
val counterParties = parties.filter {
it.legalIdentity.name != DUMMY_MAP.name
&& it.legalIdentity.name != DUMMY_NOTARY.name
&& it.legalIdentity.name != ownParty.name
val counterParties = parties.filterNot {
it.advertisedServices.any { it.info.type in setOf(ServiceType.networkMap, ServiceType.notary) }
|| it.legalIdentity == ownParty
}
return AvailableParties(
@ -280,8 +277,6 @@ class PortfolioApi(val rpc: CordaRPCOps) {
return withParty(partyName) { otherParty ->
val existingSwap = getPortfolioWith(otherParty)
val flowHandle = if (existingSwap == null) {
// TODO: Remove this suppress when we upgrade to kotlin 1.1 or when JetBrain fixes the bug.
@Suppress("UNSUPPORTED_FEATURE")
rpc.startFlow(SimmFlow::Requester, otherParty, params.valuationDate)
} else {
rpc.startFlow(SimmRevaluation::Initiator, getPortfolioStateAndRefWith(otherParty).ref, params.valuationDate)
@ -295,4 +290,3 @@ class PortfolioApi(val rpc: CordaRPCOps) {
}
}
}

View File

@ -3,10 +3,10 @@ package net.corda.vega
import com.google.common.util.concurrent.Futures
import net.corda.core.getOrThrow
import net.corda.core.node.services.ServiceInfo
import net.corda.core.utilities.DUMMY_BANK_A
import net.corda.core.utilities.DUMMY_BANK_B
import net.corda.core.utilities.DUMMY_BANK_C
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.DUMMY_BANK_A
import net.corda.testing.DUMMY_BANK_B
import net.corda.testing.DUMMY_BANK_C
import net.corda.testing.DUMMY_NOTARY
import net.corda.node.services.transactions.SimpleNotaryService
import net.corda.testing.driver.driver

View File

@ -6,9 +6,9 @@ import net.corda.core.contracts.DOLLARS
import net.corda.core.getOrThrow
import net.corda.core.millis
import net.corda.core.node.services.ServiceInfo
import net.corda.core.utilities.DUMMY_BANK_A
import net.corda.core.utilities.DUMMY_BANK_B
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.DUMMY_BANK_A
import net.corda.testing.DUMMY_BANK_B
import net.corda.testing.DUMMY_NOTARY
import net.corda.flows.IssuerFlow
import net.corda.testing.driver.poll
import net.corda.node.services.startFlowPermission

View File

@ -4,10 +4,8 @@ import com.google.common.net.HostAndPort
import joptsimple.OptionParser
import net.corda.client.rpc.CordaRPCClient
import net.corda.core.contracts.DOLLARS
import net.corda.core.crypto.X509Utilities
import net.corda.core.utilities.DUMMY_BANK_A
import net.corda.testing.DUMMY_BANK_A
import net.corda.core.utilities.loggerFor
import org.bouncycastle.asn1.x500.X500Name
import org.slf4j.Logger
import kotlin.system.exitProcess

View File

@ -4,7 +4,7 @@ import com.google.common.util.concurrent.Futures
import net.corda.client.rpc.notUsed
import net.corda.contracts.CommercialPaper
import net.corda.contracts.asset.Cash
import net.corda.contracts.testing.calculateRandomlySizedAmounts
import net.corda.testing.contracts.calculateRandomlySizedAmounts
import net.corda.core.contracts.Amount
import net.corda.core.contracts.DOLLARS
import net.corda.core.contracts.USD

View File

@ -2,9 +2,9 @@ package net.corda.traderdemo
import net.corda.core.div
import net.corda.core.node.services.ServiceInfo
import net.corda.core.utilities.DUMMY_BANK_A
import net.corda.core.utilities.DUMMY_BANK_B
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.DUMMY_BANK_A
import net.corda.testing.DUMMY_BANK_B
import net.corda.testing.DUMMY_NOTARY
import net.corda.flows.IssuerFlow
import net.corda.node.services.startFlowPermission
import net.corda.node.services.transactions.SimpleNotaryService

View File

@ -6,35 +6,35 @@ import com.typesafe.config.ConfigRenderOptions
import com.typesafe.config.ConfigValue
import com.typesafe.config.ConfigValueFactory
import net.corda.core.crypto.commonName
import net.corda.core.identity.Party
import net.corda.nodeapi.User
import org.bouncycastle.asn1.x500.X500Name
class NodeConfig(
val party: Party,
val p2pPort: Int,
val rpcPort: Int,
val webPort: Int,
val extraServices: List<String>,
val users: List<User>,
var networkMap: NodeConfig? = null
val legalName: X500Name,
val p2pPort: Int,
val rpcPort: Int,
val webPort: Int,
val extraServices: List<String>,
val users: List<User>,
var networkMap: NodeConfig? = null
) {
companion object {
val renderOptions: ConfigRenderOptions = ConfigRenderOptions.defaults().setOriginComments(false)
}
val commonName: String get() = party.name.commonName
val commonName: String get() = legalName.commonName
/*
* The configuration object depends upon the networkMap,
* which is mutable.
*/
fun toFileConfig(): Config = empty()
.withValue("myLegalName", valueFor(party.name.toString()))
.withValue("myLegalName", valueFor(legalName.toString()))
.withValue("p2pAddress", addressValueFor(p2pPort))
.withValue("extraAdvertisedServiceIds", valueFor(extraServices))
.withFallback(optional("networkMapService", networkMap, { c, n ->
c.withValue("address", addressValueFor(n.p2pPort))
.withValue("legalName", valueFor(n.party.name.toString()))
.withValue("legalName", valueFor(n.legalName.toString()))
}))
.withValue("webAddress", addressValueFor(webPort))
.withValue("rpcAddress", addressValueFor(rpcPort))

View File

@ -6,13 +6,12 @@ import net.corda.core.getOrThrow
import net.corda.core.list
import net.corda.core.node.services.ServiceInfo
import net.corda.core.readLines
import net.corda.core.utilities.DUMMY_BANK_A
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.core.utilities.DUMMY_REGULATOR
import net.corda.testing.DUMMY_BANK_A
import net.corda.testing.DUMMY_NOTARY
import net.corda.testing.DUMMY_REGULATOR
import net.corda.node.internal.NodeStartup
import net.corda.node.services.api.RegulatorService
import net.corda.node.services.transactions.SimpleNotaryService
import net.corda.nodeapi.ArtemisMessagingComponent
import net.corda.testing.ProjectStructure.projectRootDir
import org.assertj.core.api.Assertions.assertThat
import org.junit.Test

View File

@ -7,10 +7,6 @@ import com.google.common.net.HostAndPort
import com.nhaarman.mockito_kotlin.spy
import com.nhaarman.mockito_kotlin.whenever
import net.corda.core.contracts.StateRef
import net.corda.core.crypto.SecureHash
import net.corda.core.crypto.X509Utilities
import net.corda.core.crypto.commonName
import net.corda.core.crypto.generateKeyPair
import net.corda.core.crypto.*
import net.corda.core.identity.Party
import net.corda.core.identity.PartyAndCertificate
@ -19,8 +15,9 @@ import net.corda.core.node.VersionInfo
import net.corda.core.node.services.IdentityService
import net.corda.core.serialization.OpaqueBytes
import net.corda.core.transactions.TransactionBuilder
import net.corda.core.utilities.*
import net.corda.node.services.config.*
import net.corda.node.services.config.NodeConfiguration
import net.corda.node.services.config.VerifierType
import net.corda.node.services.config.configureDevKeyAndTrustStores
import net.corda.node.services.identity.InMemoryIdentityService
import net.corda.nodeapi.config.SSLConfiguration
import net.corda.testing.node.MockServices
@ -33,6 +30,7 @@ import java.nio.file.Files
import java.nio.file.Path
import java.security.KeyPair
import java.security.PublicKey
import java.security.cert.CertificateFactory
import java.util.concurrent.atomic.AtomicInteger
/**
@ -195,3 +193,17 @@ fun getTestX509Name(commonName: String): X500Name {
nameBuilder.addRDN(BCStyle.C, "US")
return nameBuilder.build()
}
fun getTestPartyAndCertificate(party: Party, trustRoot: CertificateAndKeyPair = DUMMY_CA): PartyAndCertificate {
val certFactory = CertificateFactory.getInstance("X509")
val certHolder = X509Utilities.createCertificate(CertificateType.IDENTITY, trustRoot.certificate, trustRoot.keyPair, party.name, party.owningKey)
val certPath = certFactory.generateCertPath(listOf(certHolder.cert, trustRoot.certificate.cert))
return PartyAndCertificate(party, certHolder, certPath)
}
/**
* Build a test party with a nonsense certificate authority for testing purposes.
*/
fun getTestPartyAndCertificate(name: X500Name, publicKey: PublicKey, trustRoot: CertificateAndKeyPair = DUMMY_CA): PartyAndCertificate {
return getTestPartyAndCertificate(Party(name, publicKey), trustRoot)
}

View File

@ -6,7 +6,6 @@ import net.corda.core.contracts.TransactionState
import net.corda.core.crypto.SecureHash
import net.corda.core.transactions.TransactionBuilder
import net.corda.core.transactions.WireTransaction
import net.corda.core.utilities.DUMMY_NOTARY
import java.io.InputStream
/**

View File

@ -1,6 +1,6 @@
@file:JvmName("TestConstants")
package net.corda.core.utilities
package net.corda.testing
import net.corda.core.crypto.*
import net.corda.core.crypto.testing.DummyPublicKey
@ -10,7 +10,6 @@ import org.bouncycastle.asn1.x500.X500Name
import java.math.BigInteger
import java.security.KeyPair
import java.security.PublicKey
import java.security.cert.CertificateFactory
import java.time.Instant
// A dummy time at which we will be pretending test transactions are created.
@ -68,14 +67,3 @@ val DUMMY_CA: CertificateAndKeyPair by lazy {
CertificateAndKeyPair(cert, DUMMY_CA_KEY)
}
/**
* Build a test party with a nonsense certificate authority for testing purposes.
*/
fun getTestPartyAndCertificate(name: X500Name, publicKey: PublicKey, trustRoot: CertificateAndKeyPair = DUMMY_CA) = getTestPartyAndCertificate(Party(name, publicKey), trustRoot)
fun getTestPartyAndCertificate(party: Party, trustRoot: CertificateAndKeyPair = DUMMY_CA): PartyAndCertificate {
val certFactory = CertificateFactory.getInstance("X509")
val certHolder = X509Utilities.createCertificate(CertificateType.IDENTITY, trustRoot.certificate, trustRoot.keyPair, party.name, party.owningKey)
val certPath = certFactory.generateCertPath(listOf(certHolder.cert, trustRoot.certificate.cert))
return PartyAndCertificate(party, certHolder, certPath)
}

View File

@ -6,7 +6,6 @@ import net.corda.core.crypto.SecureHash
import net.corda.core.identity.Party
import net.corda.core.seconds
import net.corda.core.transactions.TransactionBuilder
import net.corda.core.utilities.DUMMY_NOTARY
import java.security.PublicKey
import java.time.Duration
import java.time.Instant

View File

@ -1,6 +1,6 @@
@file:JvmName("VaultFiller")
package net.corda.contracts.testing
package net.corda.testing.contracts
import net.corda.contracts.Commodity
import net.corda.contracts.DealState
@ -15,9 +15,9 @@ import net.corda.core.node.ServiceHub
import net.corda.core.node.services.Vault
import net.corda.core.serialization.OpaqueBytes
import net.corda.core.transactions.SignedTransaction
import net.corda.core.utilities.CHARLIE
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.core.utilities.DUMMY_NOTARY_KEY
import net.corda.testing.CHARLIE
import net.corda.testing.DUMMY_NOTARY
import net.corda.testing.DUMMY_NOTARY_KEY
import java.security.KeyPair
import java.security.PublicKey
import java.time.Instant
@ -63,12 +63,13 @@ fun ServiceHub.fillWithSomeTestLinearStates(numberToCreate: Int,
val transactions: List<SignedTransaction> = (1..numberToCreate).map {
// Issue a Linear state
val dummyIssue = TransactionType.General.Builder(notary = DUMMY_NOTARY).apply {
addOutputState(DummyLinearContract.State(linearId = UniqueIdentifier(externalId),
participants = participants.plus(me),
linearString = linearString,
linearNumber = linearNumber,
linearBoolean = linearBoolean,
linearTimestamp = linearTimestamp))
addOutputState(DummyLinearContract.State(
linearId = UniqueIdentifier(externalId),
participants = participants.plus(me),
linearString = linearString,
linearNumber = linearNumber,
linearBoolean = linearBoolean,
linearTimestamp = linearTimestamp))
signWith(DUMMY_NOTARY_KEY)
}
@ -202,7 +203,7 @@ fun <T : LinearState> ServiceHub.consumeAndProduce(stateAndRef: StateAndRef<T>):
// Create a txn consuming different contract types
val producedTx = TransactionType.General.Builder(notary = DUMMY_NOTARY).apply {
addOutputState(DummyLinearContract.State(linearId = stateAndRef.state.data.linearId,
participants = stateAndRef.state.data.participants))
participants = stateAndRef.state.data.participants))
signWith(DUMMY_NOTARY_KEY)
}.toSignedTransaction()

View File

@ -34,7 +34,7 @@ import net.corda.nodeapi.User
import net.corda.nodeapi.config.SSLConfiguration
import net.corda.nodeapi.config.parseAs
import net.corda.nodeapi.internal.addShutdownHook
import net.corda.testing.MOCK_VERSION_INFO
import net.corda.testing.*
import okhttp3.OkHttpClient
import okhttp3.Request
import org.bouncycastle.asn1.x500.X500Name

View File

@ -1,7 +1,7 @@
package net.corda.testing.driver
import com.google.common.net.HostAndPort
import net.corda.core.utilities.DUMMY_MAP
import net.corda.testing.DUMMY_MAP
import org.bouncycastle.asn1.x500.X500Name
sealed class NetworkMapStartStrategy {

View File

@ -7,9 +7,9 @@ import net.corda.core.identity.Party
import net.corda.core.node.NodeInfo
import net.corda.core.node.ServiceHub
import net.corda.core.node.services.NetworkMapCache
import net.corda.core.utilities.getTestPartyAndCertificate
import net.corda.node.services.network.InMemoryNetworkMapCache
import net.corda.testing.MOCK_VERSION_INFO
import net.corda.testing.getTestPartyAndCertificate
import net.corda.testing.getTestX509Name
import rx.Observable
import rx.subjects.PublishSubject

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