@@ -1134,38 +1134,50 @@ describe('ALGO:', function () {
11341134 const { key } = algoBackupKey ;
11351135 const walletPassphrase = 'ZQ8MhxT84m4P' ;
11361136
1137- it ( 'should return { isValid: true) } for valid inputs' , async ( ) => {
1138- const result = await basecoin . auditKey ( {
1137+ it ( 'should return for valid inputs' , ( ) => {
1138+ basecoin . assertIsValidKey ( {
11391139 encryptedPrv : key ,
11401140 walletPassphrase,
11411141 } ) ;
1142- result . should . deepEqual ( { isValid : true } ) ;
11431142 } ) ;
11441143
1145- it ( 'should return { isValid: false } if the walletPassphrase is incorrect' , async ( ) => {
1146- const result = await basecoin . auditKey ( {
1147- encryptedPrv : key ,
1148- walletPassphrase : 'foo' ,
1149- } ) ;
1150- result . should . deepEqual ( { isValid : false , message : "failed to decrypt prv: ccm: tag doesn't match" } ) ;
1144+ it ( 'should throw error if the walletPassphrase is incorrect' , ( ) => {
1145+ assert . throws (
1146+ ( ) => {
1147+ basecoin . assertIsValidKey ( {
1148+ encryptedPrv : key ,
1149+ walletPassphrase : 'foo' ,
1150+ } ) ;
1151+ } ,
1152+ { message : "failed to decrypt prv: ccm: tag doesn't match" }
1153+ ) ;
11511154 } ) ;
1152- it ( 'should return { isValid: false } if the key is altered' , async ( ) => {
1155+
1156+ it ( 'should throw error if the key is altered' , ( ) => {
11531157 const alteredKey = key . replace ( / [ 0 - 9 ] / g, '0' ) ;
1154- const result = await basecoin . auditKey ( {
1155- encryptedPrv : alteredKey ,
1156- walletPassphrase,
1157- } ) ;
1158- result . isValid . should . equal ( false ) ;
1158+ assert . throws (
1159+ ( ) => {
1160+ basecoin . assertIsValidKey ( {
1161+ encryptedPrv : alteredKey ,
1162+ walletPassphrase,
1163+ } ) ;
1164+ } ,
1165+ { message : 'failed to decrypt prv: json decrypt: invalid parameters' }
1166+ ) ;
11591167 } ) ;
11601168
1161- it ( 'should return { isValid: false } if the key is not a valid key' , async ( ) => {
1169+ it ( 'should throw error if the key is not a valid key' , ( ) => {
11621170 const invalidKey = '#@)$#($*@)#($*' ;
11631171 const encryptedPrv = encrypt ( walletPassphrase , invalidKey ) ;
1164- const result = await basecoin . auditKey ( {
1165- encryptedPrv,
1166- walletPassphrase,
1167- } ) ;
1168- result . should . deepEqual ( { isValid : false , message : 'Invalid private key' } ) ;
1172+ assert . throws (
1173+ ( ) => {
1174+ basecoin . assertIsValidKey ( {
1175+ encryptedPrv,
1176+ walletPassphrase,
1177+ } ) ;
1178+ } ,
1179+ { message : 'Invalid private key' }
1180+ ) ;
11691181 } ) ;
11701182 } ) ;
11711183} ) ;
0 commit comments