Skip to content

Add orderbook cancellation depth tests#3

Open
poorandhungrybutbuthappy wants to merge 5 commits into
jackjin1997:mainfrom
poorandhungrybutbuthappy:bounty-2-orderbook-tests
Open

Add orderbook cancellation depth tests#3
poorandhungrybutbuthappy wants to merge 5 commits into
jackjin1997:mainfrom
poorandhungrybutbuthappy:bounty-2-orderbook-tests

Conversation

@poorandhungrybutbuthappy

@poorandhungrybutbuthappy poorandhungrybutbuthappy commented Jun 19, 2026

Copy link
Copy Markdown

Summary

Adds focused Go coverage for the orderbook cancellation and snapshot-depth behavior requested in #2.

Closes #2.

Changes

  • Adds bid cancellation coverage that verifies depth removal and order-index deletion.
  • Verifies cancelling a middle bid preserves surrounding price levels.
  • Verifies cancelling one of two same-price bids preserves the remaining price, quantity, count, and order index entry.
  • Adds ask cancellation, unknown-order, and closed-book error coverage.
  • Adds snapshot immutability coverage for bid and ask level copies.
  • Adds the required encrypted build diagnostic bundle generated with the repository's Linux x64 encryptly tooling.

Testing

  • go test -count=1 ./orderbook from market/ - passed locally and on GitHub Actions.
  • go vet ./orderbook - passed locally and on GitHub Actions.
  • go build -o market . from market/ - passed locally.
  • python3 build.py -m market - passed on an Ubuntu GitHub Actions runner; market reported PASS.
  • Generated diagnostic/build-93e73b32.logd and matching metadata. The metadata uses a project-relative artifact path.

Checklist

  • Relevant modules affected by these changes build locally
  • Tests pass locally
  • Diagnostic build log is committed in this PR
  • Documentation has been updated, if applicable
  • Configuration or schema changes are documented, if applicable
  • No generated build artifacts are committed, except the required diagnostic build log
  • Changes are scoped to the PR purpose and avoid unrelated cleanup
  • Security, privacy, and error-handling implications have been considered

  • I would like to request that my diagnostic build log is removed before merging

Summary by CodeRabbit

  • Tests
    • Added unit tests covering order cancellation behavior, including removal of bid/ask levels, correct status updates, and internal bookkeeping validation.
    • Verifies proper error handling when cancelling unknown orders (ErrOrderNotFound) and when operations are attempted on a closed book (ErrBookClosed).
    • Added snapshot integrity checks to ensure returned bid/ask level data is immutable copies (mutations to a snapshot don't affect future snapshots).

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds OrderBook unit tests for cancellation outcomes, shared-price depth handling, closed-book and missing-order errors, and snapshot immutability, plus a diagnostic JSON file with build metadata, artifact references, module results, and a PR note.

Changes

OrderBook tests and build diagnostics

Layer / File(s) Summary
OrderBook cancel and snapshot tests
market/orderbook/orderbook_test.go
Adds test helpers and coverage for bid/ask cancellation, preservation of unaffected price levels, shared-price remaining depth, missing-order and closed-book errors, and immutable snapshots returned by GetSnapshot().
Diagnostic build metadata
diagnostic/build-93e73b32.json
Adds generated diagnostic metadata with commit/build timestamps, encrypted artifact details, decrypt instructions, module pass/fail counts, and a PR note for including the .logd artifact.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

  • jackjin1997/zeroeye#2 — The PR adds the described OrderBook cancellation, closed-book, missing-order, and snapshot immutability tests, along with the diagnostic artifact metadata.

Poem

🐇 I thumped through bids and asks today,
Cancelled trails still kept depth in play.
Fresh snapshots stayed crisp and bright,
Untouched by paws from earlier sight.
A logd note now rides along—
Soft code, neat burrow, tidy song.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add orderbook cancellation depth tests' clearly and concisely describes the primary change: adding test coverage for orderbook cancellation behavior with depth verification.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR description follows the required template and includes a clear summary, changes, testing, and completed checklist items.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. I don't see the encrypted build diagnostic log artifact (*.logd / builds.compact) committed on this branch yet. Please rerun the build diagnostic/encryption step with the fixed encryptly tooling and commit the generated encrypted log artifact to this PR (typically under diagnostic/).

Blocking review until the encrypted diagnostic log artifact is present.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@diagnostic/build-5a585c38.json`:
- Around line 8-9: The diagnostic/build-5a585c38.json file contains plaintext
passwords in both the "password" field on line 8 and within the
"decrypt_command" value on line 9. Remove these sensitive credentials by either
deleting the entire "password" field and its value, or redacting it with a
placeholder like "<redacted>". Additionally, replace the inline password
appearing in the decrypt_command string with the same redaction placeholder to
ensure no plaintext secrets are committed to the repository.
🪄 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: cfe98f10-dcbd-4906-9b42-9f4a331f50b4

📥 Commits

Reviewing files that changed from the base of the PR and between 4162088 and 79561d1.

📒 Files selected for processing (2)
  • diagnostic/build-5a585c38.json
  • diagnostic/build-5a585c38.logd

Comment thread diagnostic/build-5a585c38.json Outdated
@poorandhungrybutbuthappy

Copy link
Copy Markdown
Author

Added the required encrypted diagnostic bundle in commit 79561d1:

  • diagnostic/build-5a585c38.logd
  • diagnostic/build-5a585c38.json

Validation completed:

  • go test ./orderbook passed locally and on the Linux runner
  • go build -o market . passed locally
  • python3 build.py -m market reported market: PASS
  • diagnostic metadata uses the project-relative artifact path market/market

The temporary generation workflow removed itself and is absent from the final PR diff. Please re-review.

@poorandhungrybutbuthappy

Copy link
Copy Markdown
Author

Strengthened the submission against the full issue criteria in commit 93e73b3:

  • added coverage that cancelling a middle bid preserves the surrounding price levels
  • added same-price cancellation coverage for remaining price, quantity, count, and order-index integrity
  • added comments for all test/helper functions; CodeRabbit now reports 100% docstring coverage and 5/5 pre-merge checks
  • regenerated the encrypted diagnostic as diagnostic/build-93e73b32.logd with matching JSON

Fresh validation passed locally and on the Linux runner:

  • go test -count=1 ./orderbook
  • go vet ./orderbook
  • python3 build.py -m market (market: PASS)

The final PR diff remains scoped to the orderbook tests and the required diagnostic bundle. Ready for final review.

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.

[$40 BOUNTY] [Go] Add order book cancellation depth tests

1 participant