From ac4a9fe8ba82201a59050ed9123a55fc2d5db61d Mon Sep 17 00:00:00 2001 From: fluency03 Date: Sun, 6 May 2018 15:52:26 +0200 Subject: [PATCH] add test for checkEncode --- .../com/github/fluency03/blockchain/crypto/Base58.scala | 2 -- .../com/github/fluency03/blockchain/crypto/Base58Test.scala | 6 ++++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com/github/fluency03/blockchain/crypto/Base58.scala b/src/main/scala/com/github/fluency03/blockchain/crypto/Base58.scala index 945851e..2b2278d 100644 --- a/src/main/scala/com/github/fluency03/blockchain/crypto/Base58.scala +++ b/src/main/scala/com/github/fluency03/blockchain/crypto/Base58.scala @@ -43,8 +43,6 @@ object Base58 { def decodeToHex(str: String): String = new String(decode(str)) - def checkEncodeHex(str: String): String = encodeString(str + str.hex2Bytes.toSha256Digest.toSha256.substring(0, 8)) - def checkEncode(bytes: Bytes): String = encode(bytes ++ bytes.toSha256Digest.toSha256Digest.slice(0, 4)) diff --git a/src/test/scala/com/github/fluency03/blockchain/crypto/Base58Test.scala b/src/test/scala/com/github/fluency03/blockchain/crypto/Base58Test.scala index c66a509..6d8c369 100644 --- a/src/test/scala/com/github/fluency03/blockchain/crypto/Base58Test.scala +++ b/src/test/scala/com/github/fluency03/blockchain/crypto/Base58Test.scala @@ -32,6 +32,12 @@ class Base58Test extends FlatSpec with Matchers { Base58.encodeHex("00A6020CF86FECEDEEF8859C172BAA1A15A575BC6F27D7CF19") shouldEqual "1G8mdKwihfYAxeb2E7XwtE94myognJxibS" + Base58.checkEncode("00A6020CF86FECEDEEF8859C172BAA1A15A575BC6F".hex2Bytes) shouldEqual + "1G8mdKwihfYAxeb2E7XwtE94myognJxibS" + + Base58.checkEncode("009568D21EB9B6AAB3F77DBA0650930985EFDE6AE8".hex2Bytes) shouldEqual + "1Ed1FfBXKH6eDQa3p7LyaxvxJamHH2HvCQ" + } }