8
8
Address ,
9
9
Arc ,
10
10
Plugin ,
11
- REDEEMER_CONTRACT_VERSIONS
11
+ REDEEMER_CONTRACT_VERSIONS ,
12
+ Token
12
13
} from '../src/index'
13
14
import {
14
15
fromWei ,
@@ -318,12 +319,22 @@ it('plugin contractInfo should contain alias', async () => {
318
319
expect ( contractInfo . alias ) . toEqual ( "ContributionRewardExt" )
319
320
} )
320
321
321
- it ( 'arc.approveToken should return tx with status one' , async ( ) => {
322
+ it . only ( 'arc.approveToken should return tx with status one' , async ( ) => {
322
323
const arc = await newArc ( )
323
324
const addresses = getTestAddresses ( )
324
325
const tokenAddress = addresses . dao . DAOToken
325
- const account = '0x90f8bf6a479f320ead074411a4b0e7944ea8c9c1'
326
- const approval = await arc . approveTokens ( tokenAddress , account , new BN ( 1 ) ) . send ( ) ;
326
+ const spender = '0x90f8bf6a479f320ead074411a4b0e7944ea8c9c1'
327
+ const amount = toWei ( '31415' )
328
+ const approval = await arc . approveTokens ( tokenAddress , spender , amount ) . send ( ) ;
327
329
expect ( approval . transactionHash ) . toBeDefined ( ) ;
328
330
expect ( approval . receipt ! . status ) . toEqual ( 1 ) ;
331
+ const token = new Token ( arc , tokenAddress ) ;
332
+ const signer = ( arc . web3 as JsonRpcProvider ) . getSigner ( arc . defaultAccount as any )
333
+ const allowances : Array < BN > = [ ]
334
+ const lastAllowance = ( ) => allowances [ allowances . length - 1 ]
335
+ await token . allowance ( await signer . getAddress ( ) , spender ) . subscribe (
336
+ ( next : any ) => allowances . push ( next )
337
+ )
338
+ await waitUntilTrue ( ( ) => allowances . length > 0 && lastAllowance ( ) . gte ( amount ) )
339
+ expect ( lastAllowance ( ) ) . toMatchObject ( amount )
329
340
} )
0 commit comments