Skip to content

Commit

Permalink
add test for checkEncode
Browse files Browse the repository at this point in the history
  • Loading branch information
fluency03 committed May 6, 2018
1 parent 20d337d commit ac4a9fe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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))


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

}

}

0 comments on commit ac4a9fe

Please sign in to comment.