Skip to content

test: add first Go unit suite (primitives, config, abi, wallet)#27

Merged
LeJamon merged 2 commits into
mainfrom
test/go-unit-suite
Jun 29, 2026
Merged

test: add first Go unit suite (primitives, config, abi, wallet)#27
LeJamon merged 2 commits into
mainfrom
test/go-unit-suite

Conversation

@Sanka-D

@Sanka-D Sanka-D commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Context

The repository currently has no Go tests. This PR adds a first, focused unit suite over the pure / deterministic packages — no node, Docker, or network required — so go test ./... gives a real safety net and a foundation to grow.

Coverage

Package What's tested
primitives All / IsValid; Registry invariants (every kind builds, contract needs an ABI, escrow/vault don't, correct WASM targets)
config TOML Load/Save round-trip, local-node default injection, primitive inference from legacy [contracts]/[escrows] sections, missing-file error, HasPrimitive
abi ParseContract over annotated Rust (params, @flag, @return), invalid-type and name-mismatch errors, IsValidType / GetTypeInfo
wallet ValidateSeed / ValidateAddress, SeedToAddress known-answer vector (masterpassphrase → rHb9C…tyTh) + determinism, GenerateWallet round-trip, getAlgorithm

Notes

  • Table-driven, t.TempDir() for fixtures, got/want error messages — standard Go idioms.
  • 21 test functions, all green; go vet ./... and gofmt clean.
  • One assertion documents a subtle parser behaviour found while writing it: @flag is positional — it applies to the @param annotations that follow it, not the ones before.

Independent of #26 (the P1 bug-fix PR); branched from main and touches only *_test.go files.

🤖 Generated with Claude Code

The repository had no Go tests. This adds a focused, network-free suite over
the pure/deterministic packages, runnable with `go test ./...`:

- primitives: All/IsValid plus Registry invariants (build/ABI/target per kind)
- config: TOML Load/Save round-trip, local-node default injection, primitive
  inference from legacy sections, missing-file error, HasPrimitive
- abi: ParseContract over annotated Rust (params/flag/return), invalid-type and
  name-mismatch errors, IsValidType/GetTypeInfo
- wallet: ValidateSeed/ValidateAddress, SeedToAddress known-answer vector
  (masterpassphrase) + determinism, GenerateWallet round-trip, getAlgorithm

Tests are table-driven and use t.TempDir(). One assertion documents a subtle
parser behaviour surfaced while writing it: @Flag is positional and applies to
the @param annotations that follow it.

21 test functions, all green; go vet and gofmt clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
`primitives` is a root-level key in bedrock.toml (Config.Primitives is a
top-level field), but generateConfig and every doc example emitted it under
[project], where TOML parses it as project.primitives and Load silently
drops it. cfg.Primitives was only repopulated by the section-inference
fallback, so the explicit list users edit had no effect.

Move the key above [project] in the scaffolder and all examples, and assert
root-level loading in the config test (it previously nested the key under
[project] and never checked it loaded).
@LeJamon LeJamon merged commit ff657ad into main Jun 29, 2026
3 checks passed
@LeJamon LeJamon deleted the test/go-unit-suite branch June 29, 2026 11:58
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