Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SimulatedBackendClient CallContext #11164

Merged

Conversation

EasterTheBunny
Copy link
Contributor

The function CallContext has different supported contract function calls than BatchCallContext even though the latter is simply a batch version of the former.

This commit makes the two functions match both in the supported calls, but also in the validation and execution of those calls.

Copy link
Contributor

github-actions bot commented Nov 2, 2023

I see that you haven't updated any README files. Would it make sense to do so?

Comment on lines 673 to 688
return common.HexToAddress(v), nil
case *big.Int:
return common.BigToAddress(v), nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there variants that return errors instead of failing silently?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far, the way it is used in tests, no. And it shouldn't fail silently. Everywhere this function is used will panic if it can't handle the value type. It's not ideal, but the way this is mainly used is in unit testing. So if it fails, the unit tests will fail.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Hex/BigToAddress funcs silently accept invalid values that could be difficult to debug from an indirect failure. Why don't we use IsHexAddress?
And could check for big.Int > 0 and b.Bytes() <=20?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh. Ok. I'll give that a Go...

@EasterTheBunny EasterTheBunny marked this pull request as draft November 6, 2023 14:38
@EasterTheBunny EasterTheBunny marked this pull request as ready for review November 6, 2023 20:29
@EasterTheBunny EasterTheBunny requested a review from a team as a code owner November 6, 2023 20:29
@EasterTheBunny EasterTheBunny force-pushed the AUTO-7045/update-simulated-backend-client-callcontext branch from ef51143 to 458c50e Compare November 6, 2023 20:29
default:
// panic("not implemented")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented code

EasterTheBunny and others added 9 commits November 7, 2023 11:17
The function `CallContext` has different supported contract function calls than
`BatchCallContext` even though the latter is simply a batch version of the
former.

This commit makes the two functions match both in the supported calls, but also
in the validation and execution of those calls.
Use suggestion on default address returned on error.

Co-authored-by: Jordan Krage <[email protected]>
@EasterTheBunny EasterTheBunny force-pushed the AUTO-7045/update-simulated-backend-client-callcontext branch from 2b2cf36 to d38e967 Compare November 7, 2023 16:17
@cl-sonarqube-production
Copy link

SonarQube Quality Gate

Quality Gate failed

Failed condition 63.5% 63.5% Coverage on New Code (is less than 75%)

See analysis details on SonarQube

@EasterTheBunny EasterTheBunny added this pull request to the merge queue Nov 7, 2023
Merged via the queue into develop with commit 8b4e0f8 Nov 7, 2023
83 of 84 checks passed
@EasterTheBunny EasterTheBunny deleted the AUTO-7045/update-simulated-backend-client-callcontext branch November 7, 2023 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants