@@ -1284,71 +1284,6 @@ describe('HappyTokenPool', () => {
12841284 } ) ;
12851285 } ) ;
12861286
1287- describe ( 'withdraw()' , async ( ) => {
1288- beforeEach ( async ( ) => {
1289- await testTokenADeployed . approve ( happyTokenPoolDeployed . address , new BigNumber ( '1e27' ) . toFixed ( ) ) ;
1290- } ) ;
1291-
1292- it ( 'Should emit WithdrawSuccess event and withdraw the specified token' , async ( ) => {
1293- const fakeTime = ( new Date ( ) . getTime ( ) + 1000 * 1000 ) / 1000 ;
1294- fpp . end_time = Math . ceil ( fakeTime ) - base_timestamp ;
1295- fpp . exchange_ratios = [ 1 , 75000 , 1 , 100 , 1 , 100 ] ;
1296- fpp . limit = BigNumber ( '50000e18' ) . toFixed ( ) ;
1297- fpp . total_tokens = BigNumber ( '50000e18' ) . toFixed ( ) ;
1298- const { id : pool_id } = await getResultFromPoolFill ( happyTokenPoolDeployed , fpp ) ;
1299-
1300- const exchange_ETH_amount = BigNumber ( '3e14' ) . toFixed ( ) ;
1301-
1302- const { verification, validation } = getVerification ( PASSWORD , signers [ 2 ] . address ) ;
1303- await happyTokenPoolDeployed
1304- . connect ( signers [ 2 ] )
1305- . swap ( pool_id , verification , ETH_address_index , exchange_ETH_amount , [ pool_id ] , {
1306- value : exchange_ETH_amount ,
1307- } ) ;
1308-
1309- const exchange_tokenB_amount = BigNumber ( '200e18' ) . toFixed ( ) ;
1310- await approveThenSwapToken (
1311- testTokenBDeployed ,
1312- signers [ 3 ] ,
1313- tokenB_address_index ,
1314- pool_id ,
1315- exchange_tokenB_amount ,
1316- ) ;
1317-
1318- // "none-pool owner" can not withdraw
1319- const account_not_creator = signers [ 4 ] ;
1320- await expect (
1321- happyTokenPoolDeployed . connect ( account_not_creator ) . withdraw ( pool_id , ETH_address_index ) ,
1322- ) . to . be . rejectedWith ( Error ) ;
1323-
1324- await helper . advanceTimeAndBlock ( 2000 * 1000 ) ;
1325- await happyTokenPoolDeployed . connect ( creator ) . withdraw ( pool_id , tokenB_address_index ) ;
1326- await happyTokenPoolDeployed . connect ( creator ) . withdraw ( pool_id , ETH_address_index ) ;
1327-
1328- // can not withdraw again
1329- expect ( happyTokenPoolDeployed . connect ( creator ) . withdraw ( pool_id , ETH_address_index ) ) . to . be . rejectedWith (
1330- Error ,
1331- ) ;
1332- expect ( happyTokenPoolDeployed . connect ( creator ) . withdraw ( pool_id , tokenB_address_index ) ) . to . be . rejectedWith (
1333- Error ,
1334- ) ;
1335-
1336- const latestBlock = await ethers . provider . getBlockNumber ( ) ;
1337- const filter = happyTokenPoolDeployed . filters . WithdrawSuccess ( ) ;
1338- filter . fromBlock = latestBlock - 2 ;
1339- filter . toBlock = latestBlock ;
1340- const logs = await ethers . provider . getLogs ( filter ) ;
1341-
1342- let parsedLog = itoInterface . parseLog ( logs [ 0 ] ) ;
1343- const logWithdrawTokenB = parsedLog . args ;
1344- parsedLog = itoInterface . parseLog ( logs [ 1 ] ) ;
1345- const logWithdrawETH = parsedLog . args ;
1346-
1347- expect ( logWithdrawTokenB . withdraw_balance . toString ( ) ) . that . to . be . eq ( BigNumber ( '200e18' ) . toFixed ( ) ) ;
1348- expect ( logWithdrawETH . withdraw_balance . toString ( ) ) . that . to . be . eq ( BigNumber ( '3e14' ) . toFixed ( ) ) ;
1349- } ) ;
1350- } ) ;
1351-
13521287 describe ( 'smart contract upgrade' , async ( ) => {
13531288 let pool_user ;
13541289 let verification ;
0 commit comments