@@ -10,6 +10,7 @@ import { ethers } from 'hardhat';
1010import { IexecInterfaceNative , IexecInterfaceNative__factory } from '../../../typechain' ;
1111import config from '../../../utils/config' ;
1212import { getIexecAccounts } from '../../../utils/poco-tools' ;
13+ import { getPocoStorageSlotLocation } from '../../../utils/proxy-tools' ;
1314import { loadHardhatFixtureDeployment } from '../../utils/hardhat-fixture-deployer' ;
1415import { setZeroAddressBalance } from '../../utils/utils' ;
1516
@@ -75,7 +76,6 @@ if (config.isNativeChain()) {
7576 } ) ;
7677 } ) ;
7778
78- // TODO 'Should deposit with zero value'
7979 describe ( 'Deposit' , ( ) => {
8080 it ( 'Should deposit native tokens' , async ( ) => {
8181 expect ( await iexecPocoAsAccountA . deposit . staticCall ( ...depositArgs ) ) . to . be . true ;
@@ -105,6 +105,16 @@ if (config.isNativeChain()) {
105105 . withArgs ( AddressZero , accountA . address , depositAmount ) ;
106106 } ) ;
107107
108+ it ( 'Should deposit amount zero' , async ( ) => {
109+ expect ( await iexecPocoAsAccountA . deposit . staticCall ( { value : 0 } ) ) . to . be . true ;
110+ const tx = iexecPocoAsAccountA . deposit ( { value : 0 } ) ;
111+ await expect ( tx ) . to . changeEtherBalances ( [ accountA , iexecPoco ] , [ 0 , 0 ] ) ;
112+ await expect ( tx ) . to . changeTokenBalances ( iexecPoco , [ accountA ] , [ 0 ] ) ;
113+ await expect ( tx )
114+ . to . emit ( iexecPoco , 'Transfer' )
115+ . withArgs ( AddressZero , accountA . address , 0 ) ;
116+ } ) ;
117+
108118 it ( 'Should not deposit native tokens when caller is address 0' , async ( ) => {
109119 const zeroAddressSigner = await ethers . getImpersonatedSigner ( ZeroAddress ) ;
110120 const iexecPocoAsAddress0 = iexecPoco . connect ( zeroAddressSigner ) ;
@@ -214,7 +224,6 @@ if (config.isNativeChain()) {
214224 } ) ;
215225 } ) ;
216226
217- // TODO 'Should withdraw with zero value'
218227 describe ( 'Withdraw' , ( ) => {
219228 it ( 'Should withdraw native tokens' , async ( ) => {
220229 await iexecPocoAsAccountA . deposit ( ...depositArgs ) ;
@@ -231,6 +240,19 @@ if (config.isNativeChain()) {
231240 . withArgs ( accountA . address , AddressZero , withdrawAmount ) ;
232241 } ) ;
233242
243+ it ( 'Should withdraw amount zero' , async ( ) => {
244+ await iexecPocoAsAccountA . deposit ( ...depositArgs ) ;
245+ expect ( await iexecPocoAsAccountA . withdraw . staticCall ( 0 ) ) . to . be . true ;
246+ const tx = iexecPocoAsAccountA . withdraw ( 0 ) ;
247+ await expect ( tx ) . to . changeEtherBalances ( [ accountA , iexecPoco ] , [ 0 , 0 ] ) ;
248+ await expect ( tx ) . to . changeTokenBalances ( iexecPoco , [ accountA ] , [ 0 ] ) ;
249+ await expect ( tx )
250+ . to . emit ( iexecPoco , 'Transfer' )
251+ . withArgs ( accountA . address , AddressZero , 0 ) ;
252+ // User balance haven't changed.
253+ expect ( await iexecPoco . balanceOf ( accountA . address ) ) . to . equal ( depositAmount ) ;
254+ } ) ;
255+
234256 it ( 'Should not withdraw native tokens with empty balance' , async ( ) => {
235257 await expect (
236258 iexecPocoAsAccountA . withdraw ( ...withdrawArg ) ,
@@ -291,7 +313,7 @@ if (config.isNativeChain()) {
291313 const expectedDelta = 5n ;
292314 await setStorageAt (
293315 proxyAddress ,
294- '0x07' , // Slot index of `m_totalSupply` in Store
316+ getPocoStorageSlotLocation ( 7n ) , // 7 is the slot index of `m_totalSupply` in Store
295317 ethers . toBeHex ( initTotalSupply - expectedDelta ) ,
296318 ) ;
297319 expect ( await iexecPoco . totalSupply ( ) ) . to . equal (
0 commit comments