Page MenuHomePhabricator

[chronik] Add websocket.rs integration test to bitcoinsuite-chronik-client
Needs RevisionPublic

Authored by hazzarust on Tue, Apr 15, 10:25.

Details

Reviewers
Fabien
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Restricted Project
Summary

The code adds WebSocket functionality for a Bitcoin blockchain explorer (Chronik), specifically the subscription and unsubscription to blocks

  • Creates a WebSocket connection to Chronik
  • Subscribes to block updates with ws_endpoint.subscribe_to_blocks()
  • Verifies subscription status with assert_eq!(ws_endpoint.subs.blocks, true)
  • Tests unsubscribing with ws_endpoint.unsubscribe_from_blocks()
  • Verifies unsubscription worked with assert_eq!(ws_endpoint.subs.blocks, false)
  • Resubscribes again
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

Event Timeline

Owners added a reviewer: Restricted Owners Package.Tue, Apr 15, 10:25
hazzarust edited the summary of this revision. (Show Details)

lint

Tail of the build log:

test test_raw_tx ... ok
test test_broadcast_txs ... ok
test test_raw_tx_missing ... ok
test test_broadcast_tx ... ok
test test_block ... ok
test test_tx ... ok
test test_tx_missing ... ok
test test_block_txs ... ok

test result: ok. 14 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 2.22s

     Running tests/websocket.rs (/work/target/debug/deps/websocket-c44ec198b8e10aaa)

running 1 test
test websocket ... FAILED

failures:

---- websocket stdout ----
Starting test_runner for chronik-client_websocket
Rust IPC server is listening on "/tmp/websocket.socket"
Sent: next
Sent: next
Sent: stop
thread 'websocket' panicked at modules/bitcoinsuite-chronik-client/tests/websocket.rs:73:21:
internal error: entered unreachable code: An unexpected ready message was sent from the
                            setup framework, causing the counter to
                            increment beyond a valid match arm.
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Output: 2025-04-15T10:31:15.133000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/build-bitcoinsuite-chronik-client/test/tmp/test_runner_₿₵_🏃_20250415_103114/setup_scripts/chronik-client_websocket_0
2025-04-15T10:31:16.776000Z TestFramework (INFO): Passed test setup data to mocha
2025-04-15T10:31:23.110000Z TestFramework (INFO): Step 1: Avalanche finalize a block
2025-04-15T10:31:25.270000Z TestFramework (INFO): Received a stop message, exiting
2025-04-15T10:31:25.320000Z TestFramework (INFO): Stopping nodes
2025-04-15T10:31:25.472000Z TestFramework (INFO): Cleaning up /work/abc-ci-builds/build-bitcoinsuite-chronik-client/test/tmp/test_runner_₿₵_🏃_20250415_103114/setup_scripts/chronik-client_websocket_0 on exit
2025-04-15T10:31:25.472000Z TestFramework (INFO): Tests successful
Running Unit Tests for Test Framework Modules
setup_scripts/chronik-client_websocket.py started
setup_scripts/chronik-client_websocket.py passed, Duration: 10 s

TEST                                      | STATUS    | DURATION

setup_scripts/chronik-client_websocket.py | ✓ Passed  | 10 s

ALL                                       | ✓ Passed  | 10 s (accumulated) 
Runtime: 10 s


thread 'websocket' panicked at /work/modules/bitcoinsuite-chronik-client/src/test_runner.rs:82:9:
Test chronik-client_websocket failed!


failures:
    websocket

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 10.58s

error: test failed, to rerun pass `-p bitcoinsuite-chronik-client --test websocket`
Build build-bitcoinsuite-chronik-client failed with exit code 101
Fabien requested changes to this revision.Tue, Apr 15, 10:34
Fabien added a subscriber: Fabien.

It's adding code, not only testing it, please update the title/summary.

Back to your queue, the test is failing.

This revision now requires changes to proceed.Tue, Apr 15, 10:34

Tail of the build log:

test test_broadcast_txs ... ok
test test_history ... ok
test test_blocks ... ok
test test_raw_tx_missing ... ok
test test_block ... ok
test test_tx_missing ... ok
test test_tx ... ok
test test_block_txs ... ok

test result: ok. 14 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 2.60s

     Running tests/websocket.rs (/work/target/debug/deps/websocket-c44ec198b8e10aaa)

running 1 test
test websocket ... FAILED

failures:

---- websocket stdout ----
Starting test_runner for chronik-client_websocket
Rust IPC server is listening on "/tmp/websocket.socket"
Sent: next
Sent: next
Sent: stop
thread 'websocket' panicked at modules/bitcoinsuite-chronik-client/tests/websocket.rs:73:21:
internal error: entered unreachable code: An unexpected ready message was sent from the
                            setup framework, causing the counter to
                            increment beyond a valid match arm.
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Output: 2025-04-15T10:36:24.177000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/build-bitcoinsuite-chronik-client/test/tmp/test_runner_₿₵_🏃_20250415_103624/setup_scripts/chronik-client_websocket_0
2025-04-15T10:36:26.472000Z TestFramework (INFO): Passed test setup data to mocha
2025-04-15T10:36:33.809000Z TestFramework (INFO): Step 1: Avalanche finalize a block
2025-04-15T10:36:36.152000Z TestFramework (INFO): Received a stop message, exiting
2025-04-15T10:36:36.202000Z TestFramework (INFO): Stopping nodes
2025-04-15T10:36:36.406000Z TestFramework (INFO): Cleaning up /work/abc-ci-builds/build-bitcoinsuite-chronik-client/test/tmp/test_runner_₿₵_🏃_20250415_103624/setup_scripts/chronik-client_websocket_0 on exit
2025-04-15T10:36:36.406000Z TestFramework (INFO): Tests successful
Running Unit Tests for Test Framework Modules
setup_scripts/chronik-client_websocket.py started
setup_scripts/chronik-client_websocket.py passed, Duration: 12 s

TEST                                      | STATUS    | DURATION

setup_scripts/chronik-client_websocket.py | ✓ Passed  | 12 s

ALL                                       | ✓ Passed  | 12 s (accumulated) 
Runtime: 12 s


thread 'websocket' panicked at /work/modules/bitcoinsuite-chronik-client/src/test_runner.rs:82:9:
Test chronik-client_websocket failed!


failures:
    websocket

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 12.47s

error: test failed, to rerun pass `-p bitcoinsuite-chronik-client --test websocket`
Build build-bitcoinsuite-chronik-client failed with exit code 101
hazzarust retitled this revision from [chronik] Test subscribe and unsubscribe_to_blocks behaviour in bitcoinsuite-chronik-client to [chronik] Add websocket.rs integration test to bitcoinsuite-chronik-client.Tue, Apr 15, 10:40
hazzarust edited the summary of this revision. (Show Details)
hazzarust edited the summary of this revision. (Show Details)

Added new branch arms (last time committed wrong change ..)

Tail of the build log:

   Compiling yoke v0.7.5
   Compiling rand_chacha v0.9.0
   Compiling zerovec v0.10.4
   Compiling rand v0.9.0
   Compiling tinystr v0.7.6
   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 prost-types v0.11.9
   Compiling bitcoinsuite-core v0.1.0 (/work/chronik/bitcoinsuite-core)
   Compiling icu_normalizer v1.5.0
   Compiling tungstenite v0.26.2
   Compiling abc-rust-error v0.1.0 (/work/chronik/abc-rust-error)
   Compiling http-body v0.4.6
   Compiling idna_adapter v1.2.0
   Compiling idna v1.0.3
   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 tokio-tungstenite v0.26.2
   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.22s
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 pretty_assertions v1.4.1
  Downloaded yansi v1.0.1
  Downloaded diff v0.1.13
   Compiling diff v0.1.13
   Compiling yansi v1.0.1
   Compiling pretty_assertions v1.4.1
   Compiling bitcoinsuite-chronik-client v0.1.0 (/work/modules/bitcoinsuite-chronik-client)
error[E0658]: exclusive range pattern syntax is experimental
  --> modules/bitcoinsuite-chronik-client/tests/websocket.rs:71:17
   |
71 |                 2..15 => {}
   |                 ^^^^^
   |
   = note: see issue #37854 <https://github.com/rust-lang/rust/issues/37854> for more information

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

Tail of the build log:

  ecc.ts                       |   13.11 |     62.5 |    8.51 |    25.8 | 54-90,110-118,131-167     
  hash.ts                      |   41.46 |    83.33 |   26.66 |   80.95 | 26,35,38,41               
  hdwallet.ts                  |       0 |        0 |       0 |       0 | 12-176                    
  hmac.ts                      |       0 |        0 |       0 |       0 | 16-73                     
  index.ts                     |       0 |        0 |       0 |       0 |                           
  indexBrowser.ts              |       0 |        0 |       0 |       0 |                           
  indexNodeJs.ts               |       0 |        0 |       0 |       0 |                           
  initBrowser.ts               |       0 |      100 |       0 |       0 | 11-17                     
  initNodeJs.ts                |   54.54 |      100 |     100 |      80 | 10                        
  messages.ts                  |       0 |        0 |       0 |       0 | 18-123                    
  mnemonic.ts                  |       0 |        0 |       0 |       0 | 9-144                     
  op.ts                        |   20.13 |    23.33 |   36.36 |   39.47 | ...09,111,119-124,135-163 
  opcode.ts                    |    50.2 |    83.33 |     100 |     100 | 1                         
  pbkdf2.ts                    |       0 |      100 |       0 |       0 | 17-51                     
  script.ts                    |   28.44 |    20.58 |   29.03 |   50.87 | ...33-144,150,160,182-193 
  sigHashType.ts               |      40 |       25 |   46.15 |   78.94 | 26-38                     
  tx.ts                        |   47.25 |    45.23 |   47.61 |   87.23 | 110,114,123-125,144       
  txBuilder.ts                 |   40.74 |    33.92 |   54.54 |   80.43 | ...62,181-186,191,261-265 
  unsignedTx.ts                |   25.27 |       16 |   30.76 |   46.15 | ...12,320,326-329,345,357 
 src/address                   |   11.35 |    15.15 |    5.12 |   22.41 |                           
  address.ts                   |   10.95 |    11.36 |    3.22 |   21.05 | ...39-240,255-256,266-344 
  legacyaddr.ts                |   12.04 |    22.72 |    12.5 |      25 | ...9,23-38,70-111,124-128 
 src/ffi                       |   14.37 |    12.87 |    8.25 |   14.54 |                           
  ecash_lib_wasm_bg_browser.js |       0 |      100 |     100 |       0 | 1                         
  ecash_lib_wasm_browser.js    |       0 |        0 |       0 |       0 | 3-681                     
  ecash_lib_wasm_nodejs.js     |    29.9 |    36.11 |   17.64 |   30.09 | ...19,526-591,597-598,602 
 src/io                        |   30.79 |    41.17 |   39.06 |   59.55 |                           
  bytes.ts                     |    8.19 |       60 |   11.76 |   16.12 | 12,23-74                  
  hex.ts                       |   41.55 |       50 |   44.44 |   82.35 | 41-45,50,58               
  int.ts                       |       0 |        0 |       0 |       0 |                           
  str.ts                       |   46.15 |    83.33 |      40 |   85.71 | 15                        
  varsize.ts                   |   16.32 |    21.05 |      40 |      32 | 14-24,40-47               
  writer.ts                    |       0 |        0 |       0 |       0 |                           
  writerbytes.ts               |   42.62 |    40.62 |   53.33 |   83.87 | 34,44,54,64,80            
  writerlength.ts              |   53.33 |    83.33 |   53.84 |     100 | 1                         
 src/payment                   |       0 |        0 |       0 |       0 |                           
  asn1.ts                      |       0 |        0 |       0 |       0 | 77-439                    
  index.ts                     |       0 |        0 |       0 |       0 |                           
  x509.ts                      |       0 |      100 |     100 |       0 | 5-15                      
 src/test                      |   46.05 |    37.68 |      50 |   89.04 |                           
  testRunner.ts                |   46.05 |    37.68 |      50 |   89.04 | 66-68,81-82,105,114,157   
 src/token                     |   45.48 |    43.96 |      50 |   87.07 |                           
  alp.ts                       |    42.5 |    53.12 |   43.47 |   82.92 | 110-123,142               
  common.ts                    |   54.54 |    83.33 |     100 |     100 | 1                         
  empp.ts                      |   52.17 |       60 |   57.14 |   91.66 | 12                        
  slp.ts                       |   46.97 |    33.82 |      52 |   89.74 | ...61,167,175,178,197,202 
-------------------------------|---------|----------|---------|---------|---------------------------

##teamcity[blockOpened name='Code Coverage Summary']
##teamcity[buildStatisticValue key='CodeCoverageAbsBCovered' value='865']
##teamcity[buildStatisticValue key='CodeCoverageAbsBTotal' value='3994']
##teamcity[buildStatisticValue key='CodeCoverageAbsRCovered' value='263']
##teamcity[buildStatisticValue key='CodeCoverageAbsRTotal' value='1102']
##teamcity[buildStatisticValue key='CodeCoverageAbsMCovered' value='144']
##teamcity[buildStatisticValue key='CodeCoverageAbsMTotal' value='665']
##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='844']
##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='2866']
##teamcity[blockClosed name='Code Coverage Summary']
mv: cannot stat 'test_results/ecash-lib-integration-tests-junit.xml': No such file or directory
Build ecash-lib-integration-tests failed with exit code 1

Changed range (looks like CICD didn't like the old range)

Fabien requested changes to this revision.Tue, Apr 15, 14:25
Fabien added inline comments.
modules/bitcoinsuite-chronik-client/src/lib.rs
6

don't pull it and use hex:: directly

278

soooooooooon
Also move the comment on the line above

518

what a question

modules/bitcoinsuite-chronik-client/tests/websocket.rs
69

I'm sure you can test getting blocks with subscribe_to_blocks() being implemented

This revision now requires changes to proceed.Tue, Apr 15, 14:25

The title is still not good