Page MenuHomePhabricator

[explorer] Add test chains address support to the explorer
ClosedPublic

Authored by Fabien on Sep 5 2023, 19:52.

Details

Summary

The explorer is currently hard-coded to use the ecash: prefix. This diffs adds on optional chain parameter to the config.toml that can be set to "testnet" to use the ectest prefix instead.

Depends on D14450 for the search bar to work.

Test Plan
cd explorer-server && cargo test

Add chain: "testnet" to the config.toml file, then cargo run. Check the addresses are now displayed using the ectest: prefix. Navigate through the transaction and address pages, and use the search bar to check it works as expected.
Repeat with chain: "regtest".

Try again with a wrong chain name, check that cargo run aborts with a meaningful error message.

Diff Detail

Repository
rABC Bitcoin ABC
Branch
explorer_testnet_addresses
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 24957
Build 49502: Build Diff
Build 49501: arc lint + arc unit

Event Timeline

Fabien requested review of this revision.Sep 5 2023, 19:52
This revision now requires changes to proceed.Sep 5 2023, 21:48
web/explorer/explorer-server/src/server.rs
55–59 ↗(On Diff #42076)

Also maybe add regtest prefixes? It's actually quite useful in some cases

Support regtest addresses as well

Fabien retitled this revision from [explorer] Add testnet address support to the explorer to [explorer] Add test chains address support to the explorer.Sep 6 2023, 07:21
Fabien edited the test plan for this revision. (Show Details)
tobias_ruck added inline comments.
web/explorer/explorer-server/src/server.rs
50

It may also be a good idea to use an enum here (enum Chain { Mainnet, Testnet, Regtest }), you can implement FromStr for it, even return an error from there, and then parse it in main using chain.parse

58

Are you sure this is reasonable behavouir? If someone specifies "chipnet" or something invalid like that it's going to interpret that as "mainnet". Might be confusing.

This revision now requires changes to proceed.Sep 7 2023, 09:35

Use a Chain enum that implements the FromStr trait

This revision is now accepted and ready to land.Sep 7 2023, 14:03