Skip to content

Commit 27bba80

Browse files
reditablereditable
andauthored
feat(target_chains/sui) add test_only new method into sui contract (#2375)
Co-authored-by: reditable <reditable@gmail.com>
1 parent c26d575 commit 27bba80

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

target_chains/sui/contracts/sources/data_source.move

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,12 @@ module pyth::data_source {
7474
public fun emitter_address(data_source: &DataSource): ExternalAddress{
7575
data_source.emitter_address
7676
}
77+
78+
#[test_only]
79+
public fun new_data_source_for_test(emitter_chain: u64, emitter_address: ExternalAddress): DataSource {
80+
DataSource {
81+
emitter_chain,
82+
emitter_address,
83+
}
84+
}
7785
}

target_chains/sui/contracts/sources/price_info.move

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,17 @@ module pyth::price_info {
175175
object::delete(id);
176176
}
177177

178+
#[test_only]
179+
public fun new_price_info_object_for_test(
180+
price_info: PriceInfo,
181+
ctx: &mut TxContext
182+
): PriceInfoObject {
183+
PriceInfoObject {
184+
id: object::new(ctx),
185+
price_info
186+
}
187+
}
188+
178189
public fun uid_to_inner(price_info: &PriceInfoObject): ID {
179190
object::uid_to_inner(&price_info.id)
180191
}

target_chains/sui/contracts/sources/state.move

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,31 @@ module pyth::state {
365365
sui::dynamic_field::add(&mut self.id, CurrentDigest {}, bytes32::from_bytes(b"new build"));
366366
}
367367

368+
#[test_only]
369+
public fun register_price_info_object_for_test(self: &mut State, price_identifier: PriceIdentifier, id: ID) {
370+
price_info::add(&mut self.id, price_identifier, id);
371+
}
372+
373+
#[test_only]
374+
public fun new_state_for_test(
375+
upgrade_cap: UpgradeCap,
376+
governance_data_source: DataSource,
377+
stale_price_threshold: u64,
378+
base_update_fee: u64,
379+
ctx: &mut TxContext
380+
): State {
381+
State {
382+
id: object::new(ctx),
383+
upgrade_cap,
384+
governance_data_source,
385+
stale_price_threshold,
386+
base_update_fee,
387+
fee_recipient_address: tx_context::sender(ctx),
388+
last_executed_governance_sequence: 0,
389+
consumed_vaas: consumed_vaas::new(ctx),
390+
}
391+
}
392+
368393
////////////////////////////////////////////////////////////////////////////
369394
//
370395
// Deprecated

0 commit comments

Comments
 (0)