Skip to content

Comments

cli: display bandwidth/cir as human-readable strings, update help text#3077

Open
juan-malbeclabs wants to merge 3 commits intomainfrom
jo/3055
Open

cli: display bandwidth/cir as human-readable strings, update help text#3077
juan-malbeclabs wants to merge 3 commits intomainfrom
jo/3055

Conversation

@juan-malbeclabs
Copy link
Contributor

@juan-malbeclabs juan-malbeclabs commented Feb 23, 2026

Summary of Changes

  • --bandwidth and --cir flags in interface create and interface update now require an explicit unit (Kbps, Mbps, or Gbps); bare numbers are rejected
  • interface create: --bandwidth and --cir are now optional (no default); omitting them sends 0
  • interface list displays bandwidth and CIR as human-readable strings (e.g., 1Gbps) instead of raw u64 values

Diff Breakdown

Category Files Lines (+/-) Net
Core logic 2 +11 / -9 +2
Scaffolding 2 +6 / -6 0
Tests 2 +5 / -0 +5
Docs 1 +1 / -0 +1

Small but impactful UX change: enforces explicit units on bandwidth input and improves readability of list output; tests and changelog updated accordingly.

Key files (click to expand)
  • smartcontract/programs/common/src/types/parse_utils.rsbandwidth_parse now returns an error when no unit is provided; added bandwidth_to_string for human-readable output
  • smartcontract/cli/src/device/interface/list.rs — changed bandwidth/cir display fields from u64 to String using bandwidth_to_string()
  • smartcontract/cli/src/device/interface/create.rsbandwidth and cir changed to Option<u64> with no default; help text updated
  • smartcontract/cli/src/device/interface/update.rs — updated --bandwidth and --cir help text
  • smartcontract/cli/src/validators.rs — added test cases for unit-required validation

Testing Verification

  • validate_parse_bandwidth("1000") now returns an error; validate_parse_bandwidth("1Mbps") passes
  • Updated table and JSON snapshot assertions in test_cli_device_interface_list to expect formatted strings (1Kbps, 500bps, etc.)
  • 206/206 unit tests passing

@juan-malbeclabs juan-malbeclabs linked an issue Feb 23, 2026 that may be closed by this pull request
@juan-malbeclabs juan-malbeclabs enabled auto-merge (squash) February 23, 2026 15:39
@juan-malbeclabs juan-malbeclabs marked this pull request as draft February 23, 2026 16:01
auto-merge was automatically disabled February 23, 2026 16:01

Pull request was converted to draft

@juan-malbeclabs juan-malbeclabs marked this pull request as ready for review February 23, 2026 16:20
@juan-malbeclabs juan-malbeclabs enabled auto-merge (squash) February 23, 2026 16:20
@vihu
Copy link
Contributor

vihu commented Feb 23, 2026

Just a quick note, there is some backward incompatibility introduced here which we should probably note in the CHANGELOG. Anyone who is using --output json would have got "bandwidth": 1000 now they will see "bandwidth":"1Kbps". It's a minor change but we should flag it.

@juan-malbeclabs
Copy link
Contributor Author

Right, going back to u64 and I’ll add the formatting for the table.

    #[tabled(display = "crate::util::display_as_bandwidth", rename = "bandwidth")]
    pub bandwidth: u64,

Copy link
Contributor

@elitegreg elitegreg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I typically like doing these with a type that wraps a u64 so you don't have to check the i/o every possible place in the program, it just becomes the default behavior for that type. So struct Bandwidth(u64) with FromStr, Debug, Display, Clone, Copy, PartialEq, BorshSerialize, BorshDeserialize traits should do it. Just something to consider. Not blocking this merge.

update e2e tests
- Update multicast group create/update --max-bandwidth to use unit
  suffixes (100Mbps, 200Mbps) required by the updated bandwidth parser
- Bump knownIncompatibilities[multicast_group_update] to minVersion 0.8.9:
  v0.8.1-v0.8.8 parsed --max-bandwidth as a plain integer; v0.8.9 added
  validate_parse_bandwidth (a855ca7) which accepts unit strings

Delete .devcontainer/Dockerfile

rollback the list bandwidth change

update prefx rollover test

restore .devcontainer/Dockerfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix Interface Bandwidth Value

4 participants