@@ -54,4 +54,41 @@ describe('types', () => {
54
54
} ) ;
55
55
} ) ;
56
56
} ) ;
57
+
58
+ describe ( 'UInt31' , ( ) => {
59
+ const UINT31_MAX = Math . pow ( 2 , 31 ) - 1 ;
60
+ it ( 'return true for valid values' , ( ) => {
61
+ assert . strictEqual ( types . UInt31 ( 0 ) , true ) ;
62
+ assert . strictEqual ( types . UInt31 ( 1000 ) , true ) ;
63
+ assert . strictEqual ( types . UInt31 ( UINT31_MAX ) , true ) ;
64
+ } ) ;
65
+
66
+ it ( 'return false for negative values' , ( ) => {
67
+ assert . strictEqual ( types . UInt31 ( - 1 ) , false ) ;
68
+ assert . strictEqual ( types . UInt31 ( - UINT31_MAX ) , false ) ;
69
+ } ) ;
70
+
71
+ it ( 'return false for values > UINT31_MAX' , ( ) => {
72
+ assert . strictEqual ( types . UInt31 ( UINT31_MAX + 1 ) , false ) ;
73
+ } ) ;
74
+ } ) ;
75
+
76
+ describe ( 'BIP32Path' , ( ) => {
77
+ it ( 'return true for valid paths' , ( ) => {
78
+ assert . strictEqual ( types . BIP32Path ( "m/0'/0'" ) , true ) ;
79
+ assert . strictEqual ( types . BIP32Path ( "m/0'/0" ) , true ) ;
80
+ assert . strictEqual ( types . BIP32Path ( "m/0'/1'/2'/3/4'" ) , true ) ;
81
+ } ) ;
82
+
83
+ it ( 'return false for invalid paths' , ( ) => {
84
+ assert . strictEqual ( types . BIP32Path ( 'm' ) , false ) ;
85
+ assert . strictEqual ( types . BIP32Path ( "n/0'/0'" ) , false ) ;
86
+ assert . strictEqual ( types . BIP32Path ( "m/0'/x" ) , false ) ;
87
+ } ) ;
88
+
89
+ it ( 'return "BIP32 derivation path" for JSON.strigify()' , ( ) => {
90
+ const toJsonValue = JSON . stringify ( types . BIP32Path ) ;
91
+ assert . equal ( toJsonValue , '"BIP32 derivation path"' ) ;
92
+ } ) ;
93
+ } ) ;
57
94
} ) ;
0 commit comments