Skip to content

Commit c4f3c4e

Browse files
committed
test framework
1 parent a6f300e commit c4f3c4e

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#[cfg(test)]
2+
mod test {
3+
use super::*;
4+
use alloy_primitives::address;
5+
use stylus_sdk::testing::*;
6+
7+
#[test]
8+
fn test_initialize() {
9+
// Set up test environment
10+
let vm = TestVM::default();
11+
// Initialize your contract
12+
let mut contract = PythReceiver::from(&vm);
13+
14+
let wormhole_address = address!("0x3F38404A2e3Cb949bcDfA19a5C3bDf3fE375fEb0");
15+
16+
}
17+
}

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ extern crate alloc;
77

88
mod structs;
99
mod error;
10+
mod integration_tests;
1011

1112
use alloc::vec::Vec;
1213
use stylus_sdk::{alloy_primitives::{U16, U32, U256, U64, I32, I64, FixedBytes, Address},
@@ -163,8 +164,6 @@ impl PythReceiver {
163164
let parsed_vaa = wormhole.parse_and_verify_vm(config, Vec::from(vaa)).map_err(|_| PythReceiverError::InvalidWormholeMessage).unwrap();
164165
let vaa = Vaa::read(&mut parsed_vaa.as_slice()).unwrap();
165166

166-
// TODO: CHECK IF THE VAA IS FROM A VALID DATA SOURCE
167-
168167
let cur_emitter_address: &[u8; 32] = vaa.body.emitter_address.as_slice().try_into().expect("emitter address must be 32 bytes");
169168

170169
let cur_data_source = DataSource {
@@ -283,3 +282,7 @@ fn parse_wormhole_proof(vaa: Vaa) -> Result<MerkleRoot<Keccak160>, PythReceiverE
283282
});
284283
Ok(root)
285284
}
285+
286+
287+
#[cfg(test)]
288+
pub use integration_tests::*;

0 commit comments

Comments
 (0)