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

test: chainReader shares and operatorSets functions #437

Open
wants to merge 27 commits into
base: dev
Choose a base branch
from

Conversation

damiramirez
Copy link
Contributor

@damiramirez damiramirez commented Jan 14, 2025

What Changed?

This PR aims to increase the test coverage of reader.go.

Tested functions:

  • GetOperatorsForOperatorSet
  • GetNumOperatorsForOperatorSet
  • GetOperatorSetsForOperator
  • GetNumOperatorSetsForOperator
  • GetStrategiesForOperatorSet
  • GetSlashableShares
  • GetSlashableSharesForOperatorSets
  • GetSlashableSharesForOperatorSetsBefore
  • GetRegisteredSets

Reviewer Checklist

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

@damiramirez damiramirez marked this pull request as ready for review January 17, 2025 19:17
Copy link
Contributor

@maximopalopoli maximopalopoli 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 leave you some comments:


const allocationDelay = 1
const allocationMagnitude = 100
const allocationConfigurationDelay = 1200
Copy link
Contributor

Choose a reason for hiding this comment

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

These constants should be outside the test or else they can be variables.

true,
)
require.NoError(t, err)
require.Equal(t, uint64(1), receipt.Status)
Copy link
Contributor

Choose a reason for hiding this comment

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

This literal can be replaced for gethtypes.ReceiptStatusSuccessful

opSets, err := chainReader.GetOperatorSetsForOperator(context.Background(), operatorAddr)
require.NoError(t, err)
require.NotEmpty(t, opSets)
require.Len(t, opSets, 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

If opSets has len 1 then it is not empty, so one require is redundant in my opinion

operators, err := chainReader.GetOperatorsForOperatorSet(context.Background(), operatorSet)
require.NoError(t, err)
require.NotEmpty(t, operators)
require.Len(t, operators, 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto

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.

2 participants