-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add btcdctrl
& generatetoaddress
RPC
#2257
base: master
Are you sure you want to change the base?
Conversation
removes the need to run dedicated wallet when testing on simnet/regtest.
makes it possible to import `config` into another package, `params` & `log` moved to avoid circular imports.
`btcdctrl` makes it easy to programmatically run `btcd` - with a defined configuration and sensible defaults, it eases testing and managing `btcd` in production.
What does this accomplish that Can you explain the use case a bit more? |
Re the current approach to gain a free port: https://github.com/btcsuite/btcd/pull/2071/files#r1431328709 I think we can make this approach and the normal |
@Roasbeef Sure, happy to. Our goal is to make running
Our use cases so far have been, unit testing for our wallet and managing
I agree, although we'd have to listen on port |
1. killing a process then waiting for it can return an error depending on state, instead just exit the loop. 2. websockets hang indefinitely every 20 tests or so, use HTTP POST instead. 3. handle the RPC/P2P message being the last line in the log.
was missed by tests as this only appears on long-lived processes, eventually the pipe will run out of space causing `btcd` to hang.
the client could exist but with an error case, this should be handled.
This PR adds
btcdctrl
, a process controller wrappingbtcd
and providing typed configuration on par with the cli. Easing both production and testing with sensible defaults, makingbtcd
incredibly easy to run programmatically.btcdctrl
embeds an RPC client, both to ensurebtcd
is ready whenStart
is called and to lower the amount of boilerplate needed to start and connect. This somewhat overlaps withintegration/rpctest
but covers a larger amount of use-cases while overall becoming a simpler implementation.I've also added
generatetoaddress
, an RPC method which makes testing much simpler - as you no longer have to run an additional wallet for managing funds. I'm happy to split this into another PR, maintainers choice.Note:
integration/rpctest
has a race condition with the port allocation, an empty port is found then only used somewhat late in the start-up procedure - has been an issue for me, in more complex testing environments when multiple processes are looking for empty ports at the same time. I've fixed that here by using port:0
which allows the OS to allocate a free port.