Page MenuHomePhabricator

[chronik] Add blocktxs_and_tx_and_rawtx.rs integration test to bitcoinsuite-chronik-client
DraftPublic

Authored by hazzarust on Sat, Mar 8, 17:57.
This is a draft revision that has not yet been submitted for review.

Details

Reviewers
None
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Restricted Project
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

Diff Detail

Repository
rABC Bitcoin ABC
Branch
raw_and_blocks
Lint
Lint Passed
SeverityLocationCodeMessage
Auto-Fixmodules/bitcoinsuite-chronik-client/src/test_runner.rs:105WHITESPACE1Found trailing whitespace(s).
Auto-Fixmodules/bitcoinsuite-chronik-client/tests/blocktxs_and_tx_and_rawtx.rs:73WHITESPACE1Found trailing whitespace(s).
Unit
No Test Coverage
Build Status
Buildable 32631
Build 64750: Build Diffbuild-bitcoinsuite-chronik-client
Build 64749: arc lint + arc unit

Event Timeline

Owners added a reviewer: Restricted Owners Package.Sat, Mar 8, 17:57

Added handling of rawtxs and txs and changed get_tx to receive a TxId struct and then hash and call tx

Fabien added inline comments.
modules/bitcoinsuite-chronik-client/src/test_runner.rs
102

Why is this in the test_runner ? It's unrelated and should be in the test. If it's common to several tests we create create it's own file as needed

modules/bitcoinsuite-chronik-client/tests/blocktxs_and_tx_and_rawtx.rs
84

TxId

87

TxId

88

I think you're converting TxId (which is a subclass of Sha256d) to bytes then to Sha256d. Just use raw_txid_hash directly below, I think it works

191–202

At some point you should consider moving this code block to its own function, like assert_error_code(). This will remove (and clarify) some code from your tests.
Note this can be done in its own diff

modules/bitcoinsuite-chronik-client/src/test_runner.rs
102

This is used in

image.png (102×1 px, 40 KB)
- as its only used in 2 i will move to individual tests.

Added println! to handler as right now it displays no error upon failure. Also progressing on step 3

Tail of the build log:

   Compiling icu_collections v1.5.0
   Compiling icu_locid v1.5.0
   Compiling icu_provider v1.5.0
   Compiling icu_locid_transform v1.5.0
   Compiling icu_properties v1.5.1
   Compiling bytes v1.9.0
   Compiling serde_urlencoded v0.7.1
   Compiling tokio v1.42.0
   Compiling prost v0.11.9
   Compiling http v0.2.12
   Compiling http v1.2.0
   Compiling icu_normalizer v1.5.0
   Compiling prost-types v0.11.9
   Compiling bitcoinsuite-core v0.1.0 (/work/chronik/bitcoinsuite-core)
   Compiling idna_adapter v1.2.0
   Compiling abc-rust-error v0.1.0 (/work/chronik/abc-rust-error)
   Compiling idna v1.0.3
   Compiling http-body v0.4.6
   Compiling url v2.5.4
   Compiling prost-build v0.11.9
   Compiling chronik-proto v0.1.0 (/work/chronik/chronik-proto)
   Compiling tokio-util v0.7.13
   Compiling tokio-native-tls v0.3.1
   Compiling h2 v0.3.26
   Compiling hyper v0.14.31
   Compiling hyper-tls v0.5.0
   Compiling reqwest v0.11.27
   Compiling bitcoinsuite-chronik-client v0.1.0 (/work/modules/bitcoinsuite-chronik-client)
    Finished dev [unoptimized + debuginfo] target(s) in 19.66s
warning: virtual workspace defaulting to `resolver = "1"` despite one or more workspace members being on edition 2021 which implies `resolver = "2"`
note: to keep the current resolver, specify `workspace.resolver = "1"` in the workspace root's manifest
note: to use the edition 2021 resolver, specify `workspace.resolver = "2"` in the workspace root's manifest
note: for more details see https://doc.rust-lang.org/cargo/reference/resolver.html#resolver-versions
 Downloading crates ...
  Downloaded diff v0.1.13
  Downloaded yansi v1.0.1
  Downloaded pretty_assertions v1.4.1
   Compiling yansi v1.0.1
   Compiling diff v0.1.13
   Compiling pretty_assertions v1.4.1
   Compiling bitcoinsuite-chronik-client v0.1.0 (/work/modules/bitcoinsuite-chronik-client)
error[E0432]: unresolved import `std::os::macos`
 --> modules/bitcoinsuite-chronik-client/tests/blocktxs_and_tx_and_rawtx.rs:6:14
  |
6 | use std::os::macos::raw;
  |              ^^^^^ could not find `macos` in `os`

warning: unused import: `bitcoinsuite_core::block`
  --> modules/bitcoinsuite-chronik-client/tests/blocktxs_and_tx_and_rawtx.rs:17:5
   |
17 | use bitcoinsuite_core::block;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

For more information about this error, try `rustc --explain E0432`.
warning: `bitcoinsuite-chronik-client` (test "blocktxs_and_tx_and_rawtx") generated 1 warning
error: could not compile `bitcoinsuite-chronik-client` (test "blocktxs_and_tx_and_rawtx") due to 1 previous error; 1 warning emitted
warning: build failed, waiting for other jobs to finish...
Build build-bitcoinsuite-chronik-client failed with exit code 101