Page MenuHomePhabricator

[chronik] Add assert_status_code_eq! macro to bitcoinsuite-chronik-client
ClosedPublic

Authored by hazzarust on Wed, Mar 12, 14:13.

Details

Reviewers
Fabien
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Restricted Project
Commits
rABCe3e84199d89c: [chronik] Add assert_status_code_eq! macro to bitcoinsuite-chronik-client
Summary

Created an assert_status_code_eq! to extract the status_code of forced errors and then compare and panic if the expressions don't match. This was implemented to reduce the boilerplate of previously downcasting every error manually.

Test Plan

Please set BUILD_DIR env to export BUILD_DIR="/path/to/build_dir
UNIX: ./contrib/teamcity/build-configurations.py build-bitcoinsuite-chronik-client
cargo test --nocapture

Diff Detail

Repository
rABC Bitcoin ABC
Branch
status_error
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 32705
Build 64898: Build Diffbuild-bitcoinsuite-chronik-client
Build 64897: arc lint + arc unit

Event Timeline

Owners added a reviewer: Restricted Owners Package.Wed, Mar 12, 14:13
Fabien requested changes to this revision.Wed, Mar 12, 14:15
Fabien added a subscriber: Fabien.
Fabien added inline comments.
modules/bitcoinsuite-chronik-client/tests/block_and_blocks.rs
124 ↗(On Diff #53043)

You can improve the api:

assert_status_code(result, 400);
This revision now requires changes to proceed.Wed, Mar 12, 14:15
modules/bitcoinsuite-chronik-client/tests/block_and_blocks.rs
124 ↗(On Diff #53043)

You can improve the api:

assert_status_code(result, 400);

assert_error_status_code is even better, because code 200 is no error and this code don't cover this case

Removed the impl function and made into macro

Fabien requested changes to this revision.Wed, Mar 12, 19:27

Please update your title and summary

modules/bitcoinsuite-chronik-client/tests/test_chronik_client.rs
450 ↗(On Diff #53051)

You don't need to test the test fixtures, which in turns is a duplicata of the client block tests where it already gets coverage

This revision now requires changes to proceed.Wed, Mar 12, 19:27
hazzarust retitled this revision from [chronik] Add extract_status_code function to bitcoinsuite-chronik-client to [chronik] Add assert_status_code_eq! macro to bitcoinsuite-chronik-client.Thu, Mar 13, 11:29
hazzarust edited the summary of this revision. (Show Details)
hazzarust edited the summary of this revision. (Show Details)

Removed test and changed title + summary

This revision is now accepted and ready to land.Thu, Mar 13, 13:07