diff options
author | Felix Lange <fjl@twurst.com> | 2015-03-02 22:26:24 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2015-03-04 19:27:24 +0800 |
commit | 2c505efd1ec03dc28ebabbb54253f3eb9e719be5 (patch) | |
tree | 3390823a5bb64fe4cc3a4184f0875d4d95de0745 /p2p/discover/node_test.go | |
parent | d344054e5a2844241bf0e4f64ccfc4d2ad259718 (diff) | |
download | go-tangerine-2c505efd1ec03dc28ebabbb54253f3eb9e719be5.tar go-tangerine-2c505efd1ec03dc28ebabbb54253f3eb9e719be5.tar.gz go-tangerine-2c505efd1ec03dc28ebabbb54253f3eb9e719be5.tar.bz2 go-tangerine-2c505efd1ec03dc28ebabbb54253f3eb9e719be5.tar.lz go-tangerine-2c505efd1ec03dc28ebabbb54253f3eb9e719be5.tar.xz go-tangerine-2c505efd1ec03dc28ebabbb54253f3eb9e719be5.tar.zst go-tangerine-2c505efd1ec03dc28ebabbb54253f3eb9e719be5.zip |
p2p/discover: add NodeID.Pubkey
Diffstat (limited to 'p2p/discover/node_test.go')
-rw-r--r-- | p2p/discover/node_test.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/p2p/discover/node_test.go b/p2p/discover/node_test.go index ae82ae4f1..60b01b6ca 100644 --- a/p2p/discover/node_test.go +++ b/p2p/discover/node_test.go @@ -133,6 +133,24 @@ func TestNodeID_recover(t *testing.T) { if pub != recpub { t.Errorf("recovered wrong pubkey:\ngot: %v\nwant: %v", recpub, pub) } + + ecdsa, err := pub.Pubkey() + if err != nil { + t.Errorf("Pubkey error: %v", err) + } + if !reflect.DeepEqual(ecdsa, &prv.PublicKey) { + t.Errorf("Pubkey mismatch:\n got: %#v\n want: %#v", ecdsa, &prv.PublicKey) + } +} + +func TestNodeID_pubkeyBad(t *testing.T) { + ecdsa, err := NodeID{}.Pubkey() + if err == nil { + t.Error("expected error for zero ID") + } + if ecdsa != nil { + t.Error("expected nil result") + } } func TestNodeID_distcmp(t *testing.T) { |