Skip to content

Commit 80468af

Browse files
committed
remove unused function
1 parent 3f08c85 commit 80468af

File tree

2 files changed

+33
-112
lines changed

2 files changed

+33
-112
lines changed

router/utils.gno

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,6 @@ func assertHopsInRange(hops int) {
2828
}
2929
}
3030

31-
func poolPathWithFeeDivide(poolPath string) (string, string, int) {
32-
poolPathSplit, err := common.Split(poolPath, ":", 3)
33-
if err != nil {
34-
panic(addDetailToError(
35-
errInvalidPoolPath,
36-
ufmt.Sprintf("invalid poolPath(%s)", poolPath),
37-
))
38-
}
39-
40-
feeInt, err := strconv.Atoi(poolPathSplit[2])
41-
if err != nil {
42-
panic(err.Error())
43-
}
44-
45-
return poolPathSplit[0], poolPathSplit[1], feeInt
46-
}
47-
4831
func getDataForSinglePath(poolPath string) (string, string, uint32) {
4932
poolPathSplit, err := common.Split(poolPath, ":", 3)
5033
if err != nil {

router/utils_test.gno

Lines changed: 33 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -7,77 +7,15 @@ import (
77
"gno.land/p/demo/uassert"
88
)
99

10-
type poolPathWithFeeDivideTestCases struct {
11-
name string
12-
input string
13-
wantToken0 string
14-
wantToken1 string
15-
wantFee int
16-
shouldPanic bool
17-
}
18-
19-
func TestPoolPathWithFeeDivide(t *testing.T) {
20-
tests := []poolPathWithFeeDivideTestCases{
21-
{
22-
name: "valid path",
23-
input: "token0:token1:500",
24-
wantToken0: "token0",
25-
wantToken1: "token1",
26-
wantFee: 500,
27-
shouldPanic: false,
28-
},
29-
{
30-
name: "valid path with special characters",
31-
input: "r/token_a:r/token_b:3000",
32-
wantToken0: "r/token_a",
33-
wantToken1: "r/token_b",
34-
wantFee: 3000,
35-
shouldPanic: false,
36-
},
37-
{
38-
name: "invalid fee format",
39-
input: "token0:token1:abc",
40-
shouldPanic: true,
41-
},
42-
{
43-
name: "missing parts",
44-
input: "token0:token1",
45-
shouldPanic: true,
46-
},
47-
{
48-
name: "empty string",
49-
input: "",
50-
shouldPanic: true,
51-
},
52-
}
53-
54-
for _, tt := range tests {
55-
t.Run(tt.name, func(t *testing.T) {
56-
defer func() {
57-
r := recover()
58-
if (r != nil) != tt.shouldPanic {
59-
t.Errorf("poolPathWithFeeDivide() panic = %v, shouldPanic = %v", r != nil, tt.shouldPanic)
60-
}
61-
}()
62-
63-
token0, token1, fee := poolPathWithFeeDivide(tt.input)
64-
if !tt.shouldPanic {
65-
if token0 != tt.wantToken0 {
66-
t.Errorf("token0 = %v, want %v", token0, tt.wantToken0)
67-
}
68-
if token1 != tt.wantToken1 {
69-
t.Errorf("token1 = %v, want %v", token1, tt.wantToken1)
70-
}
71-
if fee != tt.wantFee {
72-
t.Errorf("fee = %v, want %v", fee, tt.wantFee)
73-
}
74-
}
75-
})
76-
}
77-
}
78-
7910
func TestGetDataForSinglePath(t *testing.T) {
80-
tests := []poolPathWithFeeDivideTestCases{
11+
tests := []struct {
12+
name string
13+
input string
14+
wantToken0 string
15+
wantToken1 string
16+
wantFee int
17+
shouldPanic bool
18+
}{
8119
{
8220
name: "valid path",
8321
input: "tokenA:tokenB:500",
@@ -222,32 +160,32 @@ func TestSplitSingleChar(t *testing.T) {
222160
expected: []string{"a", "b", "c"},
223161
},
224162
{
225-
name: "single character string",
226-
input: "a",
227-
sep: ',',
228-
expected: []string{"a"},
229-
},
230-
{
231-
name: "only separators",
232-
input: ",,,,",
233-
sep: ',',
234-
expected: []string{"", "", "", "", ""},
235-
},
236-
{
237-
name: "unicode characters",
238-
input: "한글,English,日本語",
239-
sep: ',',
240-
expected: []string{"한글", "English", "日本語"},
241-
},
242-
{
243-
name: "special characters",
244-
input: "!@#$,%^&*,()_+",
245-
sep: ',',
246-
expected: []string{"!@#$", "%^&*", "()_+"},
247-
},
163+
name: "single character string",
164+
input: "a",
165+
sep: ',',
166+
expected: []string{"a"},
167+
},
168+
{
169+
name: "only separators",
170+
input: ",,,,",
171+
sep: ',',
172+
expected: []string{"", "", "", "", ""},
173+
},
174+
{
175+
name: "unicode characters",
176+
input: "한글,English,日本語",
177+
sep: ',',
178+
expected: []string{"한글", "English", "日本語"},
179+
},
180+
{
181+
name: "special characters",
182+
input: "!@#$,%^&*,()_+",
183+
sep: ',',
184+
expected: []string{"!@#$", "%^&*", "()_+"},
185+
},
248186
{
249-
name: "routes path",
250-
input: "gno.land/r/onbloc/bar:gno.land/r/onbloc/baz:500*POOL*gno.land/r/onbloc/baz:gno.land/r/onbloc/qux:500,gno.land/r/onbloc/bar:gno.land/r/onbloc/baz:500*POOL*gno.land/r/onbloc/baz:gno.land/r/onbloc/qux:500",
187+
name: "routes path",
188+
input: "gno.land/r/onbloc/bar:gno.land/r/onbloc/baz:500*POOL*gno.land/r/onbloc/baz:gno.land/r/onbloc/qux:500,gno.land/r/onbloc/bar:gno.land/r/onbloc/baz:500*POOL*gno.land/r/onbloc/baz:gno.land/r/onbloc/qux:500",
251189
sep: ',',
252190
expected: []string{"gno.land/r/onbloc/bar:gno.land/r/onbloc/baz:500*POOL*gno.land/r/onbloc/baz:gno.land/r/onbloc/qux:500", "gno.land/r/onbloc/bar:gno.land/r/onbloc/baz:500*POOL*gno.land/r/onbloc/baz:gno.land/r/onbloc/qux:500"},
253191
},

0 commit comments

Comments
 (0)