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

style: neater leverage unit tests #1681

Open
toteki opened this issue Dec 29, 2022 · 0 comments
Open

style: neater leverage unit tests #1681

toteki opened this issue Dec 29, 2022 · 0 comments

Comments

@toteki
Copy link
Member

toteki commented Dec 29, 2022

Extracted from review on
#1654

maybe we can have a helper function:

type balances struct {
  balance, collateral, utokenSupply, exchangeRate, borrowed
}
func getBalances(ctx, addr) balances
And use it across test functions :

before := getBalances(...)
...
after := getBalances(...)
Will make the code easier to read (and much shorter)
let's create a helper function:

check := func(err, expectedDec, p) {...}
...
check(err, "0.5", p)
let's create a helper function ucoin which will do the "u/"+, and panic if denom is already a utoken,
please provide more meaningful name for [each test case]
[add comments for test cases that might be confusing in why they should fail/pass]
--- tcs := []testCase{
+++ tcs := []struct {
same for other test cases, makes it easier to read if we have type definition right next to the values.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant