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

Commit

Permalink
migrate test utilities to go-libp2p-testing (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
raulk committed May 24, 2019
1 parent 4762826 commit 9a5d4c5
Show file tree
Hide file tree
Showing 13 changed files with 222 additions and 445 deletions.
46 changes: 0 additions & 46 deletions ci/ci.go

This file was deleted.

36 changes: 36 additions & 0 deletions ci/deprecated.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci instead.
package ci

import testing "github.com/libp2p/go-libp2p-testing/ci"

// Deprecated: use github.com/libp2p/go-libp2p-testing/ci.EnvVar instead.
type EnvVar = testing.EnvVar

const (
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci.VarCI instead.
VarCI = testing.VarCI
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci.VarNoFuse instead.
VarNoFuse = testing.VarNoFuse
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci.VarVerbose instead.
VarVerbose = testing.VarVerbose
)

// Deprecated: use github.com/libp2p/go-libp2p-testing/ci.IsRunning instead.
func IsRunning() bool {
return testing.IsRunning()
}

// Deprecated: use github.com/libp2p/go-libp2p-testing/ci.EnvVar instead.
func Env(v EnvVar) string {
return testing.Env(v)
}

// Deprecated: use github.com/libp2p/go-libp2p-testing/ci.NoFuse instead.
func NoFuse() bool {
return testing.NoFuse()
}

// Deprecated: use github.com/libp2p/go-libp2p-testing/ci.Verbose instead.
func Verbose() bool {
return testing.Verbose()
}
62 changes: 62 additions & 0 deletions ci/travis/deprecated.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis instead.
package travis

import testing "github.com/libp2p/go-libp2p-testing/ci/travis"

// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.EnvVar instead.
type EnvVar = testing.EnvVar

const (
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.EnvVar instead.
VarCI = testing.VarCI
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.VarTravis instead.
VarTravis = testing.VarTravis
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.VarBranch instead.
VarBranch = testing.VarBranch
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.VarBuildDir instead.
VarBuildDir = testing.VarBuildDir
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.VarBuildId instead.
VarBuildId = testing.VarBuildId
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.VarBuildNumber instead.
VarBuildNumber = testing.VarBuildNumber
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.VarCommit instead.
VarCommit = testing.VarCommit
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.VarCommitRange instead.
VarCommitRange = testing.VarCommitRange
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.VarJobId instead.
VarJobId = testing.VarJobId
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.VarJobNumber instead.
VarJobNumber = testing.VarJobNumber
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.VarPullRequest instead.
VarPullRequest = testing.VarPullRequest
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.VarSecureEnvVars instead.
VarSecureEnvVars = testing.VarSecureEnvVars
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.VarRepoSlug instead.
VarRepoSlug = testing.VarRepoSlug
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.VarOsName instead.
VarOsName = testing.VarOsName
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.VarTag instead.
VarTag = testing.VarTag
// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.VarGoVersion instead.
VarGoVersion = testing.VarGoVersion
)

// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.IsRunning instead.
func IsRunning() bool {
return testing.IsRunning()
}

// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.Env instead.
func Env(v EnvVar) string {
return testing.Env(v)
}

// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.JobId instead.
func JobId() string {
return testing.JobId()
}

// Deprecated: use github.com/libp2p/go-libp2p-testing/ci/travis.JobNumber instead.
func JobNumber() string {
return testing.JobNumber()
}
57 changes: 0 additions & 57 deletions ci/travis/travis.go

This file was deleted.

13 changes: 0 additions & 13 deletions ci/travis/travis_test.go

This file was deleted.

99 changes: 99 additions & 0 deletions deprecated.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// Deprecated: use github.com/libp2p/go-libp2p-testing and subpackages instead.
package testutil

import (
"context"
"math/rand"
"testing"

ci "github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/test"

"github.com/libp2p/go-libp2p-testing/etc"
"github.com/libp2p/go-libp2p-testing/net"

ma "github.com/multiformats/go-multiaddr"
)

// Deprecated: use github.com/libp2p/go-libp2p-testing/net.ZeroLocalTCPAddress instead.
// Warning: it's impossible to alias a var in go. Writes to this var would have no longer
// have any effect, so it has been commented out to induce breakage for added safety.
// var ZeroLocalTCPAddress = tnet.ZeroLocalTCPAddress

// Deprecated: use github.com/libp2p/go-libp2p-core/test.RandTestKeyPair instead.
// Supply RSA as a key type to get an equivalent result.
func RandTestKeyPair(bits int) (ci.PrivKey, ci.PubKey, error) {
return test.RandTestKeyPair(ci.RSA, bits)
}

// Deprecated: use github.com/libp2p/go-libp2p-core/test.SeededTestKeyPair instead.
// Supply RSA as a key type, with 512 bits, to get an equivalent result.
func SeededTestKeyPair(seed int64) (ci.PrivKey, ci.PubKey, error) {
return test.SeededTestKeyPair(ci.RSA, 512, seed)
}

// Deprecated: use github.com/libp2p/go-libp2p-core/test.RandPeerID instead.
func RandPeerID() (peer.ID, error) {
return test.RandPeerID()
}

// Deprecated: use github.com/libp2p/go-libp2p-core/test.RandPeerIDFatal instead.
func RandPeerIDFatal(t testing.TB) peer.ID {
return test.RandPeerIDFatal(t)
}

// Deprecated: use github.com/libp2p/go-libp2p-testing/net.RandLocalTCPAddress instead.
func RandLocalTCPAddress() ma.Multiaddr {
return tnet.RandLocalTCPAddress()
}

// Deprecated: use github.com/libp2p/go-libp2p-testing/net.PeerNetParams instead.
type PeerNetParams = tnet.PeerNetParams

// Deprecated: use github.com/libp2p/go-libp2p-testing/net.RandPeerNetParamsOrFatal instead.
func RandPeerNetParamsOrFatal(t *testing.T) PeerNetParams {
return tnet.RandPeerNetParamsOrFatal(t)
}

// Deprecated: use github.com/libp2p/go-libp2p-testing/net.RandPeerNetParams instead.
func RandPeerNetParams() (*PeerNetParams, error) {
return tnet.RandPeerNetParams()
}

// Deprecated: use github.com/libp2p/go-libp2p-testing/net.Identity instead.
type Identity = tnet.Identity

// Deprecated: use github.com/libp2p/go-libp2p-testing/net.RandIdentity instead.
func RandIdentity() (Identity, error) {
return tnet.RandIdentity()
}

// Deprecated: use github.com/libp2p/go-libp2p-testing/net.RandIdentityOrFatal instead.
func RandIdentityOrFatal(t *testing.T) Identity {
return tnet.RandIdentityOrFatal(t)
}

// Deprecated: use github.com/libp2p/go-libp2p-testing/net.NewIdentity instead.
func NewIdentity(ID peer.ID, addr ma.Multiaddr, privk ci.PrivKey, pubk ci.PubKey) Identity {
return tnet.NewIdentity(ID, addr, privk, pubk)
}

// Deprecated: use github.com/libp2p/go-libp2p-testing/net.LatencyConfig instead.
type LatencyConfig = tnet.LatencyConfig

// Deprecated: use github.com/libp2p/go-libp2p-testing/etc.SeededRand instead.
var SeededRand = tetc.SeededRand

// Deprecated: use github.com/libp2p/go-libp2p-testing/etc.NewSeededRand instead.
func NewSeededRand(seed int64) *rand.Rand {
return tetc.NewSeededRand(seed)
}

// Deprecated: use github.com/libp2p/go-libp2p-testing/etc.LockedRandSource instead.
type LockedRandSource = tetc.LockedRandSource

// Deprecated: use github.com/libp2p/go-libp2p-testing/etc.WaitFor instead.
func WaitFor(ctx context.Context, check func() error) error {
return tetc.WaitFor(ctx, check)
}
Loading

0 comments on commit 9a5d4c5

Please sign in to comment.