|
8 | 8 | "time" |
9 | 9 |
|
10 | 10 | "github.com/metacubex/mihomo/component/profile/cachefile" |
11 | | - "github.com/metacubex/mihomo/component/trie" |
12 | | - C "github.com/metacubex/mihomo/constant" |
13 | 11 |
|
14 | 12 | "github.com/metacubex/bbolt" |
15 | 13 | "github.com/stretchr/testify/assert" |
@@ -43,7 +41,7 @@ func createCachefileStore(options Options) (*Pool, string, error) { |
43 | 41 | return nil, "", err |
44 | 42 | } |
45 | 43 |
|
46 | | - pool.store = newCachefileStore(&cachefile.CacheFile{DB: db}) |
| 44 | + pool.store = newCachefileStore(&cachefile.CacheFile{DB: db}, options.IPNet) |
47 | 45 | return pool, f.Name(), nil |
48 | 46 | } |
49 | 47 |
|
@@ -146,47 +144,6 @@ func TestPool_CycleUsed(t *testing.T) { |
146 | 144 | } |
147 | 145 | } |
148 | 146 |
|
149 | | -func TestPool_Skip(t *testing.T) { |
150 | | - ipnet := netip.MustParsePrefix("192.168.0.1/29") |
151 | | - tree := trie.New[struct{}]() |
152 | | - assert.NoError(t, tree.Insert("example.com", struct{}{})) |
153 | | - assert.False(t, tree.IsEmpty()) |
154 | | - pools, tempfile, err := createPools(Options{ |
155 | | - IPNet: ipnet, |
156 | | - Size: 10, |
157 | | - Host: []C.DomainMatcher{tree.NewDomainSet()}, |
158 | | - }) |
159 | | - assert.Nil(t, err) |
160 | | - defer os.Remove(tempfile) |
161 | | - |
162 | | - for _, pool := range pools { |
163 | | - assert.True(t, pool.ShouldSkipped("example.com")) |
164 | | - assert.False(t, pool.ShouldSkipped("foo.com")) |
165 | | - assert.False(t, pool.shouldSkipped("baz.com")) |
166 | | - } |
167 | | -} |
168 | | - |
169 | | -func TestPool_SkipWhiteList(t *testing.T) { |
170 | | - ipnet := netip.MustParsePrefix("192.168.0.1/29") |
171 | | - tree := trie.New[struct{}]() |
172 | | - assert.NoError(t, tree.Insert("example.com", struct{}{})) |
173 | | - assert.False(t, tree.IsEmpty()) |
174 | | - pools, tempfile, err := createPools(Options{ |
175 | | - IPNet: ipnet, |
176 | | - Size: 10, |
177 | | - Host: []C.DomainMatcher{tree.NewDomainSet()}, |
178 | | - Mode: C.FilterWhiteList, |
179 | | - }) |
180 | | - assert.Nil(t, err) |
181 | | - defer os.Remove(tempfile) |
182 | | - |
183 | | - for _, pool := range pools { |
184 | | - assert.False(t, pool.ShouldSkipped("example.com")) |
185 | | - assert.True(t, pool.ShouldSkipped("foo.com")) |
186 | | - assert.True(t, pool.ShouldSkipped("baz.com")) |
187 | | - } |
188 | | -} |
189 | | - |
190 | 147 | func TestPool_MaxCacheSize(t *testing.T) { |
191 | 148 | ipnet := netip.MustParsePrefix("192.168.0.1/24") |
192 | 149 | pool, _ := New(Options{ |
|
0 commit comments