mirror of
https://github.com/corda/corda.git
synced 2024-12-18 20:47:57 +00:00
Resolve warnings for Kotlin ByteArray. (#3521)
This commit is contained in:
parent
35b2170b9c
commit
02978fc174
@ -17,7 +17,7 @@ import net.corda.finance.flows.CashPaymentFlow.PaymentRequest
|
|||||||
|
|
||||||
open class EventGenerator(val parties: List<Party>, val currencies: List<Currency>, val notary: Party) {
|
open class EventGenerator(val parties: List<Party>, val currencies: List<Currency>, val notary: Party) {
|
||||||
protected val partyGenerator = Generator.pickOne(parties)
|
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 amountGenerator = Generator.longRange(10000, 1000000)
|
||||||
protected val currencyGenerator = Generator.pickOne(currencies)
|
protected val currencyGenerator = Generator.pickOne(currencies)
|
||||||
protected val currencyMap: MutableMap<Currency, Long> = mutableMapOf(USD to 0L, GBP to 0L) // Used for estimation of how much money we have in general.
|
protected val currencyMap: MutableMap<Currency, Long> = mutableMapOf(USD to 0L, GBP to 0L) // Used for estimation of how much money we have in general.
|
||||||
|
@ -5,7 +5,6 @@ import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter
|
|||||||
import org.bouncycastle.cert.jcajce.JcaX509v3CertificateBuilder
|
import org.bouncycastle.cert.jcajce.JcaX509v3CertificateBuilder
|
||||||
import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder
|
import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder
|
||||||
import java.io.OutputStream
|
import java.io.OutputStream
|
||||||
import java.math.BigInteger
|
|
||||||
import java.math.BigInteger.TEN
|
import java.math.BigInteger.TEN
|
||||||
import java.security.KeyPairGenerator
|
import java.security.KeyPairGenerator
|
||||||
import java.security.KeyStore
|
import java.security.KeyStore
|
||||||
|
@ -11,7 +11,7 @@ class PrivacySaltTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testValidSalt() {
|
fun testValidSalt() {
|
||||||
PrivacySalt(ByteArray(SALT_SIZE, { 0x14 }))
|
PrivacySalt(ByteArray(SALT_SIZE) { 0x14 })
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -22,13 +22,13 @@ class PrivacySaltTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testTooShortPrivacySalt() {
|
fun testTooShortPrivacySalt() {
|
||||||
val ex = assertFailsWith<IllegalArgumentException> { PrivacySalt(ByteArray(SALT_SIZE - 1, { 0x7f })) }
|
val ex = assertFailsWith<IllegalArgumentException> { PrivacySalt(ByteArray(SALT_SIZE - 1) { 0x7f }) }
|
||||||
assertEquals("Privacy salt should be 32 bytes.", ex.message)
|
assertEquals("Privacy salt should be 32 bytes.", ex.message)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testTooLongPrivacySalt() {
|
fun testTooLongPrivacySalt() {
|
||||||
val ex = assertFailsWith<IllegalArgumentException> { PrivacySalt(ByteArray(SALT_SIZE + 1, { 0x7f })) }
|
val ex = assertFailsWith<IllegalArgumentException> { PrivacySalt(ByteArray(SALT_SIZE + 1) { 0x7f }) }
|
||||||
assertEquals("Privacy salt should be 32 bytes.", ex.message)
|
assertEquals("Privacy salt should be 32 bytes.", ex.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -33,7 +33,7 @@ class SecureHashTest {
|
|||||||
@Test
|
@Test
|
||||||
fun testConstants() {
|
fun testConstants() {
|
||||||
assertArrayEquals(SecureHash.zeroHash.bytes, ByteArray(32))
|
assertArrayEquals(SecureHash.zeroHash.bytes, ByteArray(32))
|
||||||
assertArrayEquals(SecureHash.allOnesHash.bytes, ByteArray(32, { 0xFF.toByte() }))
|
assertArrayEquals(SecureHash.allOnesHash.bytes, ByteArray(32) { 0xFF.toByte() })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ sealed class SecureHash(bytes: ByteArray) : OpaqueBytes(bytes) {
|
|||||||
* This field provides more intuitive access from Java.
|
* This field provides more intuitive access from Java.
|
||||||
*/
|
*/
|
||||||
@JvmField
|
@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.
|
* 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.
|
* This field provides more intuitive access from Java.
|
||||||
*/
|
*/
|
||||||
@JvmField
|
@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.
|
* A SHA-256 hash value consisting of 32 0xFF bytes.
|
||||||
|
@ -170,7 +170,7 @@ class KryoTests(private val compression: CordaSerializationEncoding?) {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `InputStream serialisation`() {
|
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)
|
val readRubbishStream: InputStream = rubbish.inputStream().serialize(factory, context).deserialize(factory, context)
|
||||||
for (i in 0..12344) {
|
for (i in 0..12344) {
|
||||||
assertEquals(rubbish[i], readRubbishStream.read().toByte())
|
assertEquals(rubbish[i], readRubbishStream.read().toByte())
|
||||||
@ -208,7 +208,7 @@ class KryoTests(private val compression: CordaSerializationEncoding?) {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `HashCheckingStream (de)serialize`() {
|
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(
|
val readRubbishStream: InputStream = NodeAttachmentService.HashCheckingStream(
|
||||||
SecureHash.sha256(rubbish),
|
SecureHash.sha256(rubbish),
|
||||||
rubbish.size,
|
rubbish.size,
|
||||||
|
@ -170,7 +170,7 @@ class ExplorerSimulation(private val options: OptionSet) {
|
|||||||
for (ref in 0..1) {
|
for (ref in 0..1) {
|
||||||
for ((currency, issuer) in issuers) {
|
for ((currency, issuer) in issuers) {
|
||||||
val amount = Amount(1_000_000, currency)
|
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()
|
it, anonymous, notary).returnValue.getOrThrow()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user