Skip to content

Commit 88fc8ef

Browse files
committed
transport: routing, added TestShardPortIterator
1 parent 8f0bca8 commit 88fc8ef

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

transport/routing_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package transport
2+
3+
import "testing"
4+
5+
func TestShardPortIterator(t *testing.T) {
6+
t.Parallel()
7+
for shards := 1; shards < 128; shards++ {
8+
for shard := 0; shard < shards; shard++ {
9+
si := ShardInfo{
10+
Shard: uint16(shard),
11+
NrShards: uint16(shards),
12+
}
13+
14+
it := ShardPortIterator(si)
15+
finishPort := it()
16+
for port := it(); port != finishPort; port = it() {
17+
if port < minPort || port > maxPort {
18+
t.Fatalf("port %d is not in range [%d, %d]", port, minPort, maxPort)
19+
}
20+
21+
if int(port)%shards != shard {
22+
t.Fatalf("port %d doesn't correspond to shard %d", port, shard)
23+
}
24+
}
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)