CORDA-3175 Remove dependency on 3rd party javax.xml.bind library for simple hex parsing/printing. (#5412)

* Remove dependency on 2rd party javax.xml.bind library for simple hex parsing/printing.

* Added unit test.
This commit is contained in:
josecoll
2019-08-30 15:24:01 +01:00
committed by GitHub
parent 6202165957
commit 136600c91a
3 changed files with 67 additions and 6 deletions

View File

@ -1,7 +1,10 @@
package net.corda.core.utilities
import net.corda.core.contracts.StateRef
import net.corda.core.crypto.SecureHash
import net.corda.core.internal.declaredField
import org.assertj.core.api.Assertions.catchThrowable
import org.junit.Assert
import org.junit.Assert.assertSame
import org.junit.Test
import java.nio.ByteBuffer
@ -42,4 +45,17 @@ class ByteArraysTest {
check(byteArrayOf(), seq.slice(2, 2))
check(byteArrayOf(), seq.slice(2, 1))
}
@Test
fun `test hex parsing strictly uppercase`() {
val HEX_REGEX = "^[0-9A-F]+\$".toRegex()
val privacySalt = net.corda.core.contracts.PrivacySalt()
val privacySaltAsHexString = privacySalt.bytes.toHexString()
Assert.assertTrue(privacySaltAsHexString.matches(HEX_REGEX))
val stateRef = StateRef(SecureHash.randomSHA256(), 0)
val txhashAsHexString = stateRef.txhash.bytes.toHexString()
Assert.assertTrue(txhashAsHexString.matches(HEX_REGEX))
}
}