forked from NatoBoram/git-to-ipns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wheel_test.go
73 lines (66 loc) · 2.09 KB
/
wheel_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package main
import (
"testing"
)
func TestDirSize(t *testing.T) {
_, err := dirSize(".")
if err != nil {
t.Errorf("dirSize failed: %s.", err.Error())
}
}
// Replication minimum for a cluster consisting of a single peer.
// If the cluster consisted of many, many peers, then the minimum should be 3 to allow re-pinning.
func TestRMin(t *testing.T) {
tests := []struct {
input int64
output string
}{
{0, "1"}, // Test value | 0 MiB | 1
{512 * 1024 * 1024, "1"}, // Test value | 512 MiB | 1
{1 * 1024 * 1024 * 1024, "1"}, // Test value | 1 GiB | 1
{321756774, "1"}, // Smallest build | 307 MiB | 1
{499107798, "1"}, // Average build | 476 MiB | 1
{755192969, "1"}, // Largest build | 720 MiB | 1
}
for _, test := range tests {
output := rmin(test.input)
if output != test.output {
t.Errorf("Replication Minimum was incorrect, got: %s, want: %s.", output, test.output)
}
}
}
// Replication maximum for a cluster consisting of a single peer.
// The goal is to download the file under 60 seconds at 10 Mbps.
//
// This is the calculation for an average file.
//
// | Value | MiB | o |
// | :---- | --: | --------: |
// | File | 512 | 536870912 |
// | Speed | 10 | 10485760 |
//
// | Unit | Value |
// | :---------- | ----: |
// | Time | 51.2s |
// | Replication | 0.85x |
//
// The replication factor is truncated then is added +1.
func TestRMax(t *testing.T) {
tests := []struct {
input int64
output string
}{
{0, "1"}, // Test value | 0 MiB | 1
{512 * 1024 * 1024, "1"}, // Test value | 512 MiB | 1
{1 * 1024 * 1024 * 1024, "2"}, // Test value | 1 GiB | 2
{321756774, "1"}, // Smallest build | 307 MiB | 1
{499107798, "1"}, // Average build | 476 MiB | 1
{755192969, "2"}, // Largest build | 720 MiB | 2
}
for _, test := range tests {
output := rmax(test.input)
if output != test.output {
t.Errorf("Replication Maximum was incorrect, got: %s, want: %s.", output, test.output)
}
}
}