github.com/linapex/ethereum-dpos-chinese@v0.0.0-20190316121959-b78b3a4a1ece/p2p/enr/idscheme_test.go (about)

     1  
     2  //<developer>
     3  //    <name>linapex 曹一峰</name>
     4  //    <email>linapex@163.com</email>
     5  //    <wx>superexc</wx>
     6  //    <qqgroup>128148617</qqgroup>
     7  //    <url>https://jsq.ink</url>
     8  //    <role>pku engineer</role>
     9  //    <date>2019-03-16 12:09:44</date>
    10  //</624342658399080448>
    11  
    12  
    13  package enr
    14  
    15  import (
    16  	"crypto/ecdsa"
    17  	"math/big"
    18  	"testing"
    19  )
    20  
    21  //检查签名失败是否使记录保持不变。
    22  func TestSignError(t *testing.T) {
    23  	invalidKey := &ecdsa.PrivateKey{D: new(big.Int), PublicKey: *pubkey}
    24  
    25  	var r Record
    26  	if err := SignV4(&r, invalidKey); err == nil {
    27  		t.Fatal("expected error from SignV4")
    28  	}
    29  	if len(r.pairs) > 0 {
    30  		t.Fatal("expected empty record, have", r.pairs)
    31  	}
    32  }
    33