fix: preserve wallet height read errors - #21
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the execution-zone core module’s wallet height-read APIs to return a distinguishable negative sentinel on Wallet FFI failures, preventing callers from confusing an error with a valid genesis-height value.
Changes:
- Return
-1fromLEZCoreModule::get_last_synced_block()when the underlying Wallet FFI call fails. - Return
-1fromLEZCoreModule::get_current_block_height()when the underlying Wallet FFI call fails. - Update/add unit tests to cover both error paths using the new sentinel behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/lez_core_module.cpp |
Changes height-read error paths to return -1 instead of 0 on Wallet FFI failure. |
tests/test_lez_core.cpp |
Updates/extends unit coverage to assert -1 is returned on height-read FFI errors. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
483
to
487
| const WalletFfiError error = wallet_ffi_get_last_synced_block(walletHandle, &block_id); | ||
| if (error != SUCCESS) { | ||
| fprintf(stderr, "get_last_synced_block: wallet FFI error %d\n", error); | ||
| return 0; | ||
| return -1; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #20.
Wallet FFI failures during current-height or last-synced-height reads now return
-1through the existingint64_tAPI. Non-negative values remain real block heights, so consumers can distinguish an unavailable read from a valid height of zero.Tests:
nix build --no-link .#checks.x86_64-linux.unit-tests