@@ -12,17 +12,18 @@ async function fixture() {
12
12
const CAIP2 = `eip155:${ chainId } ` ;
13
13
const asCAIP10 = account => `eip155:${ chainId } :${ getAddress ( account ) } ` ;
14
14
15
- const axelar = await ethers . deployContract ( '$AxelarGatewayMock' ) ;
16
- const srcGateway = await ethers . deployContract ( '$AxelarGatewaySource' , [ owner , axelar ] ) ;
17
- const dstGateway = await ethers . deployContract ( '$AxelarGatewayDestination' , [ owner , axelar , axelar ] ) ;
18
- const receiver = await ethers . deployContract ( '$ERC7786ReceiverMock' , [ dstGateway ] ) ;
15
+ const axelar = await ethers . deployContract ( '$AxelarGatewayMock' ) ;
16
+ const srcGateway = await ethers . deployContract ( '$AxelarGatewaySource' , [ owner , axelar ] ) ;
17
+ const dstGateway = await ethers . deployContract ( '$AxelarGatewayDestination' , [ owner , axelar , axelar ] ) ;
18
+ const receiver = await ethers . deployContract ( '$ERC7786ReceiverMock' , [ dstGateway ] ) ;
19
+ const invalidReceiver = await ethers . deployContract ( '$ERC7786ReceiverInvalidMock' ) ;
19
20
20
21
await srcGateway . registerChainEquivalence ( CAIP2 , 'local' ) ;
21
22
await dstGateway . registerChainEquivalence ( CAIP2 , 'local' ) ;
22
23
await srcGateway . registerRemoteGateway ( CAIP2 , getAddress ( dstGateway ) ) ;
23
24
await dstGateway . registerRemoteGateway ( CAIP2 , getAddress ( srcGateway ) ) ;
24
25
25
- return { owner, sender, accounts, CAIP2 , asCAIP10, axelar, srcGateway, dstGateway, receiver } ;
26
+ return { owner, sender, accounts, CAIP2 , asCAIP10, axelar, srcGateway, dstGateway, receiver, invalidReceiver } ;
26
27
}
27
28
28
29
describe ( 'AxelarGateway' , function ( ) {
@@ -31,13 +32,13 @@ describe('AxelarGateway', function () {
31
32
} ) ;
32
33
33
34
it ( 'initial setup' , async function ( ) {
34
- expect ( await this . srcGateway . localGateway ( ) ) . to . equal ( this . axelar ) ;
35
- expect ( await this . srcGateway . getEquivalentChain ( this . CAIP2 ) ) . to . equal ( 'local' ) ;
36
- expect ( await this . srcGateway . getRemoteGateway ( this . CAIP2 ) ) . to . equal ( getAddress ( this . dstGateway ) ) ;
35
+ expect ( this . srcGateway . localGateway ( ) ) . to . eventually . equal ( this . axelar ) ;
36
+ expect ( this . srcGateway . getEquivalentChain ( this . CAIP2 ) ) . to . eventually . equal ( 'local' ) ;
37
+ expect ( this . srcGateway . getRemoteGateway ( this . CAIP2 ) ) . to . eventually . equal ( getAddress ( this . dstGateway ) ) ;
37
38
38
- expect ( await this . dstGateway . localGateway ( ) ) . to . equal ( this . axelar ) ;
39
- expect ( await this . dstGateway . getEquivalentChain ( this . CAIP2 ) ) . to . equal ( 'local' ) ;
40
- expect ( await this . dstGateway . getRemoteGateway ( this . CAIP2 ) ) . to . equal ( getAddress ( this . srcGateway ) ) ;
39
+ expect ( this . dstGateway . localGateway ( ) ) . to . eventually . equal ( this . axelar ) ;
40
+ expect ( this . dstGateway . getEquivalentChain ( this . CAIP2 ) ) . to . eventually . equal ( 'local' ) ;
41
+ expect ( this . dstGateway . getRemoteGateway ( this . CAIP2 ) ) . to . eventually . equal ( getAddress ( this . srcGateway ) ) ;
41
42
} ) ;
42
43
43
44
describe ( 'Active mode' , function ( ) {
@@ -52,13 +53,32 @@ describe('AxelarGateway', function () {
52
53
const attributes = [ ] ;
53
54
const package = ethers . AbiCoder . defaultAbiCoder ( ) . encode ( [ 'string' , 'string' , 'bytes' , 'bytes[]' ] , [ getAddress ( this . sender ) , getAddress ( this . receiver ) , payload , attributes ] ) ;
54
55
55
- const tx = await this . srcGateway . connect ( this . sender ) . sendMessage ( this . CAIP2 , getAddress ( this . receiver ) , payload , attributes ) ;
56
- await expect ( tx )
56
+ await expect ( this . srcGateway . connect ( this . sender ) . sendMessage ( this . CAIP2 , getAddress ( this . receiver ) , payload , attributes ) )
57
57
. to . emit ( this . srcGateway , 'MessagePosted' ) . withArgs ( ethers . ZeroHash , srcCAIP10 , dstCAIP10 , payload , attributes )
58
58
. to . emit ( this . axelar , 'ContractCall' ) . withArgs ( this . srcGateway , 'local' , getAddress ( this . dstGateway ) , ethers . keccak256 ( package ) , package )
59
59
. to . emit ( this . axelar , 'ContractCallExecuted' ) . withArgs ( anyValue )
60
60
. to . emit ( this . receiver , 'MessageReceived' ) . withArgs ( ethers . ZeroAddress , this . CAIP2 , getAddress ( this . sender ) , payload , attributes ) ;
61
61
} ) ;
62
+
63
+ it ( 'invalid receiver - bad return value' , async function ( ) {
64
+ await expect ( this . srcGateway . connect ( this . sender ) . sendMessage (
65
+ this . CAIP2 ,
66
+ getAddress ( this . invalidReceiver ) ,
67
+ ethers . randomBytes ( 128 ) ,
68
+ [ ] ,
69
+ ) )
70
+ . to . be . revertedWith ( 'Receiver execution failed' ) ;
71
+ } ) ;
72
+
73
+ it ( 'invalid receiver - EOA' , async function ( ) {
74
+ await expect ( this . srcGateway . connect ( this . sender ) . sendMessage (
75
+ this . CAIP2 ,
76
+ getAddress ( this . accounts [ 0 ] ) ,
77
+ ethers . randomBytes ( 128 ) ,
78
+ [ ] ,
79
+ ) )
80
+ . to . be . revertedWithoutReason ( ) ;
81
+ } ) ;
62
82
} ) ;
63
83
64
84
describe ( 'Passive mode' , function ( ) {
0 commit comments