@@ -196,6 +196,14 @@ describe('TokensService', () => {
196196 ) ;
197197 } ;
198198
199+ const mockECONNErrors = ( count : number ) => {
200+ for ( let i = 0 ; i < count ; i ++ ) {
201+ http . post . mockImplementationOnce ( ( ) => {
202+ throw new Error ( 'connect ECONNREFUSED 10.1.2.3' ) ;
203+ } ) ;
204+ }
205+ } ;
206+
199207 beforeEach ( async ( ) => {
200208 http = {
201209 get : jest . fn ( ) ,
@@ -234,8 +242,8 @@ describe('TokensService', () => {
234242
235243 let blockchainRetryCfg : RetryConfiguration = {
236244 retryBackOffFactor : 2 ,
237- retryBackOffLimit : 10000 ,
238- retryBackOffInitial : 100 ,
245+ retryBackOffLimit : 500 ,
246+ retryBackOffInitial : 50 ,
239247 retryCondition : '.*ECONN.*' ,
240248 retriesMax : 15 ,
241249 } ;
@@ -1050,6 +1058,49 @@ describe('TokensService', () => {
10501058 expect ( http . post ) . toHaveBeenCalledWith ( BASE_URL , mockEthConnectRequest , { headers } ) ;
10511059 } ) ;
10521060
1061+ it ( 'should mint ERC721WithData token with correct abi, custom uri, and inputs after 6 ECONNREFUSED retries' , async ( ) => {
1062+ const ctx = newContext ( ) ;
1063+ const headers = {
1064+ 'x-firefly-request-id' : ctx . requestId ,
1065+ } ;
1066+
1067+ const request : TokenMint = {
1068+ tokenIndex : '721' ,
1069+ signer : IDENTITY ,
1070+ poolLocator : ERC721_WITH_DATA_V1_POOL_ID ,
1071+ to : '0x123' ,
1072+ uri : 'ipfs://CID' ,
1073+ } ;
1074+
1075+ const response : EthConnectAsyncResponse = {
1076+ id : 'responseId' ,
1077+ sent : true ,
1078+ } ;
1079+
1080+ const mockEthConnectRequest : EthConnectMsgRequest = {
1081+ headers : {
1082+ type : 'SendTransaction' ,
1083+ } ,
1084+ from : IDENTITY ,
1085+ to : CONTRACT_ADDRESS ,
1086+ method : ERC721WithDataV1ABI . abi . find ( abi => abi . name === MINT_WITH_URI ) as IAbiMethod ,
1087+ params : [ '0x123' , '721' , '0x00' , 'ipfs://CID' ] ,
1088+ } ;
1089+
1090+ http . post . mockReturnValueOnce (
1091+ new FakeObservable ( < EthConnectReturn > {
1092+ output : true ,
1093+ } ) ,
1094+ ) ;
1095+ mockECONNErrors ( 6 ) ;
1096+ http . post . mockReturnValueOnce ( new FakeObservable ( response ) ) ;
1097+
1098+ await service . mint ( ctx , request ) ;
1099+
1100+ expect ( http . post ) . toHaveBeenCalledWith ( BASE_URL , mockEthConnectRequest , { headers } ) ;
1101+ expect ( http . post ) . toHaveBeenCalledTimes ( 8 ) ; // Expect initial submit OK, 6 ECONN errors, final call OK = 8 POSTs
1102+ } ) ;
1103+
10531104 it ( 'should mint ERC721WithData token with correct abi, custom uri, auto-indexing, and inputs' , async ( ) => {
10541105 const ctx = newContext ( ) ;
10551106 const headers = {
0 commit comments