@@ -26,6 +26,7 @@ import {
2626 WalletWithKeychains ,
2727 multisigTypes ,
2828 IncorrectPasswordError ,
29+ NeedUserSignupError ,
2930} from '@bitgo/sdk-core' ;
3031import { BitGo } from '../../../src' ;
3132import { afterEach } from 'mocha' ;
@@ -2525,6 +2526,72 @@ describe('V2 Wallets:', function () {
25252526 }
25262527 } ) ;
25272528
2529+ it ( 'should throw NeedsUserSignup error if pubkey is missing' , async ( ) => {
2530+ const userId = '[email protected] ' ; 2531+ const permissions = [ 'view' , 'spend' ] ;
2532+ try {
2533+ await wallet . createBulkWalletShare ( {
2534+ walletPassphrase : 'Test' ,
2535+ keyShareOptions : [
2536+ {
2537+ userId : userId ,
2538+ permissions : permissions ,
2539+ path : 'm/999999/1/1' ,
2540+ } ,
2541+ ] ,
2542+ } as BulkWalletShareOptions ) ;
2543+ assert . fail ( 'Expected error not thrown' ) ;
2544+ } catch ( error ) {
2545+ assert ( error instanceof NeedUserSignupError ) ;
2546+ assert . strictEqual ( error . name , 'NeedUserSignupError' ) ;
2547+ assert . strictEqual ( error . message , userId ) ;
2548+ }
2549+ } ) ;
2550+
2551+ it ( 'should throw error if path is missing' , async ( ) => {
2552+ const userId = '[email protected] ' ; 2553+ const permissions = [ 'view' , 'spend' ] ;
2554+ try {
2555+ await wallet . createBulkWalletShare ( {
2556+ walletPassphrase : 'Test' ,
2557+ keyShareOptions : [
2558+ {
2559+ userId : userId ,
2560+ permissions : permissions ,
2561+ pubKey : 'm/999999/1/1' ,
2562+ } ,
2563+ ] ,
2564+ } as BulkWalletShareOptions ) ;
2565+ assert . fail ( 'Expected error not thrown' ) ;
2566+ } catch ( error ) {
2567+ assert . strictEqual ( error . name , 'Error' ) ;
2568+ assert . strictEqual ( error . message , 'Missing parameter: path' ) ;
2569+ }
2570+ } ) ;
2571+
2572+ it ( 'should throw NeedsUserSignup error if pubkey is empty string' , async ( ) => {
2573+ const userId = '[email protected] ' ; 2574+ const permissions = [ 'view' , 'spend' ] ;
2575+ try {
2576+ await wallet . createBulkWalletShare ( {
2577+ walletPassphrase : 'Test' ,
2578+ keyShareOptions : [
2579+ {
2580+ userId : userId ,
2581+ pubKey : '' ,
2582+ permissions : permissions ,
2583+ path : 'm/999999/1/1' ,
2584+ } ,
2585+ ] ,
2586+ } ) ;
2587+ assert . fail ( 'Expected error not thrown' ) ;
2588+ } catch ( error ) {
2589+ assert ( error instanceof NeedUserSignupError ) ;
2590+ assert . strictEqual ( error . name , 'NeedUserSignupError' ) ;
2591+ assert . strictEqual ( error . message , userId ) ;
2592+ }
2593+ } ) ;
2594+
25282595 it ( 'should correctly process share options and call createBulkKeyShares' , async ( ) => {
25292596 const userId = '[email protected] ' ; 25302597 const permissions = [ 'view' , 'spend' ] ;
0 commit comments