Skip to content

Commit

Permalink
testutil: obvious names for seeded key pairs
Browse files Browse the repository at this point in the history
  • Loading branch information
jbenet committed Jan 5, 2015
1 parent 9d72431 commit 29a3206
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion namesys/resolve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func TestRoutingResolve(t *testing.T) {
resolver := NewRoutingResolver(d)
publisher := NewRoutingPublisher(d)

privk, pubk, err := testutil.RandKeyPair(512)
privk, pubk, err := testutil.RandTestKeyPair(512)
if err != nil {
t.Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions p2p/crypto/key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

func TestRsaKeys(t *testing.T) {
sk, pk, err := tu.RandKeyPair(512)
sk, pk, err := tu.RandTestKeyPair(512)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -93,7 +93,7 @@ func testKeyEquals(t *testing.T, k Key) {
t.Fatal("Key not equal to key with same bytes.")
}

sk, pk, err := tu.RandKeyPair(512)
sk, pk, err := tu.RandTestKeyPair(512)
if err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion p2p/net/mock/mock_net.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func New(ctx context.Context) Mocknet {
}

func (mn *mocknet) GenPeer() (host.Host, error) {
sk, _, err := testutil.SeededKeyPair(time.Now().UnixNano())
sk, _, err := testutil.SeededTestKeyPair(time.Now().UnixNano())
if err != nil {
return nil, err
}
Expand Down
8 changes: 4 additions & 4 deletions p2p/net/mock/mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ func randPeer(t *testing.T) peer.ID {
func TestNetworkSetup(t *testing.T) {

ctx := context.Background()
sk1, _, err := testutil.RandKeyPair(512)
sk1, _, err := testutil.RandTestKeyPair(512)
if err != nil {
t.Fatal(t)
}
sk2, _, err := testutil.RandKeyPair(512)
sk2, _, err := testutil.RandTestKeyPair(512)
if err != nil {
t.Fatal(t)
}
sk3, _, err := testutil.RandKeyPair(512)
sk3, _, err := testutil.RandTestKeyPair(512)
if err != nil {
t.Fatal(t)
}
Expand Down Expand Up @@ -398,7 +398,7 @@ func TestAdding(t *testing.T) {

peers := []peer.ID{}
for i := 0; i < 3; i++ {
sk, _, err := testutil.RandKeyPair(512)
sk, _, err := testutil.RandTestKeyPair(512)
if err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion p2p/peer/peer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type keyset struct {

func (ks *keyset) generate() error {
var err error
ks.sk, ks.pk, err = tu.RandKeyPair(512)
ks.sk, ks.pk, err = tu.RandTestKeyPair(512)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions util/testutil/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ func init() {
ZeroLocalTCPAddress = maddr
}

func RandKeyPair(bits int) (ci.PrivKey, ci.PubKey, error) {
func RandTestKeyPair(bits int) (ci.PrivKey, ci.PubKey, error) {
return ci.GenerateKeyPairWithReader(ci.RSA, bits, u.NewTimeSeededRand())
}

func SeededKeyPair(seed int64) (ci.PrivKey, ci.PubKey, error) {
func SeededTestKeyPair(seed int64) (ci.PrivKey, ci.PubKey, error) {
return ci.GenerateKeyPairWithReader(ci.RSA, 512, u.NewSeededRand(seed))
}

Expand Down Expand Up @@ -142,7 +142,7 @@ func RandPeerNetParams() (*PeerNetParams, error) {
var p PeerNetParams
var err error
p.Addr = ZeroLocalTCPAddress
p.PrivKey, p.PubKey, err = RandKeyPair(512)
p.PrivKey, p.PubKey, err = RandTestKeyPair(512)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 29a3206

Please sign in to comment.