cli: display bandwidth/cir as human-readable strings, update help text#3077
cli: display bandwidth/cir as human-readable strings, update help text#3077juan-malbeclabs wants to merge 3 commits intomainfrom
Conversation
e2c4f9d to
d5e7b84
Compare
Pull request was converted to draft
adcd417 to
1b3a80b
Compare
|
Just a quick note, there is some backward incompatibility introduced here which we should probably note in the CHANGELOG. Anyone who is using |
|
Right, going back to u64 and I’ll add the formatting for the table. |
dd857a2 to
a8c3e69
Compare
elitegreg
left a comment
There was a problem hiding this comment.
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.
a8c3e69 to
0e33ca9
Compare
0e33ca9 to
a03fcc9
Compare
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
a03fcc9 to
78f564d
Compare
Summary of Changes
--bandwidthand--cirflags ininterface createandinterface updatenow require an explicit unit (Kbps, Mbps, or Gbps); bare numbers are rejectedinterface create:--bandwidthand--cirare now optional (no default); omitting them sends0interface listdisplays bandwidth and CIR as human-readable strings (e.g.,1Gbps) instead of raw u64 valuesDiff Breakdown
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.rs—bandwidth_parsenow returns an error when no unit is provided; addedbandwidth_to_stringfor human-readable outputsmartcontract/cli/src/device/interface/list.rs— changedbandwidth/cirdisplay fields fromu64toStringusingbandwidth_to_string()smartcontract/cli/src/device/interface/create.rs—bandwidthandcirchanged toOption<u64>with no default; help text updatedsmartcontract/cli/src/device/interface/update.rs— updated--bandwidthand--cirhelp textsmartcontract/cli/src/validators.rs— added test cases for unit-required validationTesting Verification
validate_parse_bandwidth("1000")now returns an error;validate_parse_bandwidth("1Mbps")passestest_cli_device_interface_listto expect formatted strings (1Kbps,500bps, etc.)