Skip to content

Conversation

@louisinger
Copy link
Collaborator

@louisinger louisinger commented Oct 16, 2025

Add unit tests to ParseVtxoScript. fixtures are coming from arkade-os/ts-sdk#186

@altafan please review

Summary by CodeRabbit

  • Tests
    • Added comprehensive test coverage for VTXO script parsing validation with fixture-based test cases.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 16, 2025

Walkthrough

Adds test coverage for VTXO script parsing functionality. A new test function TestParseVtxoScript loads test fixtures from JSON and validates Taproot key extraction. Two new helper types and a fixture loader function are introduced to support the test.

Changes

Cohort / File(s) Change Summary
VTXO Script Tests
pkg/ark-lib/script/script_test.go
Introduces TestParseVtxoScript test function that iterates through vtxo script fixtures, parses scripts, and validates Taproot keys. Adds vtxoScriptFixtures type and parseVtxoScriptFixtures loader function. Updates imports to include encoding/json and os.
VTXO Script Test Data
pkg/ark-lib/script/testdata/vtxoscript.json
New JSON test data file containing two vtxoScript test cases with hex-encoded scripts and taprootKey fields.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "Unit test ParseVtxoScript" directly summarizes the main change in the changeset. The PR adds comprehensive test coverage for the ParseVtxoScript function by introducing TestParseVtxoScript in the script_test.go file and corresponding test fixtures in vtxoscript.json. The title is concise, specific, and clearly communicates the primary intent of the change, allowing teammates scanning the repository history to immediately understand that unit tests were added for this particular function.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e16538b and ad0343c.

📒 Files selected for processing (2)
  • pkg/ark-lib/script/script_test.go (2 hunks)
  • pkg/ark-lib/script/testdata/vtxoscript.json (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
pkg/ark-lib/script/script_test.go (2)
pkg/ark-lib/script/vtxo_script.go (1)
  • ParseVtxoScript (37-53)
pkg/ark-lib/txutils/taptree.go (1)
  • TapTree (14-14)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Build and Scan
  • GitHub Check: integration tests
  • GitHub Check: unit tests
🔇 Additional comments (5)
pkg/ark-lib/script/testdata/vtxoscript.json (1)

1-27: LGTM! Well-structured test fixtures.

The JSON test data is properly formatted with consistent structure across both test cases. The fixtures cover both odd and even numbers of tapscripts, which provides good test coverage for the parsing logic.

pkg/ark-lib/script/script_test.go (4)

8-8: LGTM! Appropriate imports added.

The encoding/json and os imports are correctly added to support loading and parsing the JSON test fixtures.

Also applies to: 10-10


1246-1257: LGTM! Clean and effective test implementation.

The test follows Go testing best practices:

  • Uses table-driven testing via fixtures
  • Proper use of subtests with t.Run
  • Clear assertions with require
  • Validates the critical output (taproot key extraction)

1259-1263: LGTM! Struct properly maps to JSON fixture format.

The vtxoScriptFixtures type correctly defines the schema with appropriate JSON tags matching the test data structure.


1265-1274: LGTM! Straightforward fixture loader.

The helper function cleanly encapsulates reading and parsing the JSON fixtures with proper error handling.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@altafan altafan merged commit ac35697 into arkade-os:master Oct 17, 2025
5 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.

2 participants