mirror of
https://github.com/corda/corda.git
synced 2024-12-29 17:28:56 +00:00
CORDA-2769 - fixed infinite recursive call for copy
implementation. (#4912)
This commit is contained in:
parent
ea89f3aac4
commit
270444ab3e
.idea/codeStyles
core/src
main/kotlin/net/corda/core/node
test/kotlin/net/corda/core/node
3
.idea/codeStyles/codeStyleConfig.xml
generated
3
.idea/codeStyles/codeStyleConfig.xml
generated
@ -1,5 +1,6 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||
</state>
|
||||
</component>
|
||||
</component>
|
@ -98,15 +98,20 @@ data class NetworkParameters(
|
||||
require(noPackageOverlap(packageOwnership.keys)) { "Multiple packages added to the packageOwnership overlap." }
|
||||
}
|
||||
|
||||
fun copy(minimumPlatformVersion: Int,
|
||||
notaries: List<NotaryInfo>,
|
||||
maxMessageSize: Int,
|
||||
maxTransactionSize: Int,
|
||||
modifiedTime: Instant,
|
||||
epoch: Int,
|
||||
whitelistedContractImplementations: Map<String, List<AttachmentId>>
|
||||
/**
|
||||
* This is to address backwards compatibility of the API, invariant to package ownership
|
||||
* addresses bug CORDA-2769
|
||||
*/
|
||||
fun copy(minimumPlatformVersion: Int = this.minimumPlatformVersion,
|
||||
notaries: List<NotaryInfo> = this.notaries,
|
||||
maxMessageSize: Int = this.maxMessageSize,
|
||||
maxTransactionSize: Int = this.maxTransactionSize,
|
||||
modifiedTime: Instant = this.modifiedTime,
|
||||
epoch: Int = this.epoch,
|
||||
whitelistedContractImplementations: Map<String, List<AttachmentId>> = this.whitelistedContractImplementations,
|
||||
eventHorizon: Duration = this.eventHorizon
|
||||
): NetworkParameters {
|
||||
return copy(
|
||||
return NetworkParameters(
|
||||
minimumPlatformVersion = minimumPlatformVersion,
|
||||
notaries = notaries,
|
||||
maxMessageSize = maxMessageSize,
|
||||
@ -114,20 +119,24 @@ data class NetworkParameters(
|
||||
modifiedTime = modifiedTime,
|
||||
epoch = epoch,
|
||||
whitelistedContractImplementations = whitelistedContractImplementations,
|
||||
eventHorizon = eventHorizon
|
||||
eventHorizon = eventHorizon,
|
||||
packageOwnership = packageOwnership
|
||||
)
|
||||
}
|
||||
|
||||
fun copy(minimumPlatformVersion: Int,
|
||||
notaries: List<NotaryInfo>,
|
||||
maxMessageSize: Int,
|
||||
maxTransactionSize: Int,
|
||||
modifiedTime: Instant,
|
||||
epoch: Int,
|
||||
whitelistedContractImplementations: Map<String, List<AttachmentId>>,
|
||||
eventHorizon: Duration
|
||||
/**
|
||||
* This is to address backwards compatibility of the API, invariant to package ownership
|
||||
* addresses bug CORDA-2769
|
||||
*/
|
||||
fun copy(minimumPlatformVersion: Int = this.minimumPlatformVersion,
|
||||
notaries: List<NotaryInfo> = this.notaries,
|
||||
maxMessageSize: Int = this.maxMessageSize,
|
||||
maxTransactionSize: Int = this.maxTransactionSize,
|
||||
modifiedTime: Instant = this.modifiedTime,
|
||||
epoch: Int = this.epoch,
|
||||
whitelistedContractImplementations: Map<String, List<AttachmentId>> = this.whitelistedContractImplementations
|
||||
): NetworkParameters {
|
||||
return copy(
|
||||
return NetworkParameters(
|
||||
minimumPlatformVersion = minimumPlatformVersion,
|
||||
notaries = notaries,
|
||||
maxMessageSize = maxMessageSize,
|
||||
@ -135,7 +144,8 @@ data class NetworkParameters(
|
||||
modifiedTime = modifiedTime,
|
||||
epoch = epoch,
|
||||
whitelistedContractImplementations = whitelistedContractImplementations,
|
||||
eventHorizon = eventHorizon
|
||||
eventHorizon = eventHorizon,
|
||||
packageOwnership = packageOwnership
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import com.nhaarman.mockito_kotlin.doReturn
|
||||
import com.nhaarman.mockito_kotlin.whenever
|
||||
import net.corda.core.crypto.generateKeyPair
|
||||
import net.corda.core.internal.getPackageOwnerOf
|
||||
import net.corda.core.node.services.AttachmentId
|
||||
import net.corda.core.utilities.OpaqueBytes
|
||||
import net.corda.core.utilities.days
|
||||
import net.corda.core.utilities.getOrThrow
|
||||
@ -12,10 +13,7 @@ import net.corda.finance.flows.CashIssueFlow
|
||||
import net.corda.node.services.config.NotaryConfig
|
||||
import net.corda.nodeapi.internal.network.NetworkParametersCopier
|
||||
import net.corda.testing.common.internal.testNetworkParameters
|
||||
import net.corda.testing.core.ALICE_NAME
|
||||
import net.corda.testing.core.BOB_NAME
|
||||
import net.corda.testing.core.DUMMY_NOTARY_NAME
|
||||
import net.corda.testing.core.singleIdentity
|
||||
import net.corda.testing.core.*
|
||||
import net.corda.testing.node.MockNetworkNotarySpec
|
||||
import net.corda.testing.node.MockNetworkParameters
|
||||
import net.corda.testing.node.internal.InternalMockNetwork
|
||||
@ -26,6 +24,7 @@ import org.assertj.core.api.Assertions.*
|
||||
import org.junit.After
|
||||
import org.junit.Test
|
||||
import java.nio.file.Path
|
||||
import java.time.Duration
|
||||
import java.time.Instant
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFails
|
||||
@ -64,6 +63,34 @@ class NetworkParametersTest {
|
||||
alice.start()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `that we can copy while preserving the event horizon`() {
|
||||
// this is defensive tests in response to CORDA-2769
|
||||
val aliceNotaryParty = TestIdentity(ALICE_NAME).party
|
||||
val aliceNotaryInfo = NotaryInfo(aliceNotaryParty, false)
|
||||
val nm1 = NetworkParameters(
|
||||
minimumPlatformVersion = 1,
|
||||
notaries = listOf(aliceNotaryInfo),
|
||||
maxMessageSize = Int.MAX_VALUE,
|
||||
maxTransactionSize = Int.MAX_VALUE,
|
||||
modifiedTime = Instant.now(),
|
||||
epoch = 1,
|
||||
whitelistedContractImplementations = mapOf("MyClass" to listOf(AttachmentId.allOnesHash)),
|
||||
eventHorizon = Duration.ofDays(1)
|
||||
)
|
||||
val twoDays = Duration.ofDays(2)
|
||||
val nm2 = nm1.copy(minimumPlatformVersion = 2, eventHorizon = twoDays)
|
||||
|
||||
assertEquals(2, nm2.minimumPlatformVersion)
|
||||
assertEquals(nm1.notaries, nm2.notaries)
|
||||
assertEquals(nm1.maxMessageSize, nm2.maxMessageSize)
|
||||
assertEquals(nm1.maxTransactionSize, nm2.maxTransactionSize)
|
||||
assertEquals(nm1.modifiedTime, nm2.modifiedTime)
|
||||
assertEquals(nm1.epoch, nm2.epoch)
|
||||
assertEquals(nm1.whitelistedContractImplementations, nm2.whitelistedContractImplementations)
|
||||
assertEquals(twoDays, nm2.eventHorizon)
|
||||
}
|
||||
|
||||
// Notaries tests
|
||||
@Test
|
||||
fun `choosing notary not specified in network parameters will fail`() {
|
||||
|
Loading…
Reference in New Issue
Block a user