libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit 7c5040b810fcabc5229f1583922023b368fb6348
parent 27893bb6edf97428696f153f60a0398174098184
Author: Marcello Stanisci <stanisci.m@gmail.com>
Date:   Thu, 24 Oct 2019 18:01:14 +0200

Test simulating keys comparison.

Diffstat:
Asandbox/src/test/kotlin/KeyCmpTest.kt | 25+++++++++++++++++++++++++
1 file changed, 25 insertions(+), 0 deletions(-)

diff --git a/sandbox/src/test/kotlin/KeyCmpTest.kt b/sandbox/src/test/kotlin/KeyCmpTest.kt @@ -0,0 +1,24 @@ +package tech.libeufin.sandbox + +import org.junit.Test +import java.math.BigInteger +import junit.framework.TestCase.assertTrue + +class KeyCmpTest { + + /** + * This test simulates the way keys are compared when they get + * confirmed via the "keyletter". The scenario has one format + * (ByteArray) for keys stored in the database, and another (hexadecimanl + * string) for keys communicated in the keyletter. + */ + @Test + fun bytesCmp() { + + val HEX_STRING = "AA" // as coming from the keyletter + val ba = byteArrayOf(0xAA.toByte()) // as coming from the database + + + assertTrue(BigInteger(1, ba).equals(HEX_STRING.toBigInteger(16))) + } +} +\ No newline at end of file