-
Notifications
You must be signed in to change notification settings - Fork 129
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
chore(tests): use mockery constructors to ensure assertions #2500
Conversation
c6130b5
to
07a6e7e
Compare
07a6e7e
to
70fe90b
Compare
70fe90b
to
636d8ff
Compare
636d8ff
to
c28019c
Compare
c3c777e
to
410b1dc
Compare
cc6bc64
to
d48da71
Compare
lib/babe/babe.go
Outdated
if cfg.BlockImportHandler == nil { | ||
return nil, errNilBlockImportHandler | ||
} | ||
|
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.
Note this is removed to allow to have nil
block import handler in test code.
Anyway imo this check shouldn't be there, and we should panic if we try to pass a nil handler.
if cfg == nil { | ||
cfg = &ServiceConfig{ | ||
Authority: true, | ||
} | ||
} | ||
|
||
cfg.BlockImportHandler = new(mocks.BlockImportHandler) | ||
cfg.BlockImportHandler.(*mocks.BlockImportHandler). | ||
On("HandleBlockProduced", | ||
mock.AnythingOfType("*types.Block"), mock.AnythingOfType("*storage.TrieState")). | ||
Return(nil) | ||
|
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.
note this is pushed back up to the caller (tests), since it was differing from one test to the other.
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.
Looks good. I will probably wait to merge my branch in so that I can use these changes and not have to duplicate (or create more conflicts)
d48da71
to
e4706b2
Compare
- Add missing lock calls - Move wrongly placed calls - Rename `changedLock` to `observerListMutex`
e4706b2
to
53b057b
Compare
- Use generated mockery constructors for mockery mocks to ensure assertions are done in the test - Fix bugs caused by the now-fixed mock assertions - Remove existing `.Assert*` mock method calls - Fix data race in storage observers
🎉 This PR is included in version 0.7.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Changes
.Assert*
mocks callsTests
All unit tests passing
Issues
Primary Reviewer
@EclesioMeloJunior