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

fix: add attribute nil verifications in chainReader #448

Merged
merged 26 commits into from
Jan 21, 2025

Conversation

maximopalopoli
Copy link
Contributor

@maximopalopoli maximopalopoli commented Jan 17, 2025

What Changed?

Some chainReader methods currently does not verify that some attributes are not nil before accessing them. This PR aims to fix this and add some test cases covering it.

Also renames a variable that had a generic name for a more proper one.

Note: This PR respects structure from #447 and it's recommended to merge after it.

Reviewer Checklist

  • Code is well-documented
  • Code adheres to Go naming conventions
  • Code deprecates any old functionality before removing it

@maximopalopoli maximopalopoli marked this pull request as ready for review January 17, 2025 20:59
@pablodeymo
Copy link
Contributor

We should use errors.Wrap

@maximopalopoli maximopalopoli marked this pull request as draft January 20, 2025 18:13
@maximopalopoli maximopalopoli marked this pull request as ready for review January 20, 2025 18:51
Copy link
Contributor

@damiramirez damiramirez left a comment

Choose a reason for hiding this comment

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

LGTM! Just left some comments


_ = contractAddrs
_ = operator
_ = chainReader
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we going to use these variables? Otherwise we can remove them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines 760 to 763
assert.Zero(t, strategy)
assert.Zero(t, undToken)
assert.Error(t, err)
assert.Equal(t, err.Error(), "Failed to fetch token contract: no contract code at given address")
Copy link
Contributor

Choose a reason for hiding this comment

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

If we know that this function will throw an error, is it necessary to check the strategy and undToken?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines 768 to 772
assert.Zero(t, strategy)
assert.Zero(t, methods)
assert.Zero(t, undToken)
assert.Error(t, err)
assert.Equal(t, err.Error(), "Failed to fetch token contract: no contract code at given address")
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pablodeymo pablodeymo added this pull request to the merge queue Jan 21, 2025
Merged via the queue into Layr-Labs:dev with commit bd37a31 Jan 21, 2025
4 checks passed
@pablodeymo pablodeymo deleted the add-attribute-null-verifications branch January 21, 2025 19:58
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