@@ -14,10 +14,12 @@ import {
1414 MULTISIG_DELEGATION_PARAMS ,
1515 MPC_DELEGATION_UNSIGNED_TX_HEX ,
1616} from '../resources/transactionData/multisigDelegationTx' ;
17- import { HalfSignedAccountTransaction , TransactionType , MPCAlgorithm } from '@bitgo/sdk-core' ;
17+ import { HalfSignedAccountTransaction , TransactionType , MPCAlgorithm , common } from '@bitgo/sdk-core' ;
1818import { secp256k1 } from '@flarenetwork/flarejs' ;
1919import { FlrpContext } from '@bitgo/public-types' ;
2020import assert from 'assert' ;
21+ import nock from 'nock' ;
22+ import { CreatePairedWalletResponse } from '../../src/lib/iface' ;
2123
2224describe ( 'Flrp test cases' , function ( ) {
2325 const coinName = 'flrp' ;
@@ -1086,4 +1088,73 @@ describe('Flrp test cases', function () {
10861088 } ) ;
10871089 } ) ;
10881090 } ) ;
1091+
1092+ describe ( 'createPairedWallet' , function ( ) {
1093+ const walletId = 'abc123def456abc123def456abc123de' ;
1094+
1095+ afterEach ( function ( ) {
1096+ nock . cleanAll ( ) ;
1097+ } ) ;
1098+
1099+ it ( 'should POST to create-paired-wallet and return new wallet' , async function ( ) {
1100+ const bgUrl = common . Environments [ bitgo . getEnv ( ) ] . uri ;
1101+ const expectedResponse : CreatePairedWalletResponse = {
1102+ id : 'newwalletid000000000000000000001' ,
1103+ coin : 'tflr' ,
1104+ label : 'My FLR C Wallet' ,
1105+ keys : [ 'key1' , 'key2' , 'key3' ] ,
1106+ keySignatures : { backupPub : 'sig1' , bitgoPub : 'sig2' } ,
1107+ m : 2 ,
1108+ n : 3 ,
1109+ type : 'hot' ,
1110+ multisigType : 'tss' ,
1111+ coinSpecific : {
1112+ pairedWalletId : walletId ,
1113+ baseAddress : '0x627306090abaB3A6e1400e9345bC60c78a8BEf57' ,
1114+ } ,
1115+ } ;
1116+
1117+ nock ( bgUrl )
1118+ . post ( `/api/v2/tflrp/wallet/${ walletId } /create-paired-wallet` , { label : 'My FLR C Wallet' } )
1119+ . reply ( 200 , expectedResponse ) ;
1120+
1121+ const result = await basecoin . createPairedWallet ( { walletId, label : 'My FLR C Wallet' } ) ;
1122+ result . should . deepEqual ( expectedResponse ) ;
1123+ result . coin . should . equal ( 'tflr' ) ;
1124+ result . coinSpecific . pairedWalletId . should . equal ( walletId ) ;
1125+ } ) ;
1126+
1127+ it ( 'should POST without body when label is not provided' , async function ( ) {
1128+ const bgUrl = common . Environments [ bitgo . getEnv ( ) ] . uri ;
1129+ const expectedResponse : CreatePairedWalletResponse = {
1130+ id : 'newwalletid000000000000000000002' ,
1131+ coin : 'tflr' ,
1132+ label : 'FLR C wallet (from tflrp wallet abc123def456abc123def456abc123de)' ,
1133+ keys : [ 'key1' , 'key2' , 'key3' ] ,
1134+ keySignatures : { } ,
1135+ m : 2 ,
1136+ n : 3 ,
1137+ type : 'hot' ,
1138+ multisigType : 'tss' ,
1139+ coinSpecific : { pairedWalletId : walletId } ,
1140+ } ;
1141+
1142+ nock ( bgUrl ) . post ( `/api/v2/tflrp/wallet/${ walletId } /create-paired-wallet` , { } ) . reply ( 200 , expectedResponse ) ;
1143+
1144+ const result = await basecoin . createPairedWallet ( { walletId } ) ;
1145+ result . should . deepEqual ( expectedResponse ) ;
1146+ } ) ;
1147+
1148+ it ( 'should propagate HTTP errors from the server' , async function ( ) {
1149+ const bgUrl = common . Environments [ bitgo . getEnv ( ) ] . uri ;
1150+
1151+ nock ( bgUrl )
1152+ . post ( `/api/v2/tflrp/wallet/${ walletId } /create-paired-wallet` )
1153+ . reply ( 400 , { error : 'Source FLR P wallet is not MPC (multisigType: onchain)' } ) ;
1154+
1155+ await basecoin
1156+ . createPairedWallet ( { walletId } )
1157+ . should . be . rejectedWith ( 'Source FLR P wallet is not MPC (multisigType: onchain)' ) ;
1158+ } ) ;
1159+ } ) ;
10891160} ) ;
0 commit comments