Skip to content

Commit 6c9cc73

Browse files
committed
added in event emission assertion for set_valid_period
1 parent eca3eb9 commit 6c9cc73

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

target_chains/stylus/contracts/pyth-receiver/src/pyth_governance_test.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#[cfg(test)]
22
mod test {
3-
use crate::{DataSourcesSet, FeeSet, GovernanceDataSourceSet, PythReceiver, TransactionFeeSet};
3+
use crate::{
4+
DataSourcesSet, FeeSet, GovernanceDataSourceSet, PythReceiver, TransactionFeeSet,
5+
ValidPeriodSet,
6+
};
47
use alloy_primitives::{address, Address, FixedBytes, U256};
58
use hex::FromHex;
69
use motsu::prelude::*;
@@ -92,15 +95,6 @@ mod test {
9295
) {
9396
pyth_wormhole_init(&pyth_contract, &wormhole_contract, &alice, 0);
9497

95-
let sources = vec![(
96-
1u16,
97-
[
98-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
99-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
100-
0x00, 0x00, 0x11, 0x11,
101-
],
102-
)];
103-
10498
let hex_str = "0100000000010069825ef00344cf745b6e72a41d4f869d4e90de517849360c72bf94efc97681671d826e484747b21a80c8f1e7816021df9f55e458a6e7a717cb2bd2a1e85fd57100499602d200000000000100000000000000000000000000000000000000000000000000000000000000110000000000000001005054474d010200020100010000000000000000000000000000000000000000000000000000000000001111";
10599
let bytes = Vec::from_hex(hex_str).expect("Invalid hex string");
106100

@@ -141,8 +135,7 @@ mod test {
141135
alice: Address,
142136
) {
143137
pyth_wormhole_init(&pyth_contract, &wormhole_contract, &alice, 0);
144-
145-
let hex_str = "01000000000100b2e15dd5ef41b800ec5ec10f61c6415f706a769f459757f43be78a8fd9f1f6e104e909239fe73b4d8652f7aa1a07825e3230d01a0a7bd6efa0be2e7e72377d71010000000100000000000100000000000000000000000000000000000000000000000000000000000000110000000000000001005054474d010400020000000000000000";
138+
let hex_str = "01000000000100c9effcab077af2f3f65a7abfd1883295529eab7c0d4434772ed1f2d10b1de3571c214af45e944a3fee65417c9f0c6024010dadc26d30bb361e05f552ca4de04d000000000100000000000100000000000000000000000000000000000000000000000000000000000000110000000000000001005054474d010400020000000000000003";
146139
let bytes = Vec::from_hex(hex_str).expect("Invalid hex string");
147140

148141
let result = pyth_contract
@@ -153,6 +146,16 @@ mod test {
153146
result.is_ok(),
154147
"SetValidPeriod governance instruction should succeed"
155148
);
149+
150+
let expected_event = ValidPeriodSet {
151+
old_valid_period: U256::from(3600),
152+
new_valid_period: U256::from(3),
153+
};
154+
155+
assert!(
156+
pyth_contract.emitted(&expected_event),
157+
"ValidPeriodSet event should be emitted"
158+
);
156159
}
157160

158161
#[motsu::test]

0 commit comments

Comments
 (0)