test: cover pending.go helpers and legacy migration#3278
test: cover pending.go helpers and legacy migration#3278CaelRowley wants to merge 1 commit intoevstack:mainfrom
Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 9 minutes and 53 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughA new test file for pending-block functionality has been added, introducing helper constructors ( Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
block/internal/executing/pending_test.go (1)
44-44: Use a fixed timestamp to keep tests deterministic.Line 44 uses
time.Now().UnixNano(), which makes test data time-dependent. Prefer a constant timestamp in test helpers.As per coding guidelines, "`**/*_test.go`: Ensure tests are deterministic".Proposed change
- BaseHeader: types.BaseHeader{ + BaseHeader: types.BaseHeader{ ChainID: gen.ChainID, Height: height, - Time: uint64(time.Now().UnixNano()), + Time: uint64(1_700_000_000_000_000_000), // fixed test timestamp },🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@block/internal/executing/pending_test.go` at line 44, Replace the non-deterministic timestamp used for test data (uint64(time.Now().UnixNano()) in pending_test.go) with a fixed constant to make tests deterministic: create a package-level const or var like testTimestamp (or a local fixedTS) and use that for the Time field in the test helper/fixture that builds the pending object. Update any test helpers or struct initializers that reference Time in pending_test.go (the initializer where Time is set) to use the fixed timestamp instead of time.Now().
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@block/internal/executing/pending_test.go`:
- Around line 103-107: The tests currently accept any error from
fx.MemStore.GetBlockData and fx.MemStore.GetSignature which can mask backend
failures; update the assertions to require the specific sentinel error
ds.ErrNotFound instead of a generic assert.Error. Locate the calls to
fx.MemStore.GetBlockData(t.Context(), 1) and
fx.MemStore.GetSignature(t.Context(), 1) (and the similar checks at lines
112-113) and replace the generic error assertions with an explicit
equality/assertion against ds.ErrNotFound so the test fails only when a key is
unexpectedly present rather than on unrelated errors.
---
Nitpick comments:
In `@block/internal/executing/pending_test.go`:
- Line 44: Replace the non-deterministic timestamp used for test data
(uint64(time.Now().UnixNano()) in pending_test.go) with a fixed constant to make
tests deterministic: create a package-level const or var like testTimestamp (or
a local fixedTS) and use that for the Time field in the test helper/fixture that
builds the pending object. Update any test helpers or struct initializers that
reference Time in pending_test.go (the initializer where Time is set) to use the
fixed timestamp instead of time.Now().
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a2170101-548a-4380-93cd-c11a97347c48
📒 Files selected for processing (1)
block/internal/executing/pending_test.go
744c8e5 to
348aa72
Compare
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Overview
Follow-up to #3073 adding unit coverage for
block/internal/executing/pending.go.The existing restart tests in executor_restart_test.go cover the end-to-end happy path but leave
migrateLegacyPendingBlockand several error branches untested. These gaps are now covered inpending_test.go:No production code changes.
Testing
go test ./block/internal/executing/ -run 'TestMigrateLegacyPendingBlock|TestGetPendingBlock|TestDeletePendingBlock' -v -count=1Summary by CodeRabbit