@@ -19,12 +19,13 @@ contract("Bridge - [admin]", async (accounts) => {
19
19
const nonAdminAddress = accounts [ 1 ] ;
20
20
21
21
const expectedBridgeAdmin = accounts [ 0 ] ;
22
+ const authorizedAddress = accounts [ 2 ] ;
22
23
const someAddress = "0xcafecafecafecafecafecafecafecafecafecafe" ;
23
24
const nullAddress = "0x0000000000000000000000000000000000000000" ;
24
25
const topologyHash = "549f715f5b06809ada23145c2dc548db" ;
25
26
const txHash =
26
27
"0x59d881e01ca682130e550e3576b6de760951fb45b1d5dd81342132f57920bbfa" ;
27
-
28
+ const depositAmount = 10 ;
28
29
const bytes32 = "0x0" ;
29
30
const emptySetResourceData = "0x" ;
30
31
@@ -404,6 +405,45 @@ contract("Bridge - [admin]", async (accounts) => {
404
405
)
405
406
} ) ;
406
407
408
+ it ( "Should allow to withdraw funds if called by authorized address" , async ( ) => {
409
+ const tokenOwner = accounts [ 0 ] ;
410
+ const ERC20HandlerInstance = await ERC20HandlerContract . new (
411
+ BridgeInstance . address
412
+ ) ;
413
+ const ERC20MintableInstance = await ERC20MintableContract . new (
414
+ "token" ,
415
+ "TOK"
416
+ ) ;
417
+ await ERC20MintableInstance . mint ( ERC20HandlerInstance . address , depositAmount )
418
+
419
+ expect ( await ERC20HandlerInstance . hasRole (
420
+ await ERC20HandlerInstance . LIQUIDITY_MANAGER_ROLE ( ) ,
421
+ tokenOwner
422
+ ) ) . to . be . equal ( false ) ;
423
+
424
+ await ERC20HandlerInstance . grantRole (
425
+ await ERC20HandlerInstance . LIQUIDITY_MANAGER_ROLE ( ) ,
426
+ authorizedAddress ,
427
+ {
428
+ from : tokenOwner
429
+ }
430
+ ) ;
431
+
432
+ const recipientBalanceBefore = await ERC20MintableInstance . balanceOf ( tokenOwner ) ;
433
+ const withdrawData = Helpers . createERCWithdrawData (
434
+ ERC20MintableInstance . address ,
435
+ tokenOwner ,
436
+ depositAmount ,
437
+ ) ;
438
+
439
+ await TruffleAssert . passes ( ERC20HandlerInstance . withdraw ( withdrawData , { from : authorizedAddress } ) ) ;
440
+ const recipientBalanceAfter = await ERC20MintableInstance . balanceOf ( tokenOwner ) ;
441
+
442
+ expect (
443
+ new Ethers . BigNumber . from ( depositAmount ) . add ( recipientBalanceBefore . toString ( ) ) . toString ( )
444
+ ) . to . be . equal ( recipientBalanceAfter . toString ( ) ) ;
445
+ } ) ;
446
+
407
447
// Set nonce
408
448
409
449
it ( "Should set nonce" , async ( ) => {
0 commit comments