wharfkit / antelope

Core types, client interfaces, and other tools for working with Antelope-based blockchains.
Other
42 stars 23 forks source link

Stop the mutation of the `object` parameter #82

Closed aaroncox closed 10 months ago

aaroncox commented 10 months ago

I just ran into a situation while working on the Session Kit unit tests, where I was reusing the same Action over and over again in multiple tests, and while using the resulting Action in the serializer I started getting this error:

Error: assertion failure with message: datastream attempted to read past the end

When running individual tests in isolation... the bug wouldn't occur, it'd only occur when I was running bulk unit tests that utilized the same Action. So I started debugging and noticed this instance of parameter mutation on Action.from(). By simply tweaking this to not mutate the function parameter, the error message above no longer occurs.

All this change does is renames the input parameter and then creates a new reassignable let that had the previous name, allowing the code to continue on as normal without mutating the input parameter.