-
Notifications
You must be signed in to change notification settings - Fork 47
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: test more utils funcs #340
base: dev
Are you sure you want to change the base?
Conversation
@@ -105,6 +105,7 @@ func EcdsaPrivateKeyToAddress(privateKey *ecdsa.PrivateKey) (gethcommon.Address, | |||
return crypto.PubkeyToAddress(*publicKeyECDSA), nil | |||
} | |||
|
|||
// RoundUpDivideBig divides two positive big.Int numbers and rounds up the result. |
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.
Not sure what this is used for, but it currently doesn't handle negative numbers
return http.ErrUseLastResponse | ||
}, | ||
Timeout: 3 * time.Second, | ||
func ReadPublicURL(url string, httpClient *http.Client) ([]byte, 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.
Had to change the signature to make it possible to mock. IMO we shouldn't do real HTTP reqs from tests.
{ | ||
name: "Valid YAML", | ||
yamlContent: ` | ||
name: John Doe | ||
age: 30 | ||
`, | ||
expected: Config{Name: "John Doe", Age: 30}, | ||
}, | ||
{ | ||
name: "Missing fields", | ||
yamlContent: ` | ||
name: Alice | ||
`, | ||
expected: Config{Name: "Alice", Age: 0}, | ||
}, | ||
{ | ||
name: "Empty YAML", | ||
yamlContent: ``, | ||
expected: Config{}, | ||
}, |
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.
Not able to test with invalid values here or for TestReadJsonConfig
since it panics. Can rewrite to return an error instead of panic so this can be tested. Consider using recover, but log.Fatal
creates an unrecoverable panic.
Continuation of #336