Repository navigation
fix(repl): run create_dns_tx through AsyncAppCommand - #390
Markadrian6399 wants to merge 1 commit into
Conversation
emma31-dev
left a comment
There was a problem hiding this comment.
Thank you for picking this up!
I was thinking, Rather than adding a second CreateDnsTx dispatch here and keeping the error stub in offline.rs, consider making OfflineWalletSubCommand::execute async instead. Both call sites (main::run and repl::respond) are already async, so each collapses to cmd.execute(&mut ctx).await?, the main.rs special case can go away, and the CreateDnsTx arm in offline.rs can await AsyncAppCommand directly. That removes the need for two entry points to know which offline command is async, and avoids this dispatch logic being duplicated again if another async offline command is added. The regression test is useful.
@vadim-anfv @tvpeter What do you think of this approach instead?
|
@Markadrian6399 Another thing, It seems the signature used hasn't been added to to your github so it is showing unverified |
create_dns_tx failed in REPL mode with "CreateDnsTx is dispatched asynchronously through main". The REPL ran every offline command through the sync execute, so CreateDnsTx hit the error stub. OfflineWalletSubCommand::execute is now async, and the CreateDnsTx arm awaits the DNS command directly. main and the REPL both just await cmd.execute, so the special case in main.rs and the stub are gone. Adds a REPL regression test. Fixes bitcoindevkit#385
363fbd1 to
fe50271
Compare
|
Thanks for the suggestion, that’s much cleaner. |
emma31-dev
left a comment
There was a problem hiding this comment.
Thanks for switching to the async aggregator! The change looks good and is much cleaner than the duplicated dispatch.
However, the regression test doesn’t look updated from the first revision, and it will fail in the --all-features CI job. That build enables an online backend, which makes wallet config require --client-type and --url; the test’s setup only passes the descriptors and --database-type sqlite, so it exits with code 2 before the REPL even starts:
error: the following required arguments were not provided:
--client-type <CLIENT_TYPE>
--url <URL>
I reproduced this with --features electrum,dns_payment. It passes with only repl,dns_payment,sqlite, but that isn’t what --all-features runs. This is the same class of issue as repl_persist_tests. Could you either: gate repl_dns_tests like multipath_tests so it only runs in offline-only builds, or pass --client-type/--url conditionally based on which backend feature is enabled.
Please run cargo test --all-features --test cli before pushing.
Minor: the "Insufficient funds" assertion is a bit brittle. Asserting that the stub message is absent plus that some non-stub error occurred would be more durable.
Description
Running
wallet create_dns_txin REPL mode failed with:The same command works fine outside the REPL. The REPL handler sent all offline wallet commands through the sync
AppCommand::execute, soCreateDnsTxhit the stub inoffline.rsand errored out.This change matches on the offline subcommand in
respondand awaitsCreateDnsTxthroughAsyncAppCommand, likemain.rsalready does.Fixes #385
Notes to the reviewers
I kept the
CreateDnsTxarm inoffline.rssince that match has to be exhaustive. I only updated its error message so it points to the async path.The new imports in
repl.rsare behinddns_payment, so building with justrepldoesn't warn about unused imports.Added a regression test in
tests/integration/offline.rs.Checklists
All Submissions:
cargo fmtandcargo clippybefore committingBugfixes: