mirror of
https://github.com/corda/corda.git
synced 2025-06-22 17:09:00 +00:00
[CORDA-1472]: Crackdown on warnings. (#3136)
This commit is contained in:
committed by
GitHub
parent
5a92079011
commit
d027b5b8f2
@ -1,7 +1,12 @@
|
||||
package net.corda.testing.contracts
|
||||
|
||||
import net.corda.core.contracts.*
|
||||
import net.corda.core.crypto.SecureHash
|
||||
import net.corda.core.contracts.AlwaysAcceptAttachmentConstraint
|
||||
import net.corda.core.contracts.AttachmentConstraint
|
||||
import net.corda.core.contracts.CommandData
|
||||
import net.corda.core.contracts.ContractClassName
|
||||
import net.corda.core.contracts.ContractState
|
||||
import net.corda.core.contracts.TypeOnlyCommandData
|
||||
import net.corda.core.contracts.UpgradedContractWithLegacyConstraint
|
||||
import net.corda.core.identity.AbstractParty
|
||||
import net.corda.core.transactions.LedgerTransaction
|
||||
|
||||
|
@ -243,7 +243,7 @@ private sealed class ExpectComposeState<E : Any> {
|
||||
null
|
||||
} else if (next.second is Finished) {
|
||||
if (index == sequential.sequence.size - 1) {
|
||||
Pair(next.first, Finished<E>())
|
||||
Pair(next.first, Finished())
|
||||
} else {
|
||||
val nextState = fromExpectCompose(sequential.sequence[index + 1])
|
||||
if (nextState is Finished) {
|
||||
@ -271,10 +271,10 @@ private sealed class ExpectComposeState<E : Any> {
|
||||
val nextStates = states.mapIndexed { i, expectComposeState ->
|
||||
if (i == stateIndex) next.second else expectComposeState
|
||||
}
|
||||
if (nextStates.all { it is Finished }) {
|
||||
return Pair(next.first, Finished())
|
||||
return if (nextStates.all { it is Finished }) {
|
||||
Pair(next.first, Finished())
|
||||
} else {
|
||||
return Pair(next.first, Parallel(parallel, nextStates))
|
||||
Pair(next.first, Parallel(parallel, nextStates))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -293,14 +293,14 @@ private sealed class ExpectComposeState<E : Any> {
|
||||
Single(uncheckedCast(expectCompose))
|
||||
}
|
||||
is ExpectCompose.Sequential -> {
|
||||
if (expectCompose.sequence.size > 0) {
|
||||
if (expectCompose.sequence.isNotEmpty()) {
|
||||
Sequential(expectCompose, 0, fromExpectCompose(expectCompose.sequence[0]))
|
||||
} else {
|
||||
Finished()
|
||||
}
|
||||
}
|
||||
is ExpectCompose.Parallel -> {
|
||||
if (expectCompose.parallel.size > 0) {
|
||||
if (expectCompose.parallel.isNotEmpty()) {
|
||||
Parallel(expectCompose, expectCompose.parallel.map { fromExpectCompose(it) })
|
||||
} else {
|
||||
Finished()
|
||||
|
@ -6,9 +6,7 @@ import net.corda.core.contracts.Command
|
||||
import net.corda.core.contracts.TypeOnlyCommandData
|
||||
import net.corda.core.crypto.generateKeyPair
|
||||
import net.corda.core.identity.CordaX500Name
|
||||
import net.corda.nodeapi.internal.crypto.CertificateAndKeyPair
|
||||
import java.security.PublicKey
|
||||
import java.time.Instant
|
||||
|
||||
/** A test notary name **/
|
||||
@JvmField
|
||||
|
@ -7,6 +7,7 @@ import net.corda.core.crypto.*
|
||||
import net.corda.core.crypto.NullKeys.NULL_SIGNATURE
|
||||
import net.corda.core.flows.FlowException
|
||||
import net.corda.core.identity.Party
|
||||
import net.corda.core.internal.UNKNOWN_UPLOADER
|
||||
import net.corda.core.internal.uncheckedCast
|
||||
import net.corda.core.node.ServiceHub
|
||||
import net.corda.core.node.ServicesForResolution
|
||||
@ -281,7 +282,7 @@ data class TestLedgerDSLInterpreter private constructor(
|
||||
copy().dsl()
|
||||
|
||||
override fun attachment(attachment: InputStream): SecureHash {
|
||||
return services.attachments.importAttachment(attachment)
|
||||
return services.attachments.importAttachment(attachment, UNKNOWN_UPLOADER, null)
|
||||
}
|
||||
|
||||
override fun verifies(): EnforceVerifyOrFail {
|
||||
|
@ -175,7 +175,7 @@ private fun getFrameOffsets(stack: Stack): List<Pair<Int, Int>> {
|
||||
return offsets
|
||||
}
|
||||
|
||||
private val MASK_FULL: Long = -1L
|
||||
private const val MASK_FULL: Long = -1L
|
||||
|
||||
private fun getNumSlots(record: Long): Int {
|
||||
return getUnsignedBits(record, 14, 16).toInt()
|
||||
|
@ -9,4 +9,4 @@ val DEV_ROOT_CA: CertificateAndKeyPair by lazy { net.corda.nodeapi.internal.DEV_
|
||||
|
||||
/** A dummy time at which we will be pretending test transactions are created. **/
|
||||
@JvmField
|
||||
val TEST_TX_TIME = Instant.parse("2015-04-17T12:00:00.00Z")
|
||||
val TEST_TX_TIME: Instant = Instant.parse("2015-04-17T12:00:00.00Z")
|
@ -62,5 +62,4 @@ object LogHelper {
|
||||
Configurator.setLevel(logName, oldLevel)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,11 +5,11 @@ import com.typesafe.config.ConfigFactory
|
||||
import net.corda.node.internal.cordapp.CordappConfigProvider
|
||||
|
||||
class MockCordappConfigProvider : CordappConfigProvider {
|
||||
val cordappConfigs = mutableMapOf<String, Config> ()
|
||||
val cordappConfigs = mutableMapOf<String, Config>()
|
||||
|
||||
override fun getConfigByName(name: String): Config {
|
||||
return if(cordappConfigs.containsKey(name)) {
|
||||
cordappConfigs[name]!!
|
||||
return if (cordappConfigs.containsKey(name)) {
|
||||
cordappConfigs[name]!!
|
||||
} else {
|
||||
ConfigFactory.empty()
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import net.corda.core.transactions.LedgerTransaction
|
||||
import net.corda.core.transactions.TransactionBuilder
|
||||
import net.corda.finance.contracts.DealState
|
||||
|
||||
val DUMMY_DEAL_PROGRAM_ID = "net.corda.testing.internal.vault.DummyDealContract"
|
||||
const val DUMMY_DEAL_PROGRAM_ID = "net.corda.testing.internal.vault.DummyDealContract"
|
||||
|
||||
class DummyDealContract : Contract {
|
||||
override fun verify(tx: LedgerTransaction) {}
|
||||
|
@ -22,9 +22,7 @@ object DummyDealStateSchemaV1 : MappedSchema(schemaFamily = DummyDealStateSchema
|
||||
/** parent attributes */
|
||||
@ElementCollection
|
||||
@Column(name = "participants")
|
||||
@CollectionTable(name = "dummy_deal_states_parts", joinColumns = arrayOf(
|
||||
JoinColumn(name = "output_index", referencedColumnName = "output_index"),
|
||||
JoinColumn(name = "transaction_id", referencedColumnName = "transaction_id")))
|
||||
@CollectionTable(name = "dummy_deal_states_parts", joinColumns = [(JoinColumn(name = "output_index", referencedColumnName = "output_index")), (JoinColumn(name = "transaction_id", referencedColumnName = "transaction_id"))])
|
||||
override var participants: MutableSet<AbstractParty>? = null,
|
||||
|
||||
@Transient
|
||||
|
@ -18,9 +18,7 @@ object DummyLinearStateSchemaV2 : MappedSchema(schemaFamily = DummyLinearStateSc
|
||||
|
||||
@ElementCollection
|
||||
@Column(name = "participants")
|
||||
@CollectionTable(name = "dummy_linear_states_v2_parts", joinColumns = arrayOf(
|
||||
JoinColumn(name = "output_index", referencedColumnName = "output_index"),
|
||||
JoinColumn(name = "transaction_id", referencedColumnName = "transaction_id")))
|
||||
@CollectionTable(name = "dummy_linear_states_v2_parts", joinColumns = [(JoinColumn(name = "output_index", referencedColumnName = "output_index")), (JoinColumn(name = "transaction_id", referencedColumnName = "transaction_id"))])
|
||||
override var participants: MutableSet<AbstractParty>? = null,
|
||||
|
||||
@Column(name = "linear_string") var linearString: String,
|
||||
|
@ -27,11 +27,12 @@ class MockAttachmentStorage : AttachmentStorage, SingletonSerializeAsToken() {
|
||||
/** A map of the currently stored files by their [SecureHash] */
|
||||
val files: Map<SecureHash, Pair<Attachment, ByteArray>> get() = _files
|
||||
|
||||
@Suppress("OverridingDeprecatedMember")
|
||||
override fun importAttachment(jar: InputStream): AttachmentId = importAttachment(jar, UNKNOWN_UPLOADER, null)
|
||||
|
||||
override fun importAttachment(jar: InputStream, uploader: String, filename: String?): AttachmentId {
|
||||
return withContractsInJar(jar) { contractClassNames, inputStream ->
|
||||
importAttachmentInternal(inputStream, uploader, filename, contractClassNames)
|
||||
importAttachmentInternal(inputStream, uploader, contractClassNames)
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,21 +44,22 @@ class MockAttachmentStorage : AttachmentStorage, SingletonSerializeAsToken() {
|
||||
|
||||
override fun hasAttachment(attachmentId: AttachmentId) = files.containsKey(attachmentId)
|
||||
|
||||
@Suppress("OverridingDeprecatedMember")
|
||||
override fun importOrGetAttachment(jar: InputStream): AttachmentId {
|
||||
try {
|
||||
return importAttachment(jar)
|
||||
} catch (faee: java.nio.file.FileAlreadyExistsException) {
|
||||
return AttachmentId.parse(faee.message!!)
|
||||
return try {
|
||||
importAttachment(jar, UNKNOWN_UPLOADER, null)
|
||||
} catch (e: java.nio.file.FileAlreadyExistsException) {
|
||||
AttachmentId.parse(e.message!!)
|
||||
}
|
||||
}
|
||||
|
||||
fun importContractAttachment(contractClassNames: List<ContractClassName>, uploader: String, jar: InputStream): AttachmentId = importAttachmentInternal(jar, uploader, null, contractClassNames)
|
||||
fun importContractAttachment(contractClassNames: List<ContractClassName>, uploader: String, jar: InputStream): AttachmentId = importAttachmentInternal(jar, uploader, contractClassNames)
|
||||
|
||||
fun getAttachmentIdAndBytes(jar: InputStream): Pair<AttachmentId, ByteArray> = jar.readFully().let { bytes -> Pair(bytes.sha256(), bytes) }
|
||||
|
||||
private class MockAttachment(dataLoader: () -> ByteArray, override val id: SecureHash) : AbstractAttachment(dataLoader)
|
||||
|
||||
private fun importAttachmentInternal(jar: InputStream, uploader: String, filename: String?, contractClassNames: List<ContractClassName>? = null): AttachmentId {
|
||||
private fun importAttachmentInternal(jar: InputStream, uploader: String, contractClassNames: List<ContractClassName>? = null): AttachmentId {
|
||||
// JIS makes read()/readBytes() return bytes of the current file, but we want to hash the entire container here.
|
||||
require(jar !is JarInputStream)
|
||||
|
||||
|
Reference in New Issue
Block a user