Skip to content
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

Added WaitForEdgeForever and WaitForStateForever transactions, which return a Pending future to the callee. #125

Merged
merged 1 commit into from
Feb 15, 2025

Conversation

leighleighleigh
Copy link
Contributor

I have some code I'd like to mock for a quadrature encoder, which uses select(pin_clk,pin_data).
In order to properly test it, I need to be able to mock different paths in the select statement.

As it stands currently, the current async transactions always return Ok() when called - this means my select() paths are always taking the first branch.

The solution I propose here is to add a modified WaitForEdge/WaitForState enum called WaitFor{State,Edge}Forever, which returns a Pending future. This simulates a pin that never changes, while still allowing a mock transaction for the actual wait_for_edge call.

I have added tests for this, which poll the returned future for 10 milliseconds before timing-out (successful result).

Copy link
Collaborator

@ryankurte ryankurte left a comment

Choose a reason for hiding this comment

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

seems good to me!

@dbrgn
Copy link
Owner

dbrgn commented Feb 15, 2025

Thanks for the review, @ryankurte!

@dbrgn dbrgn merged commit e11348e into dbrgn:main Feb 15, 2025
3 checks passed
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.

3 participants