Fix issues raised at https://reviews.bitcoinabc.org/T55
Details
- Reviewers
deadalnix freetrader kyuupichan awemany - Group Reviewers
Restricted Project - Commits
- rSTAGING1db4ca8f354a: Check for user agent string length and trim it if necessary
rABC1db4ca8f354a: Check for user agent string length and trim it if necessary
create a unit test to check userAgent() return value
Diff Detail
- Repository
- rABC Bitcoin ABC
- Branch
- master
- Lint
Lint Passed - Unit
No Test Coverage - Build Status
Buildable 437 Build 437: arc lint + arc unit
Event Timeline
With a test, that'd be great. You can mock parameters in test. See miner_tests.cpp for instance.
src/net.cpp | ||
---|---|---|
2808 | This guy also need a "\n" |
src/test/net_tests.cpp | ||
---|---|---|
191 ↗ | (On Diff #715) | I'd expect a check that the data used for the truncated uacomment is what you expect. If the string is too long, the data could be taken from the front, the back, the middle (?). It should also clearly show that a comment of length MAX_SUBVERSION_LENGTH is taken as-is and not modified (unless sanitized). |
src/net.cpp | ||
---|---|---|
2820 ↗ | (On Diff #715) | typo: length |
src/util.cpp | ||
---|---|---|
413 ↗ | (On Diff #715) | As this is only used in tests, would be good to use mapMultiArgs and clear() like Core does, ensuring no multiple entries and maybe also document that this method is intended for use by tests only. |
src/util.cpp | ||
---|---|---|
413 ↗ | (On Diff #715) | Forget about using mapMultiArgs, I overlooked it is const, just keep using _mapMultiArgs then. |
New function to add multi parameters
Add regex based test to check how userAgent() trim too long subversion string
Changes look good to me.
Tested using make check and to verify that the new test case is executed:
$ src/test/test_bitcoin --log_level=all | grep test_userAgentLength Entering test case "test_userAgentLength" Leaving test case "test_userAgentLength"; testing time: 8012mks *** No errors detected