-
Notifications
You must be signed in to change notification settings - Fork 5
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
Operator opt-out
#171
Operator opt-out
#171
Conversation
I need to explore how to test this code first so marked as a draft for now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job!
One thing that I noticed is that plugin
function doesn't return error so our app always exists gracefully with code 0 even if error occurred.
Notice here we use deprecated signature. I would propose to change this
After spending quite some time trying to test the code I'm struggling to come up with a solution. My intent is to write a test that registers an operator, checks that it's registered, unregisteres it and checks that it's no longer registered. Our entry point is There is no point in testing the CLI since it's responsible for reading the config values and passing them to
Here is the actual logic that we want to test, but in order to do so we need to construct an We could add an additional constructor that allows us to pass the dependencies or expose the If we mock it, then the only thing we can assert is that we're calling the At this point, I don't see any reason to continue pushing for a unit test: to test this behavior an integration test would be more reasonable since all the code is eventually coupled to an on-chain interaction with the AVS contracts. I'd appreciate any suggestions on how this topic: @taco-paco @Hyodar |
I agree, this is better fitted for an integration test. Actually, we don't even use the plugin We could still do it if it's desirable somehow, like:
type OperatorPlugin struct {
blsKeyPair *bls.KeyPair
ecdsaPrivateKey *ecdsa.PrivateKey
avsManager AvsManagerer
}
func NewOperatorPlugin(/* same fields as struct */) *OperatorPlugin {
// just create struct
}
func (*OperatorPlugin) OptOut() error {
// ...
}
func createMockOperatorPlugin(mockCtrl *gomock.Controller, /* keypairs... */) (*OperatorPlugin, *mocks.MockAvsManagerer) {
mockAvsManager := mocks.NewMockAvsManagerer(mockCtrl)
return NewOperatorPlugin(/* keypairs... */, mockAvsManager), mockAvsManager
}
func SomeTest(t *testing.T) {
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()
mockOperatorPlugin, mockAvsManager := createMockOperatorPlugin(mockCtrl, /* ... */)
mockAvsManager.EXPECT().DeregisterOperator(blsKeypair).Return(nil)
err := mockOperatorPlugin.OptOut()
assert.Nil(t, err)
} Then, having unit tested |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I ended up separating the
I agree and I don't think its worth pursuing any further with this task. I'll mark it as complete and we can revisit it if we find issues. |
Agreed. Only a few comments, LGTM. |
Implements #170