diff --git a/client/mock/src/main/kotlin/net/corda/client/mock/EventGenerator.kt b/client/mock/src/main/kotlin/net/corda/client/mock/EventGenerator.kt index 28e938c843..d5f631826f 100644 --- a/client/mock/src/main/kotlin/net/corda/client/mock/EventGenerator.kt +++ b/client/mock/src/main/kotlin/net/corda/client/mock/EventGenerator.kt @@ -17,7 +17,7 @@ import net.corda.finance.flows.CashPaymentFlow.PaymentRequest open class EventGenerator(val parties: List, val currencies: List, val notary: Party) { protected val partyGenerator = Generator.pickOne(parties) - protected val issueRefGenerator = Generator.intRange(0, 1).map { number -> OpaqueBytes(ByteArray(1, { number.toByte() })) } + protected val issueRefGenerator = Generator.intRange(0, 1).map { number -> OpaqueBytes.of(number.toByte()) } protected val amountGenerator = Generator.longRange(10000, 1000000) protected val currencyGenerator = Generator.pickOne(currencies) protected val currencyMap: MutableMap = mutableMapOf(USD to 0L, GBP to 0L) // Used for estimation of how much money we have in general. diff --git a/core-deterministic/testing/data/src/test/kotlin/net/corda/deterministic/data/KeyStoreGenerator.kt b/core-deterministic/testing/data/src/test/kotlin/net/corda/deterministic/data/KeyStoreGenerator.kt index f14f933f10..a1511fbb42 100644 --- a/core-deterministic/testing/data/src/test/kotlin/net/corda/deterministic/data/KeyStoreGenerator.kt +++ b/core-deterministic/testing/data/src/test/kotlin/net/corda/deterministic/data/KeyStoreGenerator.kt @@ -5,7 +5,6 @@ import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter import org.bouncycastle.cert.jcajce.JcaX509v3CertificateBuilder import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder import java.io.OutputStream -import java.math.BigInteger import java.math.BigInteger.TEN import java.security.KeyPairGenerator import java.security.KeyStore diff --git a/core-deterministic/testing/src/test/kotlin/net/corda/deterministic/contracts/PrivacySaltTest.kt b/core-deterministic/testing/src/test/kotlin/net/corda/deterministic/contracts/PrivacySaltTest.kt index 5b66cf520e..0232711dd8 100644 --- a/core-deterministic/testing/src/test/kotlin/net/corda/deterministic/contracts/PrivacySaltTest.kt +++ b/core-deterministic/testing/src/test/kotlin/net/corda/deterministic/contracts/PrivacySaltTest.kt @@ -11,7 +11,7 @@ class PrivacySaltTest { @Test fun testValidSalt() { - PrivacySalt(ByteArray(SALT_SIZE, { 0x14 })) + PrivacySalt(ByteArray(SALT_SIZE) { 0x14 }) } @Test @@ -22,13 +22,13 @@ class PrivacySaltTest { @Test fun testTooShortPrivacySalt() { - val ex = assertFailsWith { PrivacySalt(ByteArray(SALT_SIZE - 1, { 0x7f })) } + val ex = assertFailsWith { PrivacySalt(ByteArray(SALT_SIZE - 1) { 0x7f }) } assertEquals("Privacy salt should be 32 bytes.", ex.message) } @Test fun testTooLongPrivacySalt() { - val ex = assertFailsWith { PrivacySalt(ByteArray(SALT_SIZE + 1, { 0x7f })) } + val ex = assertFailsWith { PrivacySalt(ByteArray(SALT_SIZE + 1) { 0x7f }) } assertEquals("Privacy salt should be 32 bytes.", ex.message) } } \ No newline at end of file diff --git a/core-deterministic/testing/src/test/kotlin/net/corda/deterministic/crypto/SecureHashTest.kt b/core-deterministic/testing/src/test/kotlin/net/corda/deterministic/crypto/SecureHashTest.kt index a9a069f589..de90178f22 100644 --- a/core-deterministic/testing/src/test/kotlin/net/corda/deterministic/crypto/SecureHashTest.kt +++ b/core-deterministic/testing/src/test/kotlin/net/corda/deterministic/crypto/SecureHashTest.kt @@ -33,7 +33,7 @@ class SecureHashTest { @Test fun testConstants() { assertArrayEquals(SecureHash.zeroHash.bytes, ByteArray(32)) - assertArrayEquals(SecureHash.allOnesHash.bytes, ByteArray(32, { 0xFF.toByte() })) + assertArrayEquals(SecureHash.allOnesHash.bytes, ByteArray(32) { 0xFF.toByte() }) } } diff --git a/core/src/main/kotlin/net/corda/core/crypto/SecureHash.kt b/core/src/main/kotlin/net/corda/core/crypto/SecureHash.kt index 91b1e5ce55..220298587b 100644 --- a/core/src/main/kotlin/net/corda/core/crypto/SecureHash.kt +++ b/core/src/main/kotlin/net/corda/core/crypto/SecureHash.kt @@ -90,7 +90,7 @@ sealed class SecureHash(bytes: ByteArray) : OpaqueBytes(bytes) { * This field provides more intuitive access from Java. */ @JvmField - val zeroHash: SHA256 = SecureHash.SHA256(ByteArray(32, { 0.toByte() })) + val zeroHash: SHA256 = SecureHash.SHA256(ByteArray(32) { 0.toByte() }) /** * A SHA-256 hash value consisting of 32 0x00 bytes. @@ -104,7 +104,7 @@ sealed class SecureHash(bytes: ByteArray) : OpaqueBytes(bytes) { * This field provides more intuitive access from Java. */ @JvmField - val allOnesHash: SHA256 = SecureHash.SHA256(ByteArray(32, { 255.toByte() })) + val allOnesHash: SHA256 = SecureHash.SHA256(ByteArray(32) { 255.toByte() }) /** * A SHA-256 hash value consisting of 32 0xFF bytes. diff --git a/node/src/test/kotlin/net/corda/node/serialization/kryo/KryoTests.kt b/node/src/test/kotlin/net/corda/node/serialization/kryo/KryoTests.kt index ad80d678d5..4570ea1495 100644 --- a/node/src/test/kotlin/net/corda/node/serialization/kryo/KryoTests.kt +++ b/node/src/test/kotlin/net/corda/node/serialization/kryo/KryoTests.kt @@ -170,7 +170,7 @@ class KryoTests(private val compression: CordaSerializationEncoding?) { @Test fun `InputStream serialisation`() { - val rubbish = ByteArray(12345, { (it * it * 0.12345).toByte() }) + val rubbish = ByteArray(12345) { (it * it * 0.12345).toByte() } val readRubbishStream: InputStream = rubbish.inputStream().serialize(factory, context).deserialize(factory, context) for (i in 0..12344) { assertEquals(rubbish[i], readRubbishStream.read().toByte()) @@ -208,7 +208,7 @@ class KryoTests(private val compression: CordaSerializationEncoding?) { @Test fun `HashCheckingStream (de)serialize`() { - val rubbish = ByteArray(12345, { (it * it * 0.12345).toByte() }) + val rubbish = ByteArray(12345) { (it * it * 0.12345).toByte() } val readRubbishStream: InputStream = NodeAttachmentService.HashCheckingStream( SecureHash.sha256(rubbish), rubbish.size, diff --git a/tools/explorer/src/main/kotlin/net/corda/explorer/ExplorerSimulation.kt b/tools/explorer/src/main/kotlin/net/corda/explorer/ExplorerSimulation.kt index e3b014a02c..b44c2b7af4 100644 --- a/tools/explorer/src/main/kotlin/net/corda/explorer/ExplorerSimulation.kt +++ b/tools/explorer/src/main/kotlin/net/corda/explorer/ExplorerSimulation.kt @@ -170,7 +170,7 @@ class ExplorerSimulation(private val options: OptionSet) { for (ref in 0..1) { for ((currency, issuer) in issuers) { val amount = Amount(1_000_000, currency) - issuer.startFlow(::CashIssueAndPaymentFlow, amount, OpaqueBytes(ByteArray(1, { ref.toByte() })), + issuer.startFlow(::CashIssueAndPaymentFlow, amount, OpaqueBytes.of( ref.toByte() ), it, anonymous, notary).returnValue.getOrThrow() } }