Repository navigation
tests: don't panic when a staker query fails during a wait - #146
Merged
Merged
Conversation
waitForCompletedPeriods logged periodDetails.CompletedPeriods before checking the query error, so a failed GetValidationPeriodDetails call dereferenced a nil result and panicked. The panic skipped RunFlakyTest's retries and hid the query error. It failed thor-private CI twice in Test_Stargate_DelegatorFlow_Stake_And_Claim_Auto_Renew_On_And_Off while the chain was producing blocks normally. Check the error first. A failed query now counts as not done yet, is logged, and polling continues within the existing one-minute bound. If the wait still fails, return the underlying error instead of a generic StakerStatusUnknownError, so the cause shows and the test is retried. assertValidatorStatus and assertValidatorStatusUnknown in the validations tests had the same nil dereference after assert.NoError: stop with require.NoError, or return the error for a retry.
libotony
approved these changes
Oct 9, 2026
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.
Why
Test_Stargate_DelegatorFlow_Stake_And_Claim_Auto_Renew_On_And_Offfailed twice in a row on vechain/thor-private#198 with a nil-pointer panic atstargate_test.go:40. A re-run passed.waitForCompletedPeriodsloggedperiodDetails.CompletedPeriodsbefore checking the error fromGetValidationPeriodDetails. When that query failed, the result was nil and the test panicked:RunFlakyTest's retries, so one failed query failed the whole job.Block production in the failing runs matched a passing run: one block every 5 s, no missed slots. In both failures, the query that panicked was the one following the "completed=4 expected=5" poll.
Changes
waitForCompletedPeriodschecks the error first. A failed query is logged at Warn and polling continues, still bounded by the existing one-minute limit.StakerStatusUnknownError. The cause then shows in the log, and the test is still retried, sinceRunTestWithRetryretries any error.assertValidatorStatusandassertValidatorStatusUnknownintests/validationshad the same nil dereference afterassert.NoError. NowassertValidatorStatusstops withrequire.NoError, andassertValidatorStatusUnknownreturns the error so the test is retried.Testing
go vet ./tests/...passes. I couldn't run the suites locally.