-
Notifications
You must be signed in to change notification settings - Fork 32
Conversation
this is great! yes this will make life a lot easier |
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!
ad35ba2
to
6db573a
Compare
6db573a
to
4cd3a31
Compare
Ok, have done, this is now ready for re-review. Have also added additional pass checks, since this test-is-implicitly-passed-if-no-error-thrown logic made me to nervous at the end, since one can just not judge if the test is running at all. |
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 great, awesome cleanup
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.
This PR got merged while I was reviewing it 😅! Nice cleanup, though.
Noticed that there are more assertions as well. From 230 to 280. 👌
It have just a little adjustment for test semantics (that's really not a big deal, just a nitpick), regarding the use of throw new Error(…)
. It does not show the expected/received values and we have to do it manually:
function compareErrorCode (t, error, errorCode) {
const msg = `should return the correct error code (expected: ${errorCode}, received: ${error.code})`
if (error.code !== errorCode) {
throw new Error(msg)
} else {
t.pass(msg)
}
Using t.equals(…)
, besides being cleaner, we automatically get the expected and received values, so there's no need to interpolate the string with them:
function compareErrorCode (t, error, errorCode) {
const msg = `should return the correct error code`
t.equals(error.code, errorCode, msg)
}
Thanks, makes sense, I will eventually place this along an another-topic-PR (or someone else can do to). Hopefully I will remember. 😄 |
This PR simplifies & wraps common code parts of the RPC test methods since there is so much code redundancy which will likely get a bit out of hand if we continue with so much copy-and-paste.
Have done this for one file only (
getBlockByHash
) for now and would apply to all RPC test files after some feedback here.