XRPLF / rippled

Decentralized cryptocurrency blockchain daemon implementing the XRP Ledger protocol in C++
https://xrpl.org
ISC License
4.48k stars 1.44k forks source link

Price Oracle: validate input parameters and extend test coverage: #5013

Closed gregtatcam closed 1 month ago

gregtatcam commented 1 month ago

High Level Overview of Change

Validate trim, time_threshold, document_id are valid Int, UInt, or string convertible to UInt. Validate base_asset and quote_asset are valid currency. Update error codes. Extend Oracle and GetAggregatePrice unit-tests. Denote unreachable coverage code.

Type of Change

Before / After

Fixes invalid input parameters conversion to uint. For instance, 1.2 was converted to 1 if passed to trim, time_threshold, or document_id. This only allows valid UInt values. Similarly, base_asset and quote_asset were not validated to be a valid currency code. This fix only allows valid currency codes in base_asset and quote_asset.

Test Plan

Extended Oracle and GetAggregatePrices tests.

codecov-commenter commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 71.0%. Comparing base (f650949) to head (848fa68).

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/XRPLF/rippled/pull/5013/graphs/tree.svg?width=650&height=150&src=pr&token=i2RPGI5xGF&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XRPLF)](https://app.codecov.io/gh/XRPLF/rippled/pull/5013?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XRPLF) ```diff @@ Coverage Diff @@ ## develop #5013 +/- ## ========================================= + Coverage 70.9% 71.0% +0.1% ========================================= Files 796 796 Lines 66792 66793 +1 Branches 10998 10986 -12 ========================================= + Hits 47377 47420 +43 + Misses 19415 19373 -42 ``` | [Files](https://app.codecov.io/gh/XRPLF/rippled/pull/5013?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XRPLF) | Coverage Δ | | |---|---|---| | [src/ripple/app/tx/impl/DeleteOracle.cpp](https://app.codecov.io/gh/XRPLF/rippled/pull/5013?src=pr&el=tree&filepath=src%2Fripple%2Fapp%2Ftx%2Fimpl%2FDeleteOracle.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XRPLF#diff-c3JjL3JpcHBsZS9hcHAvdHgvaW1wbC9EZWxldGVPcmFjbGUuY3Bw) | `100.0% <ø> (+27.5%)` | :arrow_up: | | [src/ripple/app/tx/impl/SetOracle.cpp](https://app.codecov.io/gh/XRPLF/rippled/pull/5013?src=pr&el=tree&filepath=src%2Fripple%2Fapp%2Ftx%2Fimpl%2FSetOracle.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XRPLF#diff-c3JjL3JpcHBsZS9hcHAvdHgvaW1wbC9TZXRPcmFjbGUuY3Bw) | `100.0% <ø> (+5.6%)` | :arrow_up: | | [src/ripple/rpc/handlers/GetAggregatePrice.cpp](https://app.codecov.io/gh/XRPLF/rippled/pull/5013?src=pr&el=tree&filepath=src%2Fripple%2Frpc%2Fhandlers%2FGetAggregatePrice.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XRPLF#diff-c3JjL3JpcHBsZS9ycGMvaGFuZGxlcnMvR2V0QWdncmVnYXRlUHJpY2UuY3Bw) | `100.0% <100.0%> (+8.0%)` | :arrow_up: | | [src/ripple/rpc/handlers/LedgerEntry.cpp](https://app.codecov.io/gh/XRPLF/rippled/pull/5013?src=pr&el=tree&filepath=src%2Fripple%2Frpc%2Fhandlers%2FLedgerEntry.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XRPLF#diff-c3JjL3JpcHBsZS9ycGMvaGFuZGxlcnMvTGVkZ2VyRW50cnkuY3Bw) | `81.9% <100.0%> (+1.0%)` | :arrow_up: | ... and [4 files with indirect coverage changes](https://app.codecov.io/gh/XRPLF/rippled/pull/5013/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XRPLF) [![Impacted file tree graph](https://app.codecov.io/gh/XRPLF/rippled/pull/5013/graphs/tree.svg?width=650&height=150&src=pr&token=i2RPGI5xGF&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XRPLF)](https://app.codecov.io/gh/XRPLF/rippled/pull/5013?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XRPLF)