@ -23,13 +23,13 @@ describe('Address', function () {
describe ( 'sendValue' , function ( ) {
describe ( 'sendValue' , function ( ) {
describe ( 'when sender contract has no funds' , function ( ) {
describe ( 'when sender contract has no funds' , function ( ) {
it ( 'sends 0 wei' , async function ( ) {
it ( 'sends 0 wei' , async function ( ) {
await expect ( this . mock . $sendValue ( this . other , 0 ) ) . to . changeEtherBalance ( this . recipient , 0 ) ;
await expect ( this . mock . $sendValue ( this . other , 0 n ) ) . to . changeEtherBalance ( this . recipient , 0 n ) ;
} ) ;
} ) ;
it ( 'reverts when sending non-zero amounts' , async function ( ) {
it ( 'reverts when sending non-zero amounts' , async function ( ) {
await expect ( this . mock . $sendValue ( this . other , 1 ) )
await expect ( this . mock . $sendValue ( this . other , 1 n ) )
. to . be . revertedWithCustomError ( this . mock , 'Address InsufficientBalance' )
. to . be . revertedWithCustomError ( this . mock , 'InsufficientBalance' )
. withArgs ( this . mock ) ;
. withArgs ( 0 n , 1 n ) ;
} ) ;
} ) ;
} ) ;
} ) ;
@ -42,7 +42,7 @@ describe('Address', function () {
describe ( 'with EOA recipient' , function ( ) {
describe ( 'with EOA recipient' , function ( ) {
it ( 'sends 0 wei' , async function ( ) {
it ( 'sends 0 wei' , async function ( ) {
await expect ( this . mock . $sendValue ( this . recipient , 0 ) ) . to . changeEtherBalance ( this . recipient , 0 ) ;
await expect ( this . mock . $sendValue ( this . recipient , 0 n ) ) . to . changeEtherBalance ( this . recipient , 0 n ) ;
} ) ;
} ) ;
it ( 'sends non-zero amounts' , async function ( ) {
it ( 'sends non-zero amounts' , async function ( ) {
@ -59,8 +59,8 @@ describe('Address', function () {
it ( 'reverts when sending more than the balance' , async function ( ) {
it ( 'reverts when sending more than the balance' , async function ( ) {
await expect ( this . mock . $sendValue ( this . recipient , funds + 1 n ) )
await expect ( this . mock . $sendValue ( this . recipient , funds + 1 n ) )
. to . be . revertedWithCustomError ( this . mock , 'Address InsufficientBalance' )
. to . be . revertedWithCustomError ( this . mock , 'InsufficientBalance' )
. withArgs ( this . mock ) ;
. withArgs ( funds , funds + 1 n ) ;
} ) ;
} ) ;
} ) ;
} ) ;
@ -74,7 +74,7 @@ describe('Address', function () {
await this . targetEther . setAcceptEther ( false ) ;
await this . targetEther . setAcceptEther ( false ) ;
await expect ( this . mock . $sendValue ( this . targetEther , funds ) ) . to . be . revertedWithCustomError (
await expect ( this . mock . $sendValue ( this . targetEther , funds ) ) . to . be . revertedWithCustomError (
this . mock ,
this . mock ,
'FailedInner Call' ,
'FailedCall' ,
) ;
) ;
} ) ;
} ) ;
} ) ;
} ) ;
@ -101,10 +101,7 @@ describe('Address', function () {
it ( 'reverts when the called function reverts with no reason' , async function ( ) {
it ( 'reverts when the called function reverts with no reason' , async function ( ) {
const call = this . target . interface . encodeFunctionData ( 'mockFunctionRevertsNoReason' ) ;
const call = this . target . interface . encodeFunctionData ( 'mockFunctionRevertsNoReason' ) ;
await expect ( this . mock . $functionCall ( this . target , call ) ) . to . be . revertedWithCustomError (
await expect ( this . mock . $functionCall ( this . target , call ) ) . to . be . revertedWithCustomError ( this . mock , 'FailedCall' ) ;
this . mock ,
'FailedInnerCall' ,
) ;
} ) ;
} ) ;
it ( 'reverts when the called function reverts, bubbling up the revert reason' , async function ( ) {
it ( 'reverts when the called function reverts, bubbling up the revert reason' , async function ( ) {
@ -118,7 +115,7 @@ describe('Address', function () {
await expect ( this . mock . $functionCall ( this . target , call , { gasLimit : 120_000 n } ) ) . to . be . revertedWithCustomError (
await expect ( this . mock . $functionCall ( this . target , call , { gasLimit : 120_000 n } ) ) . to . be . revertedWithCustomError (
this . mock ,
this . mock ,
'FailedInner Call' ,
'FailedCall' ,
) ;
) ;
} ) ;
} ) ;
@ -132,10 +129,7 @@ describe('Address', function () {
const interface = new ethers . Interface ( [ 'function mockFunctionDoesNotExist()' ] ) ;
const interface = new ethers . Interface ( [ 'function mockFunctionDoesNotExist()' ] ) ;
const call = interface . encodeFunctionData ( 'mockFunctionDoesNotExist' ) ;
const call = interface . encodeFunctionData ( 'mockFunctionDoesNotExist' ) ;
await expect ( this . mock . $functionCall ( this . target , call ) ) . to . be . revertedWithCustomError (
await expect ( this . mock . $functionCall ( this . target , call ) ) . to . be . revertedWithCustomError ( this . mock , 'FailedCall' ) ;
this . mock ,
'FailedInnerCall' ,
) ;
} ) ;
} ) ;
} ) ;
} ) ;
@ -155,7 +149,7 @@ describe('Address', function () {
it ( 'calls the requested function' , async function ( ) {
it ( 'calls the requested function' , async function ( ) {
const call = this . target . interface . encodeFunctionData ( 'mockFunction' ) ;
const call = this . target . interface . encodeFunctionData ( 'mockFunction' ) ;
await expect ( this . mock . $functionCallWithValue ( this . target , call , 0 ) )
await expect ( this . mock . $functionCallWithValue ( this . target , call , 0 n ) )
. to . emit ( this . target , 'MockFunctionCalled' )
. to . emit ( this . target , 'MockFunctionCalled' )
. to . emit ( this . mock , 'return$functionCallWithValue' )
. to . emit ( this . mock , 'return$functionCallWithValue' )
. withArgs ( coder . encode ( [ 'string' ] , [ '0x1234' ] ) ) ;
. withArgs ( coder . encode ( [ 'string' ] , [ '0x1234' ] ) ) ;
@ -169,8 +163,8 @@ describe('Address', function () {
const call = this . target . interface . encodeFunctionData ( 'mockFunction' ) ;
const call = this . target . interface . encodeFunctionData ( 'mockFunction' ) ;
await expect ( this . mock . $functionCallWithValue ( this . target , call , value ) )
await expect ( this . mock . $functionCallWithValue ( this . target , call , value ) )
. to . be . revertedWithCustomError ( this . mock , 'Address InsufficientBalance' )
. to . be . revertedWithCustomError ( this . mock , 'InsufficientBalance' )
. withArgs ( this . mock ) ;
. withArgs ( 0 n , value ) ;
} ) ;
} ) ;
it ( 'calls the requested function with existing value' , async function ( ) {
it ( 'calls the requested function with existing value' , async function ( ) {
@ -207,7 +201,7 @@ describe('Address', function () {
await expect ( this . mock . $functionCallWithValue ( this . target , call , value ) ) . to . be . revertedWithCustomError (
await expect ( this . mock . $functionCallWithValue ( this . target , call , value ) ) . to . be . revertedWithCustomError (
this . mock ,
this . mock ,
'FailedInner Call' ,
'FailedCall' ,
) ;
) ;
} ) ;
} ) ;
} ) ;
} ) ;
@ -225,7 +219,7 @@ describe('Address', function () {
await expect ( this . mock . $functionStaticCall ( this . target , call ) ) . to . be . revertedWithCustomError (
await expect ( this . mock . $functionStaticCall ( this . target , call ) ) . to . be . revertedWithCustomError (
this . mock ,
this . mock ,
'FailedInner Call' ,
'FailedCall' ,
) ;
) ;
} ) ;
} ) ;