@@ -111,9 +111,11 @@ mod test {
111
111
data,
112
112
) ;
113
113
114
+ alice. fund ( U256 :: from ( 200 ) ) ;
115
+
114
116
let update_data = test_data:: good_update1 ( ) ;
115
117
116
- let result = pyth_contract. sender ( alice) . update_price_feeds ( update_data) ;
118
+ let result = pyth_contract. sender_and_value ( alice, U256 :: from ( 100 ) ) . update_price_feeds ( update_data) ;
117
119
assert ! ( result. is_ok( ) ) ;
118
120
119
121
let price_result = pyth_contract. sender ( alice) . get_price_unsafe ( TEST_PRICE_ID ) ;
@@ -130,6 +132,46 @@ mod test {
130
132
131
133
}
132
134
135
+ #[ motsu:: test]
136
+ fn test_update_price_feed_insufficient_fee ( pyth_contract : Contract < PythReceiver > , wormhole_contract : Contract < WormholeContract > , alice : Address ) {
137
+ let guardians = current_guardians ( ) ;
138
+ let governance_contract = Address :: from_slice ( & GOVERNANCE_CONTRACT . to_be_bytes :: < 32 > ( ) [ 12 ..32 ] ) ;
139
+ wormhole_contract. sender ( alice) . initialize ( guardians, CHAIN_ID , GOVERNANCE_CHAIN_ID , governance_contract) . unwrap ( ) ;
140
+ // let result = wormhole_contract.sender(alice).store_gs(4, current_guardians(), 0);
141
+
142
+ let single_update_fee = U256 :: from ( 100u64 ) ;
143
+ let valid_time_period = U256 :: from ( 3600u64 ) ;
144
+
145
+ let data_source_chain_ids = vec ! [ PYTHNET_CHAIN_ID ] ;
146
+ let data_source_emitter_addresses = vec ! [ PYTHNET_EMITTER_ADDRESS ] ;
147
+
148
+ let governance_chain_id = 1u16 ;
149
+ let governance_emitter_address = [ 3u8 ; 32 ] ;
150
+ let governance_initial_sequence = 0u64 ;
151
+ let data = vec ! [ ] ;
152
+
153
+ pyth_contract. sender ( alice) . initialize (
154
+ wormhole_contract. address ( ) ,
155
+ single_update_fee,
156
+ valid_time_period,
157
+ data_source_chain_ids,
158
+ data_source_emitter_addresses,
159
+ governance_chain_id,
160
+ governance_emitter_address,
161
+ governance_initial_sequence,
162
+ data,
163
+ ) ;
164
+
165
+ alice. fund ( U256 :: from ( 50 ) ) ;
166
+
167
+ let update_data = test_data:: good_update1 ( ) ;
168
+
169
+ let result = pyth_contract. sender_and_value ( alice, U256 :: from ( 50 ) ) . update_price_feeds ( update_data) ;
170
+ assert ! ( result. is_err( ) ) ;
171
+ assert_eq ! ( result. unwrap_err( ) , PythReceiverError :: InsufficientFee ) ;
172
+
173
+ }
174
+
133
175
#[ motsu:: test]
134
176
fn test_get_price_after_multiple_updates ( pyth_contract : Contract < PythReceiver > , wormhole_contract : Contract < WormholeContract > , alice : Address ) {
135
177
let guardians = current_guardians ( ) ;
@@ -159,12 +201,14 @@ mod test {
159
201
data,
160
202
) ;
161
203
204
+ alice. fund ( U256 :: from ( 200 ) ) ;
205
+
162
206
let update_data1 = test_data:: good_update1 ( ) ;
163
- let result1 = pyth_contract. sender ( alice) . update_price_feeds ( update_data1) ;
207
+ let result1 = pyth_contract. sender_and_value ( alice, U256 :: from ( 100 ) ) . update_price_feeds ( update_data1) ;
164
208
assert ! ( result1. is_ok( ) ) ;
165
209
166
210
let update_data2 = test_data:: good_update2 ( ) ;
167
- let result2 = pyth_contract. sender ( alice) . update_price_feeds ( update_data2) ;
211
+ let result2 = pyth_contract. sender_and_value ( alice, U256 :: from ( 100 ) ) . update_price_feeds ( update_data2) ;
168
212
assert ! ( result2. is_ok( ) ) ;
169
213
170
214
let price_result = pyth_contract. sender ( alice) . get_price_unsafe ( TEST_PRICE_ID ) ;
@@ -281,8 +325,10 @@ mod test {
281
325
data,
282
326
) ;
283
327
328
+ alice. fund ( U256 :: from ( 200 ) ) ;
329
+
284
330
let update_data = test_data:: good_update2 ( ) ;
285
- let result = pyth_contract. sender ( alice) . update_price_feeds ( update_data) ;
331
+ let result = pyth_contract. sender_and_value ( alice, U256 :: from ( 100 ) ) . update_price_feeds ( update_data) ;
286
332
assert ! ( result. is_ok( ) ) ;
287
333
288
334
let price_result = pyth_contract. sender ( alice) . get_price_no_older_than ( TEST_PRICE_ID , u64:: MAX ) ;
@@ -325,9 +371,10 @@ mod test {
325
371
governance_initial_sequence,
326
372
data,
327
373
) ;
374
+ alice. fund ( U256 :: from ( 200 ) ) ;
328
375
329
376
let update_data = test_data:: good_update2 ( ) ;
330
- let result = pyth_contract. sender ( alice) . update_price_feeds ( update_data) ;
377
+ let result = pyth_contract. sender_and_value ( alice, U256 :: from ( 100 ) ) . update_price_feeds ( update_data) ;
331
378
assert ! ( result. is_ok( ) ) ;
332
379
333
380
let price_result = pyth_contract. sender ( alice) . get_price_no_older_than ( TEST_PRICE_ID , 1 ) ;
@@ -363,9 +410,11 @@ mod test {
363
410
governance_initial_sequence,
364
411
data,
365
412
) ;
413
+
414
+ alice. fund ( U256 :: from ( 200 ) ) ;
366
415
367
416
let update_data = test_data:: multiple_updates ( ) ;
368
- let result = pyth_contract. sender ( alice) . update_price_feeds ( update_data) ;
417
+ let result = pyth_contract. sender_and_value ( alice, U256 :: from ( 200 ) ) . update_price_feeds ( update_data) ;
369
418
assert ! ( result. is_ok( ) ) ;
370
419
371
420
let first_id: [ u8 ; 32 ] = [
0 commit comments