Skip to content

Commit e2cc702

Browse files
committed
fixed test case verification
1 parent f924e76 commit e2cc702

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

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

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
21
#[cfg(test)]
32
mod test {
43
use crate::PythReceiver;
54
use crate::test_data;
6-
use alloy_primitives::{address, U256, Address};
5+
use alloy_primitives::{address, U256, Address, U64, I64, I32};
76
use stylus_sdk::testing::TestVM;
87
use pythnet_sdk::wire::v1::PYTHNET_ACCUMULATOR_UPDATE_MAGIC;
98
use motsu::prelude::*;
@@ -13,12 +12,12 @@ mod test {
1312
0xe6, 0x2d, 0xf6, 0xc8, 0xb4, 0xa8, 0x5f, 0xe1, 0xa6, 0x7d, 0xb4, 0x4d, 0xc1, 0x2d, 0xe5, 0xdb,
1413
0x33, 0x0f, 0x7a, 0xc6, 0x6b, 0x72, 0xdc, 0x65, 0x8a, 0xfe, 0xdf, 0x0f, 0x4a, 0x41, 0x5b, 0x43
1514
];
16-
const TEST_PUBLISH_TIME: u64 = 1712589206;
17-
const TEST_PRICE: i64 = 7192002930010;
18-
const TEST_CONF: u64 = 3596501465;
15+
const TEST_PUBLISH_TIME: u64 = 1751563000;
16+
const TEST_PRICE: i64 = 10967241867779;
17+
const TEST_CONF: u64 = 4971244966;
1918
const TEST_EXPO: i32 = -8;
20-
const TEST_EMA_PRICE: i64 = 7181868900000;
21-
const TEST_EMA_CONF: u64 = 4096812700;
19+
const TEST_EMA_PRICE: i64 = 10942391100000;
20+
const TEST_EMA_CONF: u64 = 4398561400;
2221

2322
const PYTHNET_CHAIN_ID: u16 = 26;
2423
const PYTHNET_EMITTER_ADDRESS: [u8; 32] = [
@@ -118,9 +117,16 @@ mod test {
118117
let result = pyth_contract.sender(alice).update_price_feeds(update_data);
119118
assert!(result.is_ok());
120119

121-
// let price_result = pyth_contract.sender(alice).get_price_unsafe(TEST_PRICE_ID);
122-
// assert!(price_result.is_ok());
123-
// assert_eq!(price_result.unwrap(), (TEST_PUBLISH_TIME, TEST_EXPO, TEST_PRICE, TEST_CONF, TEST_EMA_PRICE, TEST_EMA_CONF));
120+
let price_result = pyth_contract.sender(alice).get_price_unsafe(TEST_PRICE_ID);
121+
assert!(price_result.is_ok());
122+
assert_eq!(price_result.unwrap(), (
123+
U64::from(TEST_PUBLISH_TIME),
124+
I32::from_le_bytes(TEST_EXPO.to_le_bytes()),
125+
I64::from_le_bytes(TEST_PRICE.to_le_bytes()),
126+
U64::from(TEST_CONF),
127+
I64::from_le_bytes(TEST_EMA_PRICE.to_le_bytes()),
128+
U64::from(TEST_EMA_CONF)
129+
));
124130

125131

126132
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ impl PythReceiver {
185185
Proof::WormholeMerkle { vaa, updates } => {
186186
let wormhole: IWormholeContract = IWormholeContract::new(self.wormhole.get());
187187
let config = Call::new();
188-
189188
wormhole.parse_and_verify_vm(config, Vec::from(vaa.clone())).map_err(|_| PythReceiverError::InvalidWormholeMessage).unwrap();
190189

191190
let vaa = Vaa::read(&mut Vec::from(vaa.clone()).as_slice()).unwrap();

0 commit comments

Comments
 (0)