CORDA-1815 adding maxTransactionSize validation (#3635)

* CORDA-1815 adding maxTransactionSize validation

* Fixing failing tests

* Fixing failing test
This commit is contained in:
Michal Kit 2018-07-18 10:34:41 +01:00 committed by GitHub
parent 7e3687c306
commit c0207b2219
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 4 deletions

View File

@ -60,6 +60,7 @@ data class NetworkParameters(
require(epoch > 0) { "epoch must be at least 1" }
require(maxMessageSize > 0) { "maxMessageSize must be at least 1" }
require(maxTransactionSize > 0) { "maxTransactionSize must be at least 1" }
require(maxTransactionSize <= maxMessageSize) { "maxTransactionSize cannot be bigger than maxMessageSize" }
require(!eventHorizon.isNegative) { "eventHorizon must be positive value" }
}

View File

@ -350,7 +350,7 @@ class NetworkBootstrapper
notaries = notaryInfos,
modifiedTime = Instant.now(),
maxMessageSize = 10485760,
maxTransactionSize = Int.MAX_VALUE,
maxTransactionSize = 10485760,
whitelistedContractImplementations = whitelist,
epoch = 1,
eventHorizon = 30.days

View File

@ -76,7 +76,7 @@ class LargeTransactionsTest {
driver(DriverParameters(
startNodesInProcess = true,
extraCordappPackagesToScan = listOf("net.corda.testing.contracts"),
networkParameters = testNetworkParameters(maxTransactionSize = 13.MB.toInt())
networkParameters = testNetworkParameters(maxMessageSize = 15.MB.toInt(), maxTransactionSize = 13.MB.toInt())
)) {
val rpcUser = User("admin", "admin", setOf("ALL"))
val (alice, _) = listOf(ALICE_NAME, BOB_NAME).map { startNode(providedName = it, rpcUsers = listOf(rpcUser)) }.transpose().getOrThrow()

View File

@ -20,11 +20,11 @@ import net.corda.testing.node.internal.InternalMockNetwork
import net.corda.testing.node.internal.InternalMockNodeParameters
import net.corda.testing.node.internal.MOCK_VERSION_INFO
import net.corda.testing.node.internal.startFlow
import org.assertj.core.api.Assertions.assertThat
import org.assertj.core.api.Assertions.assertThatThrownBy
import org.assertj.core.api.Assertions.*
import org.junit.After
import org.junit.Test
import java.nio.file.Path
import java.time.Instant
import kotlin.test.assertFails
class NetworkParametersTest {
@ -74,6 +74,19 @@ class NetworkParametersTest {
}
}
@Test
fun `maxTransactionSize must be bigger than maxMesssageSize`() {
assertThatExceptionOfType(IllegalArgumentException::class.java).isThrownBy {
NetworkParameters(1,
emptyList(),
2000,
2001,
Instant.now(),
1,
emptyMap())
}.withMessage("maxTransactionSize cannot be bigger than maxMessageSize")
}
// Helpers
private fun dropParametersToDir(dir: Path, params: NetworkParameters) {
NetworkParametersCopier(params).install(dir)