Skip to content
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

feature: add unit and integration tests to block events #8

Conversation

oleonardolima
Copy link
Owner

@oleonardolima oleonardolima commented Jun 21, 2022

Description

This PR focus on solving the issues:

Creating a test client for the Bitcoin Core RPC with bitcoind, the mempool/backend with it's docker image and testcontainers-rs. By using the test client, it's possible to run the docker containers with testcontainers, and subscribe to block-events with the subscribe to blocks fn built on #3

As a result, now we have the tests for the websocket module for message building, parsing (both for request and response) and producing the stream of BlockEvent.

Notes to the reviewers

There were some bugs while running it locally and implementing the tests, that's why it's not using -rpcuser and -rpcpassword as args in bitcoind, it's using the -rpcauth instead. The bug and further discussion is here: rust-bitcoin/bitcoind#68

We thought that we had a bug in mempool/backend while trying to use regtest as a parameter, but it's not supposed to be used, that's why we are not setting it as regtest in the docker image configuration, the discussion here: mempool/mempool#1916

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

New Features:

  • I've added tests for the new feature
  • I've added docs for the new feature
  • I've updated CHANGELOG.md

@oleonardolima oleonardolima changed the base branch from main to feature/add-blocks-stream-as-module June 24, 2022 01:41
@oleonardolima oleonardolima added the enhancement New feature or request label Jun 24, 2022
@oleonardolima oleonardolima added this to the milestone #1 milestone Jun 24, 2022
@oleonardolima
Copy link
Owner Author

This PR and its commits have been squashed and merged into #10, to make it easier for review and code checking at this stage.

oleonardolima added a commit that referenced this pull request Aug 11, 2022
…point and reorg handling) (#10)

* feature: implement an initial mempool.space websocket client, and library for block-events from #3

* feature: add unit and integration tests to block events from #8

* feat+test: add initial http client and tests

* wip(feat): add initial approach for subscribing to blocks from a starting height

* wip(feat): fix fn and use a tuple as return type for prev and new block streams

* wip(refactor): initial updates for fns refactor and architecture change

* wip(feat+refactor): add fn to process candidate BlockHeaders, handle reorg and yield BlockEvent

* wip(refactor+docs): extract fns to cache struct, and add documentation for fns, enums and structs

* wip(fixes+tests): fixes, improve error handling and add new integration tests

* wip(fix+test): fix common ancestor and fork branch bug, add new reorg tests

* fix: disconnected and connected block events emitting order for reorg events

* chore: simplify cli usage and output

* chore: update docs and readme examples, use u32 instead of u64

* fix: remaining cargo.toml conflicts from other branches

* feat: add full block stream api, better error handling
- use TryStream instead of stream, returning result instead
- use `?` operator instead of unwraping and panicking
- add new mempool.space endpoints for http client
- add features for wss:// and https:// usage
- add features for api versioning based on mempool.space backend

* refactor: do not use features expect two base_url instead, and improve error handling

- refactor and update http client, url usage and methods
- refactor and add creation methods for cache struct, use specific method to build
  initial one
- add `get_block_header` method in http client, and refactor lib to use `bitcoin::BlockHeader`
  instead of custom mempool.space `BlockExtended` struct
- refactor lib and websocket to improve error handling, update some `unwrap()` usage and
  match errors for messages in `WebSocketStream`
- remove duplicated/unused deps, and use only necessary features

* chore: add and update CHANGELOG.md file

* fix(test): docs and integration tests

- bump mempool/backend docker container version to v2.4.1
- update api+websocket client to handle genesis blocks without prev_blockhash
- update and fix integration tests to new fns and structure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

None yet

1 participant