-
Notifications
You must be signed in to change notification settings - Fork 17
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 consensus admin dman #151
base: candidate
Are you sure you want to change the base?
Test consensus admin dman #151
Conversation
- Fixed bug in actors where downloads were being retried when they shouldn't - Added type assertions to internaltypes - Fixed empty func in peer.go
consensus/db/db.go
Outdated
@@ -1699,7 +1700,7 @@ func (pni *PendingLeafIter) Close() { | |||
|
|||
func (db *Database) SetSafeToProceed(txn *badger.Txn, height uint32, isSafe bool) error { | |||
if height%constants.EpochLength != 1 { | |||
panic("The height must be mod 1 epoch length") | |||
panic(fmt.Errorf("the height must be mod 1 epoch length. height: %v\n", height)) |
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.
nit: panic internally just converts the error to a string, which negates the need to do fmt.Errorf
. You can just do a fmt.Sprintf
if you want to convert to format a string. Also the trailing \n
isn't needed as panic inserts one automatically.
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 point, I'll improve this on the next commit
consensus/db/db.go
Outdated
@@ -1699,7 +1700,7 @@ func (pni *PendingLeafIter) Close() { | |||
|
|||
func (db *Database) SetSafeToProceed(txn *badger.Txn, height uint32, isSafe bool) error { | |||
if height%constants.EpochLength != 1 { | |||
panic("The height must be mod 1 epoch length") | |||
panic(fmt.Errorf("the height must be mod 1 epoch length. height: %v\n", height)) |
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.
nit: panic internally just converts the error to a string, which negates the need to do fmt.Errorf
. You can just do a fmt.Sprintf
if you want to convert to format a string. Also the trailing \n
isn't needed as panic inserts one automatically.
@@ -74,9 +76,15 @@ type testingProxy struct { | |||
skipCallCheck bool | |||
} | |||
|
|||
// assert struct `testingProxy` implements `reqBusView` , `txMarshaller`, `databaseView` and `typeProxyIface` interfaces |
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.
question: Does it matter if testingProxy
doesn't implement these interfaces if tests cover that functionality?
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.
Some parts of the code require interfaces to be passed in as arguments and this ensures the testingProxy
struct actually implements the required interfaces. Note that testingProxy
mocks functionality to better test these components in isolation.
var _ txMarshaller = &testingProxy{} | ||
var _ databaseView = &testingProxy{} | ||
var _ typeProxyIface = &testingProxy{} | ||
|
||
func (trb *testingProxy) checkExpect() error { |
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.
nit: Might be a good idea to convert these functions into test helpers (take a *t.Testing
and call t.Helper()
at the start) so that you can just t.Error
and t.Fatal
without having to worry about returning errors. Less handling on the calling test side and the test log will bubble up the checks to the failing parent test.
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.
That's an interesting idea and I see its potential in more functions like generateChain()
or makeGoodBlock()
. This particular test suite would require a great deal of rewriting to accommodate that, given its stateful nature. I'll investigate more about helper functions and learn how we can leverage them in our testing.
- Improved panic error messages
SonarCloud Quality Gate failed. 0 Bugs No Coverage information |
Scope
What is changing with this PR?
Added lots of test the the admin handler and dman packages.
Why?
To ensure greater stability on AliceNet