Skip to content
This repository was archived by the owner on Dec 7, 2019. It is now read-only.

Commit 9a5d4c5

Browse files
authored
migrate test utilities to go-libp2p-testing (#24)
1 parent 4762826 commit 9a5d4c5

13 files changed

+222
-445
lines changed

ci/ci.go

Lines changed: 0 additions & 46 deletions
This file was deleted.

ci/deprecated.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci instead.
2+
package ci
3+
4+
import testing "github.com/libp2p/go-libp2p-testing/ci"
5+
6+
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci.EnvVar instead.
7+
type EnvVar = testing.EnvVar
8+
9+
const (
10+
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci.VarCI instead.
11+
VarCI = testing.VarCI
12+
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci.VarNoFuse instead.
13+
VarNoFuse = testing.VarNoFuse
14+
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci.VarVerbose instead.
15+
VarVerbose = testing.VarVerbose
16+
)
17+
18+
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci.IsRunning instead.
19+
func IsRunning() bool {
20+
return testing.IsRunning()
21+
}
22+
23+
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci.EnvVar instead.
24+
func Env(v EnvVar) string {
25+
return testing.Env(v)
26+
}
27+
28+
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci.NoFuse instead.
29+
func NoFuse() bool {
30+
return testing.NoFuse()
31+
}
32+
33+
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci.Verbose instead.
34+
func Verbose() bool {
35+
return testing.Verbose()
36+
}

ci/travis/deprecated.go

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis instead.
2+
package travis
3+
4+
import testing "github.com/libp2p/go-libp2p-testing/ci/travis"
5+
6+
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.EnvVar instead.
7+
type EnvVar = testing.EnvVar
8+
9+
const (
10+
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.EnvVar instead.
11+
VarCI = testing.VarCI
12+
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.VarTravis instead.
13+
VarTravis = testing.VarTravis
14+
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.VarBranch instead.
15+
VarBranch = testing.VarBranch
16+
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.VarBuildDir instead.
17+
VarBuildDir = testing.VarBuildDir
18+
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.VarBuildId instead.
19+
VarBuildId = testing.VarBuildId
20+
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.VarBuildNumber instead.
21+
VarBuildNumber = testing.VarBuildNumber
22+
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.VarCommit instead.
23+
VarCommit = testing.VarCommit
24+
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.VarCommitRange instead.
25+
VarCommitRange = testing.VarCommitRange
26+
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.VarJobId instead.
27+
VarJobId = testing.VarJobId
28+
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.VarJobNumber instead.
29+
VarJobNumber = testing.VarJobNumber
30+
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.VarPullRequest instead.
31+
VarPullRequest = testing.VarPullRequest
32+
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.VarSecureEnvVars instead.
33+
VarSecureEnvVars = testing.VarSecureEnvVars
34+
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.VarRepoSlug instead.
35+
VarRepoSlug = testing.VarRepoSlug
36+
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.VarOsName instead.
37+
VarOsName = testing.VarOsName
38+
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.VarTag instead.
39+
VarTag = testing.VarTag
40+
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.VarGoVersion instead.
41+
VarGoVersion = testing.VarGoVersion
42+
)
43+
44+
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.IsRunning instead.
45+
func IsRunning() bool {
46+
return testing.IsRunning()
47+
}
48+
49+
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.Env instead.
50+
func Env(v EnvVar) string {
51+
return testing.Env(v)
52+
}
53+
54+
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.JobId instead.
55+
func JobId() string {
56+
return testing.JobId()
57+
}
58+
59+
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.JobNumber instead.
60+
func JobNumber() string {
61+
return testing.JobNumber()
62+
}

ci/travis/travis.go

Lines changed: 0 additions & 57 deletions
This file was deleted.

ci/travis/travis_test.go

Lines changed: 0 additions & 13 deletions
This file was deleted.

deprecated.go

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// Deprecated: use github.com/libp2p/go-libp2p-testing and subpackages instead.
2+
package testutil
3+
4+
import (
5+
"context"
6+
"math/rand"
7+
"testing"
8+
9+
ci "github.com/libp2p/go-libp2p-core/crypto"
10+
"github.com/libp2p/go-libp2p-core/peer"
11+
"github.com/libp2p/go-libp2p-core/test"
12+
13+
"github.com/libp2p/go-libp2p-testing/etc"
14+
"github.com/libp2p/go-libp2p-testing/net"
15+
16+
ma "github.com/multiformats/go-multiaddr"
17+
)
18+
19+
// Deprecated: use github.com/libp2p/go-libp2p-testing/net.ZeroLocalTCPAddress instead.
20+
// Warning: it's impossible to alias a var in go. Writes to this var would have no longer
21+
// have any effect, so it has been commented out to induce breakage for added safety.
22+
// var ZeroLocalTCPAddress = tnet.ZeroLocalTCPAddress
23+
24+
// Deprecated: use github.com/libp2p/go-libp2p-core/test.RandTestKeyPair instead.
25+
// Supply RSA as a key type to get an equivalent result.
26+
func RandTestKeyPair(bits int) (ci.PrivKey, ci.PubKey, error) {
27+
return test.RandTestKeyPair(ci.RSA, bits)
28+
}
29+
30+
// Deprecated: use github.com/libp2p/go-libp2p-core/test.SeededTestKeyPair instead.
31+
// Supply RSA as a key type, with 512 bits, to get an equivalent result.
32+
func SeededTestKeyPair(seed int64) (ci.PrivKey, ci.PubKey, error) {
33+
return test.SeededTestKeyPair(ci.RSA, 512, seed)
34+
}
35+
36+
// Deprecated: use github.com/libp2p/go-libp2p-core/test.RandPeerID instead.
37+
func RandPeerID() (peer.ID, error) {
38+
return test.RandPeerID()
39+
}
40+
41+
// Deprecated: use github.com/libp2p/go-libp2p-core/test.RandPeerIDFatal instead.
42+
func RandPeerIDFatal(t testing.TB) peer.ID {
43+
return test.RandPeerIDFatal(t)
44+
}
45+
46+
// Deprecated: use github.com/libp2p/go-libp2p-testing/net.RandLocalTCPAddress instead.
47+
func RandLocalTCPAddress() ma.Multiaddr {
48+
return tnet.RandLocalTCPAddress()
49+
}
50+
51+
// Deprecated: use github.com/libp2p/go-libp2p-testing/net.PeerNetParams instead.
52+
type PeerNetParams = tnet.PeerNetParams
53+
54+
// Deprecated: use github.com/libp2p/go-libp2p-testing/net.RandPeerNetParamsOrFatal instead.
55+
func RandPeerNetParamsOrFatal(t *testing.T) PeerNetParams {
56+
return tnet.RandPeerNetParamsOrFatal(t)
57+
}
58+
59+
// Deprecated: use github.com/libp2p/go-libp2p-testing/net.RandPeerNetParams instead.
60+
func RandPeerNetParams() (*PeerNetParams, error) {
61+
return tnet.RandPeerNetParams()
62+
}
63+
64+
// Deprecated: use github.com/libp2p/go-libp2p-testing/net.Identity instead.
65+
type Identity = tnet.Identity
66+
67+
// Deprecated: use github.com/libp2p/go-libp2p-testing/net.RandIdentity instead.
68+
func RandIdentity() (Identity, error) {
69+
return tnet.RandIdentity()
70+
}
71+
72+
// Deprecated: use github.com/libp2p/go-libp2p-testing/net.RandIdentityOrFatal instead.
73+
func RandIdentityOrFatal(t *testing.T) Identity {
74+
return tnet.RandIdentityOrFatal(t)
75+
}
76+
77+
// Deprecated: use github.com/libp2p/go-libp2p-testing/net.NewIdentity instead.
78+
func NewIdentity(ID peer.ID, addr ma.Multiaddr, privk ci.PrivKey, pubk ci.PubKey) Identity {
79+
return tnet.NewIdentity(ID, addr, privk, pubk)
80+
}
81+
82+
// Deprecated: use github.com/libp2p/go-libp2p-testing/net.LatencyConfig instead.
83+
type LatencyConfig = tnet.LatencyConfig
84+
85+
// Deprecated: use github.com/libp2p/go-libp2p-testing/etc.SeededRand instead.
86+
var SeededRand = tetc.SeededRand
87+
88+
// Deprecated: use github.com/libp2p/go-libp2p-testing/etc.NewSeededRand instead.
89+
func NewSeededRand(seed int64) *rand.Rand {
90+
return tetc.NewSeededRand(seed)
91+
}
92+
93+
// Deprecated: use github.com/libp2p/go-libp2p-testing/etc.LockedRandSource instead.
94+
type LockedRandSource = tetc.LockedRandSource
95+
96+
// Deprecated: use github.com/libp2p/go-libp2p-testing/etc.WaitFor instead.
97+
func WaitFor(ctx context.Context, check func() error) error {
98+
return tetc.WaitFor(ctx, check)
99+
}

0 commit comments

Comments
 (0)