Skip to content

Commit

Permalink
cmd/geth: add tests for version_check (ethereum#24169)
Browse files Browse the repository at this point in the history
  • Loading branch information
rangzen authored and ValentinTrinque committed Jan 25, 2022
1 parent a5473ab commit 8937c0f
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 8937c0f

Please sign in to comment.