Automatically spawn regtest bitcoind node.
rajarshimaitra opened this issue · comments
Our current integration test in integration.rs
performs a basic swap. But it requires an already running bitcoins instance with a wallet named teleport
loaded with available balance.
This is handled in the CI by downloading and running a bitcoind binary with specific configs and performing the wallet loading part before running the tests.
This can be automated using the bitcoind
crate. https://docs.rs/bitcoind/latest/bitcoind/
Create a basic testing framework with bitcoind
crate with APIs to control the background node.
struct TestNode {
bitcoind: Bitcoind
...
}
A few important ones are
- Mine blocks,
- get transaction in mempool,
- get transaction in block,
- broadcast transaction.
- Reorg blocks.
Use the resulting Bitcoind
to connect with the taker and maker wallets. Modify the test_basic_coinswap
in /tests/integration.rs
to use the TestNode
struct. All existing tests should pass.
For reference, check out the BDK lib's testing framework: https://github.com/bitcoindevkit/bdk/blob/78529b6a429e066d5c0290111c9e26f908af5fa4/src/testutils/blockchain_tests.rs#L29-L324