1
1
#[ cfg( test) ]
2
2
mod test {
3
- use crate :: PythReceiver ;
4
- use alloy_primitives:: { address, Address , U256 } ;
3
+ use crate :: { PythReceiver , FeeSet , TransactionFeeSet , DataSourcesSet , GovernanceDataSourceSet } ;
4
+ use alloy_primitives:: { address, Address , U256 , FixedBytes } ;
5
5
use hex:: FromHex ;
6
6
use motsu:: prelude:: * ;
7
7
use wormhole_contract:: WormholeContract ;
@@ -100,6 +100,17 @@ mod test {
100
100
. execute_governance_instruction ( bytes. clone ( ) ) ;
101
101
assert ! ( result. is_ok( ) ) ;
102
102
103
+
104
+ let expected_event = DataSourcesSet {
105
+ old_data_sources : vec ! [ FixedBytes :: from( PYTHNET_EMITTER_ADDRESS ) ] ,
106
+ new_data_sources : vec ! [ FixedBytes :: from( [
107
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
108
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
109
+ 0x11 , 0x11
110
+ ] ) ] ,
111
+ } ;
112
+ assert ! ( pyth_contract. emitted( & expected_event) , "DataSourcesSet event should be emitted" ) ;
113
+
103
114
let result2 = pyth_contract
104
115
. sender ( alice)
105
116
. execute_governance_instruction ( bytes. clone ( ) ) ;
@@ -145,6 +156,13 @@ mod test {
145
156
146
157
assert ! ( result. is_ok( ) ) ;
147
158
159
+ let expected_new_fee = U256 :: from ( 5000 ) ;
160
+ let expected_event = FeeSet {
161
+ old_fee : SINGLE_UPDATE_FEE_IN_WEI ,
162
+ new_fee : expected_new_fee,
163
+ } ;
164
+ assert ! ( pyth_contract. emitted( & expected_event) , "FeeSet event should be emitted" ) ;
165
+
148
166
let result2 = pyth_contract
149
167
. sender ( alice)
150
168
. execute_governance_instruction ( bytes. clone ( ) ) ;
@@ -245,6 +263,15 @@ mod test {
245
263
) ;
246
264
}
247
265
assert ! ( result. is_ok( ) ) ;
266
+
267
+ let expected_event = GovernanceDataSourceSet {
268
+ old_chain_id : 0 , // Initial governance_data_source_index
269
+ old_emitter_address : FixedBytes :: from ( GOVERNANCE_EMITTER ) , // Initial governance emitter from pyth_wormhole_init
270
+ new_chain_id : 1 , // claim_vm.body.emitter_chain from the VAA
271
+ new_emitter_address : FixedBytes :: from ( GOVERNANCE_EMITTER ) , // emitter_bytes from the VAA
272
+ initial_sequence : 100 , // claim_vm.body.sequence from the VAA (0x64 = 100)
273
+ } ;
274
+ assert ! ( pyth_contract. emitted( & expected_event) , "GovernanceDataSourceSet event should be emitted" ) ;
248
275
}
249
276
250
277
#[ motsu:: test]
@@ -269,6 +296,13 @@ mod test {
269
296
}
270
297
assert ! ( result. is_ok( ) ) ;
271
298
299
+ let expected_new_fee = U256 :: from ( 100000 ) ;
300
+ let expected_event = TransactionFeeSet {
301
+ old_fee : U256 :: ZERO ,
302
+ new_fee : expected_new_fee,
303
+ } ;
304
+ assert ! ( pyth_contract. emitted( & expected_event) , "TransactionFeeSet event should be emitted" ) ;
305
+
272
306
let result2 = pyth_contract
273
307
. sender ( alice)
274
308
. execute_governance_instruction ( bytes. clone ( ) ) ;
0 commit comments