@@ -249,6 +249,87 @@ describe('ERC20Base', function () {
249249 } ) ;
250250 } ) ;
251251
252+ describe ( '#_decreaseAllowance(address,address,uint256)' , function ( ) {
253+ it ( 'reduces approval of spender with respect to holder by given amount' , async function ( ) {
254+ await instance . __approve (
255+ holder . address ,
256+ spender . address ,
257+ ethers . constants . Two ,
258+ ) ;
259+
260+ await instance
261+ . connect ( holder )
262+ . __decreaseAllowance (
263+ holder . address ,
264+ spender . address ,
265+ ethers . constants . One ,
266+ ) ;
267+
268+ await expect (
269+ await instance . callStatic [ 'allowance(address,address)' ] (
270+ holder . address ,
271+ spender . address ,
272+ ) ,
273+ ) . to . equal ( ethers . constants . One ) ;
274+
275+ // decreases are cumulative
276+ await instance
277+ . connect ( holder )
278+ . __decreaseAllowance (
279+ holder . address ,
280+ spender . address ,
281+ ethers . constants . One ,
282+ ) ;
283+
284+ await expect (
285+ await instance . callStatic [ 'allowance(address,address)' ] (
286+ holder . address ,
287+ spender . address ,
288+ ) ,
289+ ) . to . equal ( ethers . constants . Zero ) ;
290+ } ) ;
291+
292+ it ( 'emits Approval event' , async function ( ) {
293+ await instance . __approve (
294+ holder . address ,
295+ spender . address ,
296+ ethers . constants . Two ,
297+ ) ;
298+
299+ await expect (
300+ instance . __decreaseAllowance (
301+ holder . address ,
302+ spender . address ,
303+ ethers . constants . One ,
304+ ) ,
305+ )
306+ . to . emit ( instance , 'Approval' )
307+ . withArgs ( holder . address , spender . address , ethers . constants . One ) ;
308+ } ) ;
309+
310+ describe ( 'reverts if' , function ( ) {
311+ it ( 'holder is the zero address' , async function ( ) {
312+ await expect (
313+ instance . __decreaseAllowance (
314+ ethers . constants . AddressZero ,
315+ spender . address ,
316+ ethers . constants . Zero ,
317+ ) ,
318+ ) . to . be . revertedWith ( 'ERC20: approve from the zero address' ) ;
319+ } ) ;
320+
321+ it ( 'spender is the zero address' , async function ( ) {
322+ await expect (
323+ instance . __decreaseAllowance (
324+ holder . address ,
325+ ethers . constants . AddressZero ,
326+ ethers . constants . Zero ,
327+ ) ,
328+ ) . to . be . revertedWith ( 'ERC20: approve to the zero address' ) ;
329+ } ) ;
330+ } ) ;
331+ } ) ;
332+
252333 describe ( '#_beforeTokenTransfer(address,address,uint256)' , function ( ) {
253334 it ( 'todo' ) ;
254335 } ) ;
0 commit comments