Repository navigation
feat(scenarios): tag the Pyth v2 and Phoenix collections clock-sensitive #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7d55f53
55187e3
475277c
1df5dab
a088f6e
4779c48
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ tags: | |
| - perpetuals | ||
| - collateral | ||
| - risk | ||
| - clock-sensitive | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This tags all eight Phoenix templates, including ones with no time check, which means extra warnings in Studio. That's acceptable as a stopgap. Consider adding a short YAML comment explaining why the tag is here, and adding entry-level |
||
|
|
||
| templates: | ||
| - id: phoenix-oracle-price | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ tags: | |
| - oracle | ||
| - price-feed | ||
| - defi | ||
| - clock-sensitive | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Studio now relies on this tag, but no test checks it. Suggest adding an assertion in |
||
|
|
||
| constants: | ||
| price_feed: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1052,6 +1052,30 @@ templates: [] | |
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_clock_sensitive_tag_marks_pyth_and_every_phoenix_template() { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor: the test only checks that the tag is present. Consider also asserting that a collection known to be insensitive, e.g. a Jupiter or Whirlpool template (until its branch lands), is not tagged. Otherwise a tag put on the wrong collection by mistake would go unnoticed, since Studio would just warn for it. |
||
| let registry = TemplateRegistry::new(); | ||
| let tagged: Vec<&str> = registry | ||
| .by_tags(&["clock-sensitive".to_string()]) | ||
| .iter() | ||
| .map(|template| template.id.as_str()) | ||
| .collect(); | ||
|
|
||
| let phoenix = registry.by_protocol("Phoenix Eternal"); | ||
| assert!( | ||
| !phoenix.is_empty(), | ||
| "the Phoenix Eternal templates are registered" | ||
| ); | ||
| for template in std::iter::once("pyth-price-feed-v2") | ||
| .chain(phoenix.iter().map(|template| template.id.as_str())) | ||
| { | ||
| assert!( | ||
| tagged.contains(&template), | ||
| "{template} must be clock-sensitive" | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_jupiter_idl_has_token_ledger_account() { | ||
| let registry = TemplateRegistry::new(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would help to say that the tag is read at collection level only, because entry-level
tagsare ignored (YamlOverrideTemplateEntryhas notagsfield). Otherwise a contributor may add it to a single template and wonder why Studio never warns.