mirror of
https://github.com/corda/corda.git
synced 2025-01-30 08:04:16 +00:00
Detekt fixes
This commit is contained in:
parent
aa74ae69c1
commit
5168c38740
@ -688,7 +688,8 @@
|
||||
<ID>LongParameterList:ServiceHubInternal.kt$ServiceHubInternal.Companion$(statesToRecord: StatesToRecord, txs: Collection<SignedTransaction>, validatedTransactions: WritableTransactionStorage, stateMachineRecordedTransactionMapping: StateMachineRecordedTransactionMappingStorage, vaultService: VaultServiceInternal, database: CordaPersistence)</ID>
|
||||
<ID>LongParameterList:SignatureConstraintVersioningTests.kt$SignatureConstraintVersioningTests$( cordapp: CustomCordapp, newCordapp: CustomCordapp, whiteListedCordapps: Map<ContractClassName, List<CustomCordapp>>, systemProperties: Map<String, String>, startNodesInProcess: Boolean, minimumPlatformVersion: Int = 4, specifyExistingConstraint: Boolean = false, addAnotherAutomaticConstraintState: Boolean = false )</ID>
|
||||
<ID>LongParameterList:SinglePartyNotaryService.kt$SinglePartyNotaryService$( inputs: List<StateRef>, txId: SecureHash, caller: Party, requestSignature: NotarisationRequestSignature, timeWindow: TimeWindow?, references: List<StateRef> )</ID>
|
||||
<ID>LongParameterList:StateMachineState.kt$Checkpoint.Companion$( invocationContext: InvocationContext, flowStart: FlowStart, flowLogicClass: Class<FlowLogic<*>>, frozenFlowLogic: SerializedBytes<FlowLogic<*>>, ourIdentity: Party, subFlowVersion: SubFlowVersion, isEnabledTimedFlow: Boolean )</ID>
|
||||
<ID>LongParameterList:SingleThreadedStateMachineManager.kt$SingleThreadedStateMachineManager$( sessionMessage: ExistingSessionMessage, sender: Party, externalEvent: ExternalEvent.ExternalMessageEvent, messageIdentifier: MessageIdentifier, senderUUID: SenderUUID?, senderSequenceNumber: SenderSequenceNumber? )</ID>
|
||||
<ID>LongParameterList:StateMachineState.kt$Checkpoint.Companion$( invocationContext: InvocationContext, flowStart: FlowStart, flowLogicClass: Class<FlowLogic<*>>, frozenFlowLogic: SerializedBytes<FlowLogic<*>>, ourIdentity: Party, subFlowVersion: SubFlowVersion, isEnabledTimedFlow: Boolean, timestamp: Instant )</ID>
|
||||
<ID>LongParameterList:TLSAuthenticationTests.kt$TLSAuthenticationTests$( rootCAScheme: SignatureScheme, intermediateCAScheme: SignatureScheme, client1CAScheme: SignatureScheme, client1TLSScheme: SignatureScheme, client2CAScheme: SignatureScheme, client2TLSScheme: SignatureScheme )</ID>
|
||||
<ID>LongParameterList:TLSAuthenticationTests.kt$TLSAuthenticationTests$( serverSocketFactory: SSLServerSocketFactory, clientSocketFactory: SSLSocketFactory, serverPort: Int = 0, // Use 0 to get first free socket. clientPort: Int = 0, // Use 0 to get first free socket. cipherSuitesServer: Array<String> = CORDA_TLS_CIPHER_SUITES, cipherSuitesClient: Array<String> = CORDA_TLS_CIPHER_SUITES )</ID>
|
||||
<ID>LongParameterList:TransactionDSLInterpreter.kt$TransactionDSLInterpreter$(contractClassName: ContractClassName, label: String?, notary: Party, encumbrance: Int?, attachmentConstraint: AttachmentConstraint, contractState: ContractState)</ID>
|
||||
@ -894,6 +895,13 @@
|
||||
<ID>MagicNumber:MainView.kt$MainView$150</ID>
|
||||
<ID>MagicNumber:MainView.kt$MainView$30</ID>
|
||||
<ID>MagicNumber:MainView.kt$MainView$5.0</ID>
|
||||
<ID>MagicNumber:MessageIdentifier.kt$MessageIdentifier.Companion$19</ID>
|
||||
<ID>MagicNumber:MessageIdentifier.kt$MessageIdentifier.Companion$20</ID>
|
||||
<ID>MagicNumber:MessageIdentifier.kt$MessageIdentifier.Companion$28</ID>
|
||||
<ID>MagicNumber:MessageIdentifier.kt$MessageIdentifier.Companion$29</ID>
|
||||
<ID>MagicNumber:MessageIdentifier.kt$MessageIdentifier.Companion$3</ID>
|
||||
<ID>MagicNumber:MessageIdentifier.kt$MessageIdentifier.Companion$61</ID>
|
||||
<ID>MagicNumber:MessageIdentifier.kt$MessageIdentifier.Companion$62</ID>
|
||||
<ID>MagicNumber:MessageSizeChecksInterceptor.kt$ArtemisMessageSizeChecksInterceptor$4</ID>
|
||||
<ID>MagicNumber:MigrationNamedCacheFactory.kt$MigrationNamedCacheFactory$1024L</ID>
|
||||
<ID>MagicNumber:MockContractAttachment.kt$113</ID>
|
||||
@ -2322,6 +2330,7 @@
|
||||
<ID>WildcardImport:ServiceHub.kt$import net.corda.core.node.services.*</ID>
|
||||
<ID>WildcardImport:ServiceHubInternal.kt$import net.corda.core.internal.*</ID>
|
||||
<ID>WildcardImport:ServicesForResolutionImpl.kt$import net.corda.core.contracts.*</ID>
|
||||
<ID>WildcardImport:SessionIdTest.kt$import org.assertj.core.api.Assertions.*</ID>
|
||||
<ID>WildcardImport:SettingsModel.kt$import net.corda.core.internal.*</ID>
|
||||
<ID>WildcardImport:SettingsModel.kt$import tornadofx.*</ID>
|
||||
<ID>WildcardImport:SharedContexts.kt$import net.corda.core.serialization.*</ID>
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.corda.node.services.messaging
|
||||
|
||||
import net.corda.core.crypto.SecureHash
|
||||
import net.corda.node.services.messaging.MessageIdentifier.Companion.SHARD_SIZE_IN_CHARS
|
||||
import net.corda.node.services.statemachine.MessageType
|
||||
import net.corda.node.services.statemachine.SessionId
|
||||
import java.lang.IllegalStateException
|
||||
@ -27,20 +28,22 @@ data class MessageIdentifier(
|
||||
val timestamp: Instant
|
||||
) {
|
||||
init {
|
||||
require(shardIdentifier.length == 8) { "Shard identifier needs to be 8 characters long, but it was $shardIdentifier" }
|
||||
require(shardIdentifier.length == SHARD_SIZE_IN_CHARS) { "Shard identifier needs to be $SHARD_SIZE_IN_CHARS characters long, but it was $shardIdentifier" }
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val SHARD_SIZE_IN_CHARS = 8
|
||||
const val LONG_SIZE_IN_HEX = 16 // 64 / 4
|
||||
const val SESSION_ID_SIZE_IN_HEX = SessionId.MAX_BIT_SIZE / 4
|
||||
const val HEX_RADIX = 16
|
||||
|
||||
fun parse(id: String): MessageIdentifier {
|
||||
val prefix = id.substring(0, 2)
|
||||
val messageType = prefixToMessageType(prefix)
|
||||
val timestamp = java.lang.Long.parseUnsignedLong(id.substring(3, 19), 16)
|
||||
val timestamp = java.lang.Long.parseUnsignedLong(id.substring(3, 19), HEX_RADIX)
|
||||
val shardIdentifier = id.substring(20, 28)
|
||||
val sessionId = BigInteger(id.substring(29, 61), 16)
|
||||
val sessionSequenceNumber = Integer.parseInt(id.substring(62), 16)
|
||||
val sessionId = BigInteger(id.substring(29, 61), HEX_RADIX)
|
||||
val sessionSequenceNumber = Integer.parseInt(id.substring(62), HEX_RADIX)
|
||||
return MessageIdentifier(messageType, shardIdentifier, SessionId(sessionId), sessionSequenceNumber, Instant.ofEpochMilli(timestamp))
|
||||
}
|
||||
|
||||
@ -79,7 +82,7 @@ data class MessageIdentifier(
|
||||
}
|
||||
|
||||
fun generateShardId(flowIdentifier: String): String {
|
||||
return SecureHash.sha256(flowIdentifier).prefixChars(8)
|
||||
return SecureHash.sha256(flowIdentifier).prefixChars(SHARD_SIZE_IN_CHARS)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,7 +39,6 @@ import net.corda.node.services.api.CheckpointStorage
|
||||
import net.corda.node.services.api.ServiceHubInternal
|
||||
import net.corda.node.services.messaging.DeduplicationHandler
|
||||
import net.corda.node.services.messaging.MessageIdentifier
|
||||
import net.corda.node.services.messaging.SenderDeduplicationInfo
|
||||
import net.corda.node.services.messaging.SenderSequenceNumber
|
||||
import net.corda.node.services.messaging.SenderUUID
|
||||
import net.corda.node.services.statemachine.FlowStateMachineImpl.Companion.currentStateMachine
|
||||
|
@ -295,7 +295,7 @@ class TopLevelTransition(
|
||||
}
|
||||
|
||||
private fun TransitionBuilder.sendEndMessages() {
|
||||
val sendEndMessageActions = startingState.checkpoint.checkpointState.sessions.map { (sessionId, state) ->
|
||||
val sendEndMessageActions = startingState.checkpoint.checkpointState.sessions.map { (_, state) ->
|
||||
if (state is SessionState.Initiated) {
|
||||
val message = ExistingSessionMessage(state.peerSinkSessionId, EndSessionMessage)
|
||||
val messageType = MessageType.inferFromMessage(message)
|
||||
|
@ -1,28 +0,0 @@
|
||||
package net.corda.node.services.messaging
|
||||
|
||||
import net.corda.node.services.statemachine.SessionId
|
||||
import org.assertj.core.api.Assertions.assertThatThrownBy
|
||||
import org.junit.Test
|
||||
import java.lang.IllegalArgumentException
|
||||
import java.math.BigInteger
|
||||
|
||||
class SessionIdTest {
|
||||
|
||||
@Test(timeout=300_000)
|
||||
fun `session identifier cannot be negative`() {
|
||||
assertThatThrownBy { SessionId(BigInteger.valueOf(-1)) }
|
||||
.isInstanceOf(IllegalArgumentException::class.java)
|
||||
.hasMessage("Session identifier cannot be a negative number, but it was -1")
|
||||
}
|
||||
|
||||
@Test(timeout=300_000)
|
||||
fun `session identifier needs to be a number that can be represented in maximum 128 bits`() {
|
||||
val largestSessionIdentifierValue = BigInteger.valueOf(2).pow(128).minus(BigInteger.ONE)
|
||||
val largestValidSessionId = SessionId(largestSessionIdentifierValue)
|
||||
|
||||
assertThatThrownBy { SessionId(largestSessionIdentifierValue.plus(BigInteger.ONE)) }
|
||||
.isInstanceOf(IllegalArgumentException::class.java)
|
||||
.hasMessage("The size of a session identifier cannot exceed 128 bits, but it was 340282366920938463463374607431768211456")
|
||||
}
|
||||
|
||||
}
|
@ -21,7 +21,7 @@ class SessionIdTest {
|
||||
.isInstanceOf(IllegalArgumentException::class.java)
|
||||
.hasMessageContaining("The size of a session identifier cannot exceed 128 bits, but it was")
|
||||
|
||||
val correctSessionId = SessionId(LARGEST_SESSION_ID_VALUE)
|
||||
SessionId(LARGEST_SESSION_ID_VALUE)
|
||||
}
|
||||
|
||||
@Test(timeout=300_000)
|
||||
|
Loading…
x
Reference in New Issue
Block a user