Page MenuHomePhabricator

[Chronik] Add failover.ts integration test to chronik-client
ClosedPublic

Authored by hazzarust on Jun 17 2025, 14:14.

Details

Reviewers
Fabien
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Restricted Project
Commits
rABCd63ee166f343: [Chronik] Add failover.ts integration test to chronik-client
Summary

We spin up 3 nodes using Python, and then stop them 1 by 1 to test the failover works.

We check to make sure the failover is working by:

Connect to a new node after we force current node to stop.

Assert that the node is indeed stopped.

Mine a block on new node, ensure we still receive subscription updates.

Call blockchain.info() on the node.

Test Plan

cd modules/chronik-client/test
npx mocha -j1 -r ts-node/register test/integration/failover.ts

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

hazzarust created this revision.
Fabien requested changes to this revision.Jun 17 2025, 14:36
Fabien added a subscriber: Fabien.

Your first step is not used at all. You should use it to check that node0 is initially working (the same way you check it doesn't connect in step 2). Just move the stop_node(0) call at the beginning of step 2 instead

modules/chronik-client/test/integration/failover.ts
49 ↗(On Diff #54514)

Remove

124 ↗(On Diff #54514)

You can check the hash instead of its length

149 ↗(On Diff #54514)

Ditto

153 ↗(On Diff #54514)

Just use the full array you should get the same result instead of going one by one

test/functional/setup_scripts/chronik-client_failover.py
24 ↗(On Diff #54514)

Remove the newline

26 ↗(On Diff #54514)

Just use self.nodes[] in the test, you don't gain much with this

35 ↗(On Diff #54514)

It's never used, no need to mine

41 ↗(On Diff #54514)

Remove

42 ↗(On Diff #54514)

Just call it tip, it's not the next blockhash but the current one

48 ↗(On Diff #54514)

Ditto

This revision now requires changes to proceed.Jun 17 2025, 14:36
hazzarust edited the summary of this revision. (Show Details)

Updated nextBlockhash to be tipHash, removed empty line, checked hash instead of length after calling blockchain.info()

Fabien requested changes to this revision.Jun 18 2025, 07:22
Fabien added inline comments.
modules/chronik-client/test/integration/failover.ts
120 ↗(On Diff #54519)

you didn't get it:
expect(blockchainInfo.tipHash).to.eql(tipHash);

143 ↗(On Diff #54519)

ditto

test/functional/setup_scripts/chronik-client_failover.py
31–37 ↗(On Diff #54519)

Just remove this step and do it all at once

36 ↗(On Diff #54519)

nit: in python we use snake case, so tip_hash (you can keep the message name tipHash, just rename the python variable)

This revision now requires changes to proceed.Jun 18 2025, 07:22
Fabien requested changes to this revision.Jun 19 2025, 07:38
Fabien added inline comments.
modules/chronik-client/test/integration/failover.ts
65 ↗(On Diff #54524)

just remove this one instead

test/functional/setup_scripts/chronik-client_failover.py
24 ↗(On Diff #54524)

you don't need this one

This revision now requires changes to proceed.Jun 19 2025, 07:38
This revision is now accepted and ready to land.Jun 23 2025, 14:43