-
Notifications
You must be signed in to change notification settings - Fork 1
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
refactor: router #431
base: main
Are you sure you want to change the base?
refactor: router #431
Conversation
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.
@notJoon Please add a unit test for swap_multi.gno
, swap_single.gno
and wrap_unwrap.gno
.
Functions that use Pool currently doesn't have tests yet. This is because there's no way to directly access and initialize the pool's state for now.
Can you create mockup data in pool
that you can use for testing purposes in router
? This seems essential tests. Think about a way to complete tests for this please.
|
||
std.TestSetRealm(std.NewUserRealm(from)) | ||
std.TestSetOrigSend(std.Coins{{ugnotDenom, int64(amount)}}, nil) | ||
banker := std.GetBanker(std.BankerTypeRealmSend) |
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.
gnolang/gno merged new pr relates to banker / coin issue
need to check
@@ -11,14 +11,17 @@ import ( | |||
u256 "gno.land/p/gnoswap/uint256" | |||
) | |||
|
|||
const ( | |||
defaultSwapFee = uint64(15) // 0.15% |
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.
afaik, it should be value of bps
@onlyhyde need double check
) | ||
|
||
func TestHandleSwapFee(t *testing.T) { | ||
token0 := "token0" |
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.
please use proper token path
t.Run(tt.name, func(t *testing.T) { | ||
defer func() { | ||
r := recover() | ||
if (r != nil) != tt.shouldPanic { |
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.
use uassert.PanicsWithMessage to check panic with panic messsage
tt.sqrtPriceLimitX96, | ||
) | ||
|
||
if !result.Eq(tt.expected) { |
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.
uassert.Equal
ugnotTransfer(t, faucetAddress, to, amount) | ||
} | ||
|
||
func ugnotDeposit(t *testing.T, addr std.Address, amount uint64) { |
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.
func wrap
or func ugnotWrap
seems more straightforward
Co-authored-by: Blake <[email protected]>
modified to avoid continuing to use raw strings and add parsing functions to convert to proper types
Quality Gate passedIssues Measures |
Description
Refactor
route
file mainly.Remove
compute_routes
andgno_helper
files_swap
functions and renamed them toswapInner
DrySwapRoute
function and related methodsUpdate
"EXACT_IN"
,"EXACT_OUT"
strings. Additionally replace other hardcoded values with constants_helper_test
file for testing purposeFunctions that use
Pool
currently doesn't have tests yet. This is because there's no way to directly access and initialize the pool's state for now.