Skip to content

tests: don't panic when a staker query fails during a wait - #146

Merged
otherview merged 1 commit into
mainfrom
pedro/stargate-period-wait-nil
Oct 9, 2026
Merged

otherview merged 1 commit into
mainfrom
pedro/stargate-period-wait-nil

Conversation

@otherview

@otherview otherview commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Why

Test_Stargate_DelegatorFlow_Stake_And_Claim_Auto_Renew_On_And_Off failed twice in a row on vechain/thor-private#198 with a nil-pointer panic at stargate_test.go:40. A re-run passed.

waitForCompletedPeriods logged periodDetails.CompletedPeriods before checking the error from GetValidationPeriodDetails. When that query failed, the result was nil and the test panicked:

  • The panic skipped RunFlakyTest's retries, so one failed query failed the whole job.
  • It also hid the query error, so we can't tell from these runs what the error was.

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

  • waitForCompletedPeriods checks the error first. A failed query is logged at Warn and polling continues, still bounded by the existing one-minute limit.
  • If the wait fails, it returns the underlying error instead of StakerStatusUnknownError. The cause then shows in the log, and the test is still retried, since RunTestWithRetry retries any error.
  • assertValidatorStatus and assertValidatorStatusUnknown in tests/validations had the same nil dereference after assert.NoError. Now assertValidatorStatus stops with require.NoError, and assertValidatorStatusUnknown returns the error so the test is retried.

Testing

go vet ./tests/... passes. I couldn't run the suites locally.

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.
@otherview
otherview merged commit c012a8a into main Oct 9, 2026
11 of 20 checks passed
@otherview
otherview deleted the pedro/stargate-period-wait-nil branch October 9, 2026 08:49
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