Skip to content

refactor(ffi): DRY the accessor layer and the lock-discipline fixtures - #1233

Draft
zancas wants to merge 1 commit into
devfrom
dry_accessor_layer
Draft

refactor(ffi): DRY the accessor layer and the lock-discipline fixtures#1233
zancas wants to merge 1 commit into
devfrom
dry_accessor_layer

Conversation

@zancas

@zancas zancas commented Jul 28, 2026

Copy link
Copy Markdown
Member

Follow-up to #1230, one commit: the DRY pass over the accessor layer and the lock-discipline tests.

The crate is edition 2024, so AsyncFnOnce closures are available. Two wrappers, with_initialized_lightclient_async and with_initialized_lightclient_read_async, now own the RT.block_on frame that 40 call sites (write and read alike, including the endpoints dev already had) repeated around their async bodies. Each converted site writes only its awaits. Five sites stay on the plain accessors on purpose: poll_sync, pause_sync, and run_sync have sync or conditional bodies, and the drain, quick_split, and execute_due_parts sites arm a progress side channel where the block_on placement is load-bearing and documented in place.

On the test side, fixture() (serial guard + offline wallet) and fixture_answer() (fixture + held-read-guard call) replace the three-line preamble the nineteen lock-discipline tests repeated. Sixteen tests fold to the combined helper; the three composite tests keep the granular pieces behind one fixture() call.

cargo check --all-targets clean, cargo nextest run -p zingo 54/54. Net −80 lines. Based on read_lock_ports (#1230); retarget to dev when that merges.

🤖 Generated with Claude Code

Nearly every lightclient accessor call site repeated the same frame:
a closure whose tail drives an async body with RT.block_on. Two
AsyncFnOnce wrappers, with_initialized_lightclient_async and its read
sibling, now own that frame, and the 40 call sites matching the shape
write only their awaits. The five sites left on the plain accessors
stay deliberately: poll_sync, pause_sync, and run_sync have sync or
conditional bodies, and the drain, quick_split, and execute_due_parts
sites arm a progress side channel where the block_on placement is
load-bearing and documented.

The lock-discipline tests likewise repeated a three-line preamble
nineteen times. fixture() takes the serial guard and builds the
offline wallet; fixture_answer() adds the held-read-guard call for
the sixteen tests with nothing in between. The three composite tests
keep the granular pieces behind one fixture() call.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@zancas
zancas requested a review from juanky201271 July 28, 2026 16:42
@zancas
zancas marked this pull request as draft July 28, 2026 19:17
@zancas
zancas requested review from dorianvp and removed request for juanky201271 July 28, 2026 19:17
Base automatically changed from read_lock_ports to dev July 29, 2026 00:10
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.

1 participant