bitcoindevkit / rust-esplora-client

Bitcoin Esplora API client library. Supports plaintext, TLS and Onion servers. Blocking or async.
MIT License
29 stars 44 forks source link

Add feature (parity) tests for API methods #10

Closed tnull closed 2 years ago

tnull commented 2 years ago

This PR adds basic feature (parity) tests for the API methods:

coveralls commented 2 years ago

Pull Request Test Coverage Report for Build 3105189939

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
src/lib.rs 290 291 99.66%
<!-- Total: 292 293 99.66% -->
Files with Coverage Reduction New Missed Lines %
src/lib.rs 1 95.21%
src/async.rs 11 83.64%
src/blocking.rs 29 59.5%
<!-- Total: 41 -->
Totals Coverage Status
Change from base Build 3104888700: 67.5%
Covered Lines: 632
Relevant Lines: 807

💛 - Coveralls
tnull commented 2 years ago

I now covered all feasible API methods. Testing the feature parity of get_fee_estimates is not really feasible since the results vary quite a bit.

tnull commented 2 years ago

Squashed fixups.

notmandatory commented 2 years ago

Tests look good but I'd like to see if we can run the tests against a local regtest bitcoind and esplora rather than hitting the blockstream server URL. I'm going to give it a try using the electrsd crate, feel free to give it a try also, and/or when I get it working I'll show you how to do it.

notmandatory commented 2 years ago

@tnull, @vladimirfomene has the local regtest setup working in https://github.com/vladimirfomene/rust-esplora-client/commit/829b2fce699ab6acebbe6ed54d22ca00737a4b18, I'd like to get his changes in as a setup function that all the tests can share. Then can we put each of your tests in it's own test function ? I know each test will be very small but it's a good idea for unit tests to only test a single thing, it will make it easier to read and to see if a method call fails which one it is.

tnull commented 2 years ago

@tnull, @vladimirfomene has the local regtest setup working in vladimirfomene@829b2fc, I'd like to get his changes in as a setup function that all the tests can share. Then can we put each of your tests in it's own test function ? I know each test will be very small but it's a good idea for unit tests to only test a single thing, it will make it easier to read and to see if a method call fails which one it is.

Sounds good, will add the setup function and break the test code down into individual methods!

vladimirfomene commented 2 years ago

@tnull, you can find the updated code here: https://github.com/vladimirfomene/rust-esplora-client/tree/add-testing

vladimirfomene commented 2 years ago

@tnull, will it help if I refactor my code into a setup function and write a couple of test functions?

tnull commented 2 years ago

@tnull, will it help if I refactor my code into a setup function and write a couple of test functions?

Don't worry. I already started making the changes, will probably push an update in the next 1-2 days.

tnull commented 2 years ago

Now split the tests and updated to run against local ElectrsD/BitcoinD instances.

tnull commented 2 years ago

I now covered all feasible API methods. Testing the feature parity of get_fee_estimates is not really feasible since the results vary quite a bit.

Also added basic functionality testing of get_fee_estimates now.

afilini commented 2 years ago

(needs rebase because #14 changed the CI)

tnull commented 2 years ago

(needs rebase because #14 changed the CI)

Rebased on master, squashed commits, and added a minor clippy warning fix.

tnull commented 2 years ago

Wow, clippy can be a pain 😁 . But passes CI now, squashed the fixups.

notmandatory commented 2 years ago

If ok for everyone I'd like to get this published with Vlad on Mon or Tues so we can get a PR into bdk for the next release to remove the esplora client code there and use this crate.