@@ -13,7 +13,7 @@ describe('Base58', function () {
13
13
} ) ;
14
14
15
15
describe ( 'base58' , function ( ) {
16
- describe ( 'encode/decode' , function ( ) {
16
+ describe ( 'encode/decode random buffers ' , function ( ) {
17
17
// length 512 runs out of gas.
18
18
// this checks are very slow when running coverage, causing CI to timeout.
19
19
for ( const length of [ 0 , 1 , 2 , 3 , 4 , 32 , 42 , 128 , 384 ] )
@@ -30,6 +30,24 @@ describe('Base58', function () {
30
30
) ;
31
31
} ) ;
32
32
33
+ describe ( 'test vectors' , function ( ) {
34
+ for ( const { raw, b58 } of [
35
+ { raw : 'Hello World!' , b58 : '2NEpo7TZRRrLZSi2U' } ,
36
+ {
37
+ raw : 'The quick brown fox jumps over the lazy dog.' ,
38
+ b58 : 'USm3fpXnKG5EUBx2ndxBDMPVciP5hGey2Jh4NDv6gmeo1LkMeiKrLJUUBk6Z' ,
39
+ } ,
40
+ { raw : '0x0000287fb4cd' , b58 : '11233QC4' } ,
41
+ ] )
42
+ it ( raw , async function ( ) {
43
+ const buffer = ( ethers . isHexString ( raw ) ? ethers . getBytes : ethers . toUtf8Bytes ) ( raw ) ;
44
+ const hex = ethers . hexlify ( buffer ) ;
45
+
46
+ await expect ( this . mock . $encode ( hex ) ) . to . eventually . equal ( b58 ) ;
47
+ await expect ( this . mock . $decode ( b58 ) ) . to . eventually . equal ( hex ) ;
48
+ } ) ;
49
+ } ) ;
50
+
33
51
describe ( 'decode invalid format' , function ( ) {
34
52
for ( const chr of [ 'I' , '-' , '~' ] )
35
53
it ( `Invalid base58 char ${ chr } ` , async function ( ) {
0 commit comments