Skip to content

Commit

Permalink
cmd/geth: add tests for version_check (#24169)
Browse files Browse the repository at this point in the history
  • Loading branch information
rangzen committed Jan 11, 2022
1 parent e6b61ed commit c006261
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions cmd/geth/version_check_test.go
Expand Up @@ -25,6 +25,8 @@ import (
"strconv"
"strings"
"testing"

"github.com/jedisct1/go-minisign"
)

func TestVerification(t *testing.T) {
Expand Down Expand Up @@ -128,3 +130,39 @@ func TestMatching(t *testing.T) {
}
}
}

func TestGethPubKeysParseable(t *testing.T) {
for _, pubkey := range gethPubKeys {
_, err := minisign.NewPublicKey(pubkey)
if err != nil {
t.Errorf("Should be parseable")
}
}
}

func TestKeyID(t *testing.T) {
type args struct {
id [8]byte
}
tests := []struct {
name string
args args
want string
}{
{"@holiman key", args{id: extractKeyId(gethPubKeys[0])}, "FB1D084D39BAEC24"},
{"second key", args{id: extractKeyId(gethPubKeys[1])}, "138B1CA303E51687"},
{"third key", args{id: extractKeyId(gethPubKeys[2])}, "FD9813B2D2098484"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := keyID(tt.args.id); got != tt.want {
t.Errorf("keyID() = %v, want %v", got, tt.want)
}
})
}
}

func extractKeyId(pubkey string) [8]byte {
p, _ := minisign.NewPublicKey(pubkey)
return p.KeyId
}

0 comments on commit c006261

Please sign in to comment.