Before Posting:
β Please select the appropriate product category from the dropdown when creating a topic.
β Use this category only for help topics related Pyth Price Feeds, Hermes, Price Pusher.
β You can remove these instructions when submitting your post.
Check the Pyth Documentation for guides, known issues, and integration examples β your answer might already be there.
When asking for support, please include:
β’
Chain: Aptos mainnet
β’
Timestamp of the issue (block time or UTC)
β’
Steps to reproduce the issue
β’
Any relevant code snippet you can share
fun test_get_oracle_price(){
let price_infos = vector<PriceInfo>[
price_info::new(
1663680747,
1663074349,
price_feed::new(
price_identifier::from_byte_vec(PRICE_ID),
price::new(i64::new(1557, false), 7, i64::new(5, true), 1663680740),
price::new(i64::new(1500, false), 3, i64::new(5, true), 1663680740),
),
)
];
pyth_test::update_cache_for_test(price_infos);
let price = pyth::get_price_no_older_than(price_identifier::from_byte_vec(PRICE_ID), 60);
std::debug::print(&format1(&b"price = {}", price));
β’ Name of the dApp/Project that you are building
Xyralabs
β’ Contact (Telegram/Email/Discord) @OxAnt0
The more context you provide, the faster we can help.
Iβm trying to initialise custom pyth oracle price for unit testing on aptos move. Iβm using the above approach to create custom price . However Iβm getting this error while reading price
βββ test_get_oracle_price ββββββ
β error[E11001]: test failure
β ββ /Users/anto/.move/https___github_com_0xAnto_pyth-crosschain_git_mainnet/target_chains/aptos/contracts/sources/state.move:126:33
β β
β 125 β public fun price_info_cached(price_identifier: PriceIdentifier): bool acquires LatestPriceInfo {
β β ----------------- In this function in 0x7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387::state
β 126 β let latest_price_info = borrow_global<LatestPriceInfo>(@pyth);
β β ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Test was not expected to error, but it gave a MISSING_DATA (code 4008) error with error message: "Failed to borrow global resource from 7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387". Error originating in the module 7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387::state rooted here
β
β
β stack trace
β pyth::price_feed_exists(/Users/anto/.move/https___github_com_0xAnto_pyth-crosschain_git_mainnet/target_chains/aptos/contracts/sources/pyth.move:406)
β pyth::is_fresh_update(/Users/anto/.move/https___github_com_0xAnto_pyth-crosschain_git_mainnet/target_chains/aptos/contracts/sources/pyth.move:390)
β pyth::update_cache(/Users/anto/.move/https___github_com_0xAnto_pyth-crosschain_git_mainnet/target_chains/aptos/contracts/sources/pyth.move:311)
β pyth_test::update_cache_for_test(/Users/anto/.move/https___github_com_0xAnto_pyth-crosschain_git_mainnet/target_chains/aptos/contracts/sources/pyth.move:649)
β oracle::test_get_oracle_price(/Users/anto/Documents/Kana/Code/perpetual-contracts-v2/sources/oracle.move:320)
β
βββββββββββββββββββ
Test result: FAILED. Total tests: 1; passed: 0; failed: 1
{
"Error": "Move unit tests failed"
}