Skip to content

feat(stylus): Negative + Invalid Tests for Stylus Governance #2898

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

Merged
merged 9 commits into from
Jul 25, 2025

Conversation

ayushboss
Copy link
Contributor

Summary

Added negative and invalid test cases for stylus governance.

How has this been tested?

  • Current tests cover my changes
  • Added new tests
  • Manually tested the code

ayushboss and others added 7 commits July 23, 2025 14:33
- Use exact working Solidity VAA hex string instead of manual construction
- Debugged wormhole validation process to understand root cause
- Added comprehensive documentation explaining debugging findings
- Removed debugging test function after investigation completed
- Test now passes consistently with proper VAA structure

Debug investigation revealed that manual VAA construction can produce
identical results when using correct parameters. The original error
was likely due to incorrect construction parameters rather than the
manual approach itself.

Co-Authored-By: [email protected] <[email protected]>
…ance actions

- Add test_utils.rs with VAA generation functions for all 9 governance actions
- Use pre-signed working VAA hex strings directly to ensure valid cryptographic signatures
- Include unit tests for each VAA generation function (6 tests passing)
- Update existing tests to use new utility functions instead of hardcoded hex strings
- Fix test_set_data_sources which was previously failing with InvalidWormholeMessage
- Enable easy test case creation without manual VAA construction

Note: test_authorize_governance_data_source_transfer still fails with OldGovernanceMessage
but this was a pre-existing issue in the original pyth-stylus-governance-better-tests branch

Co-Authored-By: [email protected] <[email protected]>
Copy link

vercel bot commented Jul 24, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
api-reference ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 25, 2025 4:25pm
component-library ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 25, 2025 4:25pm
developer-hub ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 25, 2025 4:25pm
entropy-debugger ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 25, 2025 4:25pm
entropy-explorer ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 25, 2025 4:25pm
insights ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 25, 2025 4:25pm
proposals ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 25, 2025 4:25pm
staking ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 25, 2025 4:25pm

Copy link
Contributor

@tejasbadadare tejasbadadare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good!

@@ -92,12 +92,24 @@ mod test {
) {
pyth_wormhole_init(&pyth_contract, &wormhole_contract, &alice, 0);

let sources = vec![(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this being used anywhere?

let bytes = Vec::from_hex(hex_str).expect("Invalid hex string");

let result = pyth_contract
.sender(alice)
.execute_governance_instruction(bytes.clone());

println!("Result: {:?}", result.unwrap_err());
// assert!(result.is_ok());
assert!(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verify state / verify event emission here? maybe you're planning this in another PR

@ayushboss ayushboss merged commit 134f595 into main Jul 25, 2025
9 checks passed
@ayushboss ayushboss deleted the pyth-stylus-governance-better-tests branch July 25, 2025 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants