@@ -34,6 +34,12 @@ const nearCurrency: RequestLogicTypes.ICurrency = {
34
34
value : 'near' ,
35
35
} ;
36
36
37
+ const ethCurrency : RequestLogicTypes . ICurrency = {
38
+ type : RequestLogicTypes . CURRENCY . ETH ,
39
+ network : 'mainnet' ,
40
+ value : 'ETH' ,
41
+ } ;
42
+
37
43
describe ( 'payRequest' , ( ) => {
38
44
afterEach ( ( ) => {
39
45
jest . resetAllMocks ( ) ;
@@ -516,7 +522,7 @@ describe('hasSufficientFunds', () => {
516
522
expect ( solvency ) . toBeFalsy ( ) ;
517
523
} ) ;
518
524
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 ( ) => {
520
526
const mock = jest
521
527
. spyOn ( erc20Module , 'getAnyErc20Balance' )
522
528
. mockReturnValue ( Promise . resolve ( BigNumber . from ( '200' ) ) ) ;
@@ -534,6 +540,34 @@ describe('hasSufficientFunds', () => {
534
540
expect ( mock ) . toHaveBeenCalledTimes ( 1 ) ;
535
541
} ) ;
536
542
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
+
537
571
it ( 'should check ETH balance checks by default' , async ( ) => {
538
572
const mock = jest
539
573
. spyOn ( erc20Module , 'getAnyErc20Balance' )
0 commit comments