test(#443): cover oracle timeout fallback path (trigger_randomness_fa…#539
Merged
Otaiki1 merged 2 commits intoJun 30, 2026
Conversation
…randomness_fallback) Add automated coverage for the oracle-timeout recovery mechanism, which had none. Three tests in the raffle-instance test module exercise both fallback branches and the timeout guard: - fallback_with_refund_cancels_raffle: after the timeout elapses, trigger_randomness_fallback(caller, do_refund=true) cancels the raffle, clears the DrawingLock, and lets buyers reclaim funds via refund_ticket. - fallback_without_refund_uses_internal_seed: the do_refund=false branch finalizes the raffle via the internal seed, selects a winner, and clears the DrawingLock. - fallback_too_early_is_rejected: calling before request_ledger + ORACLE_TIMEOUT_LEDGERS returns Error::FallbackTooEarly. Fix an inverted guard in trigger_randomness_fallback that made the path unreachable: it rejected with DrawingAlreadyInProgress whenever DrawingLock was set, but that lock is held for the entire "awaiting oracle" window (set by transition_to_drawing and required as true by the sibling provide_randomness). The guard now requires the lock to be held and returns DrawingAlreadyComplete when it is cleared, matching provide_randomness. Tests reuse the existing setup_external_drawing_raffle fixture. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Added automated coverage for the oracle-timeout recovery mechanism, which had none. Three tests in the raffle-instance test module exercise both fallback branches and the timeout guard:
Fixed an inverted guard in trigger_randomness_fallback that made the path unreachable: it rejected with DrawingAlreadyInProgress whenever DrawingLock was set, but that lock is held for the entire "awaiting oracle" window (set by transition_to_drawing and required as true by the sibling provide_randomness). The guard now requires the lock to be held and returns DrawingAlreadyComplete when it is cleared, matching provide_randomness.
Tests reuse the existing setup_external_drawing_raffle fixture.
Brief summary of what this PR does.
Closes #443
Testing
Contract Changes
Changelog
Security