|
| 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