Skip to content
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

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open

Conversation

estensen
Copy link
Contributor

Continuation of #336

@@ -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.
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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.

Comment on lines +95 to +114
{
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{},
},
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants