This repository was archived by the owner on Dec 21, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +16
-16
lines changed Expand file tree Collapse file tree 2 files changed +16
-16
lines changed Original file line number Diff line number Diff line change @@ -224,10 +224,6 @@ class EncryptionUtilBase {
224224 }
225225 }
226226
227- static validateGroupKey ( groupKey : any ) {
228- return GroupKey . validate ( groupKey )
229- }
230-
231227 /*
232228 * Returns a Buffer or a hex String
233229 */
Original file line number Diff line number Diff line change @@ -163,20 +163,24 @@ function TestEncryptionUtil({ isBrowser = false } = {}) {
163163 } )
164164 } )
165165
166- it ( 'validateGroupKey() throws if key is the wrong size' , ( ) => {
167- expect ( ( ) => {
168- EncryptionUtil . validateGroupKey ( crypto . randomBytes ( 16 ) )
169- } ) . toThrow ( )
170- } )
166+ describe ( 'GroupKey.validate' , ( ) => {
167+ it ( 'throws if key is the wrong size' , ( ) => {
168+ expect ( ( ) => {
169+ GroupKey . validate ( GroupKey . from ( [ 'test' , crypto . randomBytes ( 16 ) ] ) )
170+ } ) . toThrow ( 'size' )
171+ } )
171172
172- it ( 'validateGroupKey() throws if key is not a buffer' , ( ) => {
173- expect ( ( ) => {
174- EncryptionUtil . validateGroupKey ( ethers . utils . hexlify ( GroupKey . generate ( ) as any ) )
175- } ) . toThrow ( )
176- } )
173+ it ( 'throws if key is not a buffer' , ( ) => {
174+ expect ( ( ) => {
175+ // expected error below is desirable, show typecheks working as intended
176+ // @ts -expect-error
177+ GroupKey . validate ( GroupKey . from ( [ 'test' , Array . from ( crypto . randomBytes ( 32 ) ) ] ) )
178+ } ) . toThrow ( 'Buffer' )
179+ } )
177180
178- it ( 'validateGroupKey() does not throw' , ( ) => {
179- EncryptionUtil . validateGroupKey ( GroupKey . generate ( ) )
181+ it ( 'does not throw with valid values' , ( ) => {
182+ GroupKey . validate ( GroupKey . generate ( ) )
183+ } )
180184 } )
181185 } )
182186}
You can’t perform that action at this time.
0 commit comments