@@ -34,6 +34,12 @@ const nearCurrency: RequestLogicTypes.ICurrency = {
3434 value : 'near' ,
3535} ;
3636
37+ const ethCurrency : RequestLogicTypes . ICurrency = {
38+ type : RequestLogicTypes . CURRENCY . ETH ,
39+ network : 'mainnet' ,
40+ value : 'ETH' ,
41+ } ;
42+
3743describe ( 'payRequest' , ( ) => {
3844 afterEach ( ( ) => {
3945 jest . resetAllMocks ( ) ;
@@ -516,7 +522,7 @@ describe('hasSufficientFunds', () => {
516522 expect ( solvency ) . toBeFalsy ( ) ;
517523 } ) ;
518524
519- it ( 'should skip ETH balance checks when needsGas is false' , async ( ) => {
525+ it ( 'should skip ETH balance checks when needsGas is false - ERC20 payment ' , async ( ) => {
520526 const mock = jest
521527 . spyOn ( erc20Module , 'getAnyErc20Balance' )
522528 . mockReturnValue ( Promise . resolve ( BigNumber . from ( '200' ) ) ) ;
@@ -534,6 +540,34 @@ describe('hasSufficientFunds', () => {
534540 expect ( mock ) . toHaveBeenCalledTimes ( 1 ) ;
535541 } ) ;
536542
543+ it ( 'should require only the given ETH amount when needsGas is false - ETH payment' , async ( ) => {
544+ // eslint-disable-next-line no-magic-numbers
545+ const solvency = await isSolvent ( {
546+ fromAddress : 'any' ,
547+ currency : ethCurrency ,
548+ amount : 200 ,
549+ providerOptions : {
550+ provider : fakeProvider as any ,
551+ } ,
552+ needsGas : false ,
553+ } ) ;
554+ expect ( solvency ) . toBeTruthy ( ) ;
555+ } ) ;
556+
557+ it ( 'should require an excess of ETH when needsGas is true - ETH payment' , async ( ) => {
558+ // eslint-disable-next-line no-magic-numbers
559+ const solvency = await isSolvent ( {
560+ fromAddress : 'any' ,
561+ currency : ethCurrency ,
562+ amount : 200 ,
563+ providerOptions : {
564+ provider : fakeProvider as any ,
565+ } ,
566+ needsGas : true ,
567+ } ) ;
568+ expect ( solvency ) . toBeFalsy ( ) ;
569+ } ) ;
570+
537571 it ( 'should check ETH balance checks by default' , async ( ) => {
538572 const mock = jest
539573 . spyOn ( erc20Module , 'getAnyErc20Balance' )
0 commit comments