Change order of checks in amm_info #4924
Open
+136
−25
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
High Level Overview of Change
Checking if account is well-formed currently happens before the check if
asset
,asset2
andamm_account
are supplied, which results in an unexpected error messages if any of the fields is malformed. Swap the order of checks, so validity of fields is verified first. Since this is a breaking change, retain the existing behaviourif (apiVersion < 3)
and add identical check, but after checks of assets and accounts,if (apiVersion >= 3)
. Also add unit tests to demonstrate the old and new behaviour.Type of Change
.gitignore
, formatting, dropping support for older tooling)API Impact
libxrpl
change (any change that may affectlibxrpl
or dependents oflibxrpl
)Before: sending an invalid account or asset to
amm_info
RPC method while other parameters are not set as expected would result inrpcINVALID_PARAMS
error. This behaviour is retained in API version 2After: sending an invalid account or asset to
amm_info
RPC method while other parameters are not set as expected will result inrpcISSUE_MALFORMED
orrpcACT_MALFORMED
error. This behaviour is new in API version 3This resolves XRPLF/clio#1157