Skip to content

Commit

Permalink
Merge pull request corda#6254 from corda/adel/merge-from-4.5
Browse files Browse the repository at this point in the history
Adel/merge from 4.5
  • Loading branch information
rick-r3 authored May 15, 2020
2 parents 6dd72ac + b9b0ca5 commit ac03ba6
Show file tree
Hide file tree
Showing 28 changed files with 177 additions and 77 deletions.
6 changes: 1 addition & 5 deletions .ci/dev/regression/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
@Library('corda-shared-build-pipeline-steps')
import static com.r3.build.BuildControl.killAllExistingBuildsForJob

killAllExistingBuildsForJob(env.JOB_NAME, env.BUILD_NUMBER.toInteger())

pipeline {
agent { label 'k8s' }
options {
timestamps()
buildDiscarder(logRotator(daysToKeepStr: '7', artifactDaysToKeepStr: '7'))
disableConcurrentBuilds()
timeout(time: 3, unit: 'HOURS')
}

Expand Down
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ buildscript {
"unknown"
}
}()
ext.corda_docs_link = "https://docs.corda.net/docs/corda-os/$baseVersion"
repositories {
mavenLocal()
mavenCentral()
Expand Down Expand Up @@ -309,6 +310,7 @@ allprojects {
attributes('Corda-Revision': corda_revision)
attributes('Corda-Vendor': 'Corda Open Source')
attributes('Automatic-Module-Name': "net.corda.${task.project.name.replaceAll('-', '.')}")
attributes('Corda-Docs-Link': corda_docs_link)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class CordaVersion {
val revision: String by lazy { manifestValue("Corda-Revision") ?: UNKNOWN }
val vendor: String by lazy { manifestValue("Corda-Vendor") ?: UNKNOWN }
val platformVersion: Int by lazy { manifestValue("Corda-Platform-Version")?.toInt() ?: 1 }
val docsLink: String by lazy { manifestValue("Corda-Docs-Link") ?: UNKNOWN }

internal val semanticVersion: String by lazy { if(releaseVersion == UNKNOWN) CURRENT_MAJOR_RELEASE else releaseVersion }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,10 @@ import java.util.*
class CordaErrorContextProvider : ErrorContextProvider {

companion object {
private const val BASE_URL = "https://docs.corda.net/docs"
private const val OS_PAGES = "corda-os"
private const val ENTERPRISE_PAGES = "corda-enterprise"
private const val ERROR_CODE_PAGE = "error-codes.html"
}

override fun getURL(locale: Locale): String {
val versionNumber = CordaVersion.releaseVersion

// This slightly strange block here allows the code to be merged across to Enterprise with no changes.
val productVersion = if (CordaVersion.platformEditionCode == "OS") {
OS_PAGES
} else {
ENTERPRISE_PAGES
}
return "$BASE_URL/$productVersion/$versionNumber/$ERROR_CODE_PAGE"
return "${CordaVersion.docsLink}/$ERROR_CODE_PAGE"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal class ErrorReporterImpl(private val resourceLocation: String,
val resource = "$resourceLocation/$ERROR_INFO_RESOURCE"
val codeMessage = fetchAndFormat(resource, ERROR_CODE_MESSAGE, arrayOf(error.formatCode()))
val urlMessage = fetchAndFormat(resource, ERROR_CODE_URL, arrayOf(errorContextProvider.getURL(locale)))
return "[$codeMessage, $urlMessage]"
return "[$codeMessage $urlMessage]"
}

override fun report(error: ErrorCode<*>, logger: Logger) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class CordaErrorContextProviderTest {
@Test(timeout = 300_000)
fun `check that correct URL is returned from context provider`() {
val context = CordaErrorContextProvider()
val expectedURL = "https://docs.corda.net/docs/corda-os/${CordaVersion.releaseVersion}/error-codes.html"
val version = CordaVersion.releaseVersion.substringBefore("-") // Remove SNAPSHOT if present
val expectedURL = "https://docs.corda.net/docs/corda-os/$version/error-codes.html"
// In this first release, there is only one localisation and the URL structure for future localisations is currently unknown. As
// a result, the same URL is expected for all locales.
assertEquals(expectedURL, context.getURL(Locale.getDefault()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class ErrorReporterImplTest {
val error = TEST_ERROR_1
val testReporter = createReporterImpl("en-US")
testReporter.report(error, loggerMock)
assertEquals(listOf("This is a test message [Code: test-case1, URL: $TEST_URL/en-US]"), logs)
assertEquals(listOf("This is a test message [Code: test-case1 URL: $TEST_URL/en-US]"), logs)
}

@Test(timeout = 300_00)
Expand All @@ -84,38 +84,38 @@ class ErrorReporterImplTest {
val testReporter = createReporterImpl("en-US")
testReporter.report(error, loggerMock)
val format = DateFormat.getDateInstance(DateFormat.LONG, Locale.forLanguageTag("en-US"))
assertEquals(listOf("This is the second case with string foo, number 1, date ${format.format(currentDate)} [Code: test-case2, URL: $TEST_URL/en-US]"), logs)
assertEquals(listOf("This is the second case with string foo, number 1, date ${format.format(currentDate)} [Code: test-case2 URL: $TEST_URL/en-US]"), logs)
}

@Test(timeout = 300_000)
fun `locale used with no corresponding resource falls back to default`() {
val error = TEST_ERROR_1
val testReporter = createReporterImpl("fr-FR")
testReporter.report(error, loggerMock)
assertEquals(listOf("This is a test message [Code: test-case1, URL: $TEST_URL/fr-FR]"), logs)
assertEquals(listOf("This is a test message [Code: test-case1 URL: $TEST_URL/fr-FR]"), logs)
}

@Test(timeout = 300_000)
fun `locale with corresponding resource causes correct error to be printed`() {
val error = TEST_ERROR_1
val testReporter = createReporterImpl("ga-IE")
testReporter.report(error, loggerMock)
assertEquals(listOf("Is teachtaireacht earráide é seo [Code: test-case1, URL: $TEST_URL/ga-IE]"), logs)
assertEquals(listOf("Is teachtaireacht earráide é seo [Code: test-case1 URL: $TEST_URL/ga-IE]"), logs)
}

@Test(timeout = 300_000)
fun `locale with missing properties falls back to default properties`() {
val error = TEST_ERROR_1
val testReporter = createReporterImpl("es-ES")
testReporter.report(error, loggerMock)
assertEquals(listOf("This is a test message [Code: test-case1, URL: $TEST_URL/es-ES]"), logs)
assertEquals(listOf("This is a test message [Code: test-case1 URL: $TEST_URL/es-ES]"), logs)
}

@Test(timeout = 300_000)
fun `error code with underscore in translated to resource file successfully`() {
val error = TEST_ERROR_3
val testReporter = createReporterImpl("en-US")
testReporter.report(error, loggerMock)
assertEquals(listOf("This is the third test message [Code: test-case-3, URL: $TEST_URL/en-US]"), logs)
assertEquals(listOf("This is the third test message [Code: test-case-3 URL: $TEST_URL/en-US]"), logs)
}
}
2 changes: 1 addition & 1 deletion constants.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ quasarVersion11=0.8.0_r3
jdkClassifier11=jdk11
proguardVersion=6.1.1
bouncycastleVersion=1.60
classgraphVersion=4.8.71
classgraphVersion=4.8.78
disruptorVersion=3.4.2
typesafeConfigVersion=1.3.4
jsr305Version=3.0.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import org.bouncycastle.asn1.x509.GeneralSubtree
import org.bouncycastle.asn1.x509.NameConstraints
import org.bouncycastle.jce.provider.BouncyCastleProvider
import org.junit.Test
import java.security.Security
import java.security.UnrecoverableKeyException
import java.security.cert.CertPathValidator
import java.security.cert.CertPathValidatorException
Expand Down Expand Up @@ -95,7 +94,8 @@ class X509NameConstraintsTest {

@Test(timeout=300_000)
fun `x500 name with correct cn and extra attribute`() {
Security.addProvider(BouncyCastleProvider())
// Do not use Security.addProvider(BouncyCastleProvider()) to avoid EdDSA signature disruption in other tests.
Crypto.findProvider(BouncyCastleProvider.PROVIDER_NAME)
val acceptableNames = listOf("CN=Bank A TLS, UID=", "O=Bank A")
.map { GeneralSubtree(GeneralName(X500Name(it))) }.toTypedArray()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,6 @@ abstract class TransactionVerificationException(val txId: SecureHash, message: S
"""
State of class ${state.data ::class.java.typeName} belongs to contract $requiredContractClassName, but
is bundled in TransactionState with ${state.contract}.
For details see: https://docs.corda.net/api-contract-constraints.html#contract-state-agreement
""".trimIndent().replace('\n', ' '))
}

Expand All @@ -243,8 +241,6 @@ abstract class TransactionVerificationException(val txId: SecureHash, message: S
State of class ${state.data::class.java.typeName} does not have a specified owning contract.
Add the @BelongsToContract annotation to this class to ensure that it can only be bundled in a TransactionState
with the correct contract.
For details see: https://docs.corda.net/api-contract-constraints.html#contract-state-agreement
""".trimIndent())
}

Expand Down Expand Up @@ -331,8 +327,7 @@ abstract class TransactionVerificationException(val txId: SecureHash, message: S
*/
class PackageOwnershipException(txId: SecureHash, @Suppress("unused") val attachmentHash: AttachmentId, @Suppress("unused") val invalidClassName: String, val packageName: String) : TransactionVerificationException(txId,
"""The attachment JAR: $attachmentHash containing the class: $invalidClassName is not signed by the owner of package $packageName specified in the network parameters.
Please check the source of this attachment and if it is malicious contact your zone operator to report this incident.
For details see: https://docs.corda.net/network-map.html#network-parameters""".trimIndent(), null)
Please check the source of this attachment and if it is malicious contact your zone operator to report this incident.""".trimIndent(), null)

class InvalidAttachmentException(txId: SecureHash, @Suppress("unused") val attachmentHash: AttachmentId) : TransactionVerificationException(txId,
"The attachment $attachmentHash is not a valid ZIP or JAR file.".trimIndent(), null)
Expand All @@ -345,8 +340,7 @@ abstract class TransactionVerificationException(val txId: SecureHash, message: S
class UntrustedAttachmentsException(val txId: SecureHash, val ids: List<SecureHash>) :
CordaException("Attempting to load untrusted transaction attachments: $ids. " +
"At this time these are not loadable because the DJVM sandbox has not yet been integrated. " +
"You will need to manually install the CorDapp to whitelist it for use. " +
"Please follow the operational steps outlined in https://docs.corda.net/cordapp-build-systems.html#cordapp-contract-attachments to learn more and continue.")
"You will need to manually install the CorDapp to whitelist it for use.")

/*
If you add a new class extending [TransactionVerificationException], please add a test in `TransactionVerificationExceptionSerializationTests`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ object JarSignatureCollector {
"""
Mismatch between signers ${firstSignerSet.toOrderedPublicKeys()} for file $firstFile
and signers ${otherSignerSet.toOrderedPublicKeys()} for file ${otherFile}.
See https://docs.corda.net/api-contract-constraints.html#signature-constraints for details of the
constraints applied to attachment signatures.
""".trimIndent().replace('\n', ' '))
}
return firstSignerSet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,6 @@ abstract class Verifier(val ltx: LedgerTransaction, protected val transactionCla
logger.warnOnce("""
State of class ${state.data::class.java.typeName} belongs to contract $requiredContractClassName, but
is bundled in TransactionState with ${state.contract}.
For details see: https://docs.corda.net/api-contract-constraints.html#contract-state-agreement
""".trimIndent().replace('\n', ' '))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ object StateContractValidationEnforcementRule {
Unable to determine JAR location for contract state class ${state::class.java.name},
and consequently unable to determine target platform version.
Enforcing state/contract agreement validation by default.
For details see: https://docs.corda.net/api-contract-constraints.html#contract-state-agreement
""".trimIndent().replace("\n", " "))
return true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ class AttachmentsClassLoader(attachments: List<Attachment>,

if (untrusted.isNotEmpty()) {
log.warn("Cannot verify transaction $sampleTxId as the following attachment IDs are untrusted: $untrusted." +
"You will need to manually install the CorDapp to whitelist it for use. " +
"Please follow the operational steps outlined in https://docs.corda.net/cordapp-build-systems.html#cordapp-contract-attachments to learn more and continue.")
"You will need to manually install the CorDapp to whitelist it for use.")
throw TransactionVerificationException.UntrustedAttachmentsException(sampleTxId, untrusted)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ class MissingContractAttachments
@JvmOverloads
constructor(val states: List<TransactionState<ContractState>>, contractsClassName: String? = null, minimumRequiredContractClassVersion: Version? = null) : FlowException(
"Cannot find contract attachments for " +
"${contractsClassName ?: states.map { it.contract }.distinct()}${minimumRequiredContractClassVersion?.let { ", minimum required contract class version $minimumRequiredContractClassVersion"}}. " +
"See https://docs.corda.net/api-contract-constraints.html#debugging")
"${contractsClassName ?: states.map { it.contract }.distinct()}${minimumRequiredContractClassVersion?.let { ", minimum required contract class version $minimumRequiredContractClassVersion"}}.")
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,7 @@ class OutstandingDatabaseChangesException(@Suppress("MemberVisibilityCanBePrivat

class CheckpointsException : DatabaseMigrationException("Attempting to update the database while there are flows in flight. " +
"This is dangerous because the node might not be able to restore the flows correctly and could consequently fail. " +
"Updating the database would make reverting to the previous version more difficult. " +
"Please drain your node first. See: https://docs.corda.net/upgrading-cordapps.html#flow-drains")
"Updating the database would make reverting to the previous version more difficult.")

class DatabaseIncompatibleException(@Suppress("MemberVisibilityCanBePrivate") private val reason: String) : DatabaseMigrationException(errorMessageFor(reason)) {
internal companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ class RpcReconnectTests {
* This test runs flows in a loop and in the background kills the node or restarts it.
* Also the RPC connection is made through a proxy that introduces random latencies and is also periodically killed.
*/
@Test(timeout=300_000)
@Suppress("ComplexMethod")
@Test(timeout=420_000)
fun `test that the RPC client is able to reconnect and proceed after node failure, restart, or connection reset`() {
val nodeRunningTime = { Random().nextInt(12000) + 8000 }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ import java.math.BigInteger
import java.net.InetSocketAddress
import java.security.KeyPair
import java.security.PrivateKey
import java.security.Security
import java.security.cert.X509CRL
import java.security.cert.X509Certificate
import java.util.*
Expand Down Expand Up @@ -117,7 +116,8 @@ class CertificateRevocationListNodeTests {

@Before
fun setUp() {
Security.addProvider(BouncyCastleProvider())
// Do not use Security.addProvider(BouncyCastleProvider()) to avoid EdDSA signature disruption in other tests.
Crypto.findProvider(BouncyCastleProvider.PROVIDER_NAME)
revokedNodeCerts.clear()
server = CrlServer(NetworkHostAndPort("localhost", 0))
server.start()
Expand Down
Loading

0 comments on commit ac03ba6

Please sign in to comment.