github.com/annchain/OG@v0.0.9/p2p/discover/udp_gen_test.go (about)

     1  package discover
     2  
     3  // Code generated by github.com/tinylib/msgp DO NOT EDIT.
     4  
     5  import (
     6  	"bytes"
     7  	"testing"
     8  
     9  	"github.com/tinylib/msgp/msgp"
    10  )
    11  
    12  func TestMarshalUnmarshalConfig(t *testing.T) {
    13  	v := Config{}
    14  	bts, err := v.MarshalMsg(nil)
    15  	if err != nil {
    16  		t.Fatal(err)
    17  	}
    18  	left, err := v.UnmarshalMsg(bts)
    19  	if err != nil {
    20  		t.Fatal(err)
    21  	}
    22  	if len(left) > 0 {
    23  		t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left)
    24  	}
    25  
    26  	left, err = msgp.Skip(bts)
    27  	if err != nil {
    28  		t.Fatal(err)
    29  	}
    30  	if len(left) > 0 {
    31  		t.Errorf("%d bytes left over after Skip(): %q", len(left), left)
    32  	}
    33  }
    34  
    35  func BenchmarkMarshalMsgConfig(b *testing.B) {
    36  	v := Config{}
    37  	b.ReportAllocs()
    38  	b.ResetTimer()
    39  	for i := 0; i < b.N; i++ {
    40  		v.MarshalMsg(nil)
    41  	}
    42  }
    43  
    44  func BenchmarkAppendMsgConfig(b *testing.B) {
    45  	v := Config{}
    46  	bts := make([]byte, 0, v.Msgsize())
    47  	bts, _ = v.MarshalMsg(bts[0:0])
    48  	b.SetBytes(int64(len(bts)))
    49  	b.ReportAllocs()
    50  	b.ResetTimer()
    51  	for i := 0; i < b.N; i++ {
    52  		bts, _ = v.MarshalMsg(bts[0:0])
    53  	}
    54  }
    55  
    56  func BenchmarkUnmarshalConfig(b *testing.B) {
    57  	v := Config{}
    58  	bts, _ := v.MarshalMsg(nil)
    59  	b.ReportAllocs()
    60  	b.SetBytes(int64(len(bts)))
    61  	b.ResetTimer()
    62  	for i := 0; i < b.N; i++ {
    63  		_, err := v.UnmarshalMsg(bts)
    64  		if err != nil {
    65  			b.Fatal(err)
    66  		}
    67  	}
    68  }
    69  
    70  func TestEncodeDecodeConfig(t *testing.T) {
    71  	v := Config{}
    72  	var buf bytes.Buffer
    73  	msgp.Encode(&buf, &v)
    74  
    75  	m := v.Msgsize()
    76  	if buf.Len() > m {
    77  		t.Logf("WARNING: Msgsize() for %v is inaccurate", v)
    78  	}
    79  
    80  	vn := Config{}
    81  	err := msgp.Decode(&buf, &vn)
    82  	if err != nil {
    83  		t.Error(err)
    84  	}
    85  
    86  	buf.Reset()
    87  	msgp.Encode(&buf, &v)
    88  	err = msgp.NewReader(&buf).Skip()
    89  	if err != nil {
    90  		t.Error(err)
    91  	}
    92  }
    93  
    94  func BenchmarkEncodeConfig(b *testing.B) {
    95  	v := Config{}
    96  	var buf bytes.Buffer
    97  	msgp.Encode(&buf, &v)
    98  	b.SetBytes(int64(buf.Len()))
    99  	en := msgp.NewWriter(msgp.Nowhere)
   100  	b.ReportAllocs()
   101  	b.ResetTimer()
   102  	for i := 0; i < b.N; i++ {
   103  		v.EncodeMsg(en)
   104  	}
   105  	en.Flush()
   106  }
   107  
   108  func BenchmarkDecodeConfig(b *testing.B) {
   109  	v := Config{}
   110  	var buf bytes.Buffer
   111  	msgp.Encode(&buf, &v)
   112  	b.SetBytes(int64(buf.Len()))
   113  	rd := msgp.NewEndlessReader(buf.Bytes(), b)
   114  	dc := msgp.NewReader(rd)
   115  	b.ReportAllocs()
   116  	b.ResetTimer()
   117  	for i := 0; i < b.N; i++ {
   118  		err := v.DecodeMsg(dc)
   119  		if err != nil {
   120  			b.Fatal(err)
   121  		}
   122  	}
   123  }
   124  
   125  func TestMarshalUnmarshalFindnode(t *testing.T) {
   126  	v := Findnode{}
   127  	bts, err := v.MarshalMsg(nil)
   128  	if err != nil {
   129  		t.Fatal(err)
   130  	}
   131  	left, err := v.UnmarshalMsg(bts)
   132  	if err != nil {
   133  		t.Fatal(err)
   134  	}
   135  	if len(left) > 0 {
   136  		t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left)
   137  	}
   138  
   139  	left, err = msgp.Skip(bts)
   140  	if err != nil {
   141  		t.Fatal(err)
   142  	}
   143  	if len(left) > 0 {
   144  		t.Errorf("%d bytes left over after Skip(): %q", len(left), left)
   145  	}
   146  }
   147  
   148  func BenchmarkMarshalMsgFindnode(b *testing.B) {
   149  	v := Findnode{}
   150  	b.ReportAllocs()
   151  	b.ResetTimer()
   152  	for i := 0; i < b.N; i++ {
   153  		v.MarshalMsg(nil)
   154  	}
   155  }
   156  
   157  func BenchmarkAppendMsgFindnode(b *testing.B) {
   158  	v := Findnode{}
   159  	bts := make([]byte, 0, v.Msgsize())
   160  	bts, _ = v.MarshalMsg(bts[0:0])
   161  	b.SetBytes(int64(len(bts)))
   162  	b.ReportAllocs()
   163  	b.ResetTimer()
   164  	for i := 0; i < b.N; i++ {
   165  		bts, _ = v.MarshalMsg(bts[0:0])
   166  	}
   167  }
   168  
   169  func BenchmarkUnmarshalFindnode(b *testing.B) {
   170  	v := Findnode{}
   171  	bts, _ := v.MarshalMsg(nil)
   172  	b.ReportAllocs()
   173  	b.SetBytes(int64(len(bts)))
   174  	b.ResetTimer()
   175  	for i := 0; i < b.N; i++ {
   176  		_, err := v.UnmarshalMsg(bts)
   177  		if err != nil {
   178  			b.Fatal(err)
   179  		}
   180  	}
   181  }
   182  
   183  func TestEncodeDecodeFindnode(t *testing.T) {
   184  	v := Findnode{}
   185  	var buf bytes.Buffer
   186  	msgp.Encode(&buf, &v)
   187  
   188  	m := v.Msgsize()
   189  	if buf.Len() > m {
   190  		t.Logf("WARNING: Msgsize() for %v is inaccurate", v)
   191  	}
   192  
   193  	vn := Findnode{}
   194  	err := msgp.Decode(&buf, &vn)
   195  	if err != nil {
   196  		t.Error(err)
   197  	}
   198  
   199  	buf.Reset()
   200  	msgp.Encode(&buf, &v)
   201  	err = msgp.NewReader(&buf).Skip()
   202  	if err != nil {
   203  		t.Error(err)
   204  	}
   205  }
   206  
   207  func BenchmarkEncodeFindnode(b *testing.B) {
   208  	v := Findnode{}
   209  	var buf bytes.Buffer
   210  	msgp.Encode(&buf, &v)
   211  	b.SetBytes(int64(buf.Len()))
   212  	en := msgp.NewWriter(msgp.Nowhere)
   213  	b.ReportAllocs()
   214  	b.ResetTimer()
   215  	for i := 0; i < b.N; i++ {
   216  		v.EncodeMsg(en)
   217  	}
   218  	en.Flush()
   219  }
   220  
   221  func BenchmarkDecodeFindnode(b *testing.B) {
   222  	v := Findnode{}
   223  	var buf bytes.Buffer
   224  	msgp.Encode(&buf, &v)
   225  	b.SetBytes(int64(buf.Len()))
   226  	rd := msgp.NewEndlessReader(buf.Bytes(), b)
   227  	dc := msgp.NewReader(rd)
   228  	b.ReportAllocs()
   229  	b.ResetTimer()
   230  	for i := 0; i < b.N; i++ {
   231  		err := v.DecodeMsg(dc)
   232  		if err != nil {
   233  			b.Fatal(err)
   234  		}
   235  	}
   236  }
   237  
   238  func TestMarshalUnmarshalNeighbors(t *testing.T) {
   239  	v := Neighbors{}
   240  	bts, err := v.MarshalMsg(nil)
   241  	if err != nil {
   242  		t.Fatal(err)
   243  	}
   244  	left, err := v.UnmarshalMsg(bts)
   245  	if err != nil {
   246  		t.Fatal(err)
   247  	}
   248  	if len(left) > 0 {
   249  		t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left)
   250  	}
   251  
   252  	left, err = msgp.Skip(bts)
   253  	if err != nil {
   254  		t.Fatal(err)
   255  	}
   256  	if len(left) > 0 {
   257  		t.Errorf("%d bytes left over after Skip(): %q", len(left), left)
   258  	}
   259  }
   260  
   261  func BenchmarkMarshalMsgNeighbors(b *testing.B) {
   262  	v := Neighbors{}
   263  	b.ReportAllocs()
   264  	b.ResetTimer()
   265  	for i := 0; i < b.N; i++ {
   266  		v.MarshalMsg(nil)
   267  	}
   268  }
   269  
   270  func BenchmarkAppendMsgNeighbors(b *testing.B) {
   271  	v := Neighbors{}
   272  	bts := make([]byte, 0, v.Msgsize())
   273  	bts, _ = v.MarshalMsg(bts[0:0])
   274  	b.SetBytes(int64(len(bts)))
   275  	b.ReportAllocs()
   276  	b.ResetTimer()
   277  	for i := 0; i < b.N; i++ {
   278  		bts, _ = v.MarshalMsg(bts[0:0])
   279  	}
   280  }
   281  
   282  func BenchmarkUnmarshalNeighbors(b *testing.B) {
   283  	v := Neighbors{}
   284  	bts, _ := v.MarshalMsg(nil)
   285  	b.ReportAllocs()
   286  	b.SetBytes(int64(len(bts)))
   287  	b.ResetTimer()
   288  	for i := 0; i < b.N; i++ {
   289  		_, err := v.UnmarshalMsg(bts)
   290  		if err != nil {
   291  			b.Fatal(err)
   292  		}
   293  	}
   294  }
   295  
   296  func TestEncodeDecodeNeighbors(t *testing.T) {
   297  	v := Neighbors{}
   298  	var buf bytes.Buffer
   299  	msgp.Encode(&buf, &v)
   300  
   301  	m := v.Msgsize()
   302  	if buf.Len() > m {
   303  		t.Logf("WARNING: Msgsize() for %v is inaccurate", v)
   304  	}
   305  
   306  	vn := Neighbors{}
   307  	err := msgp.Decode(&buf, &vn)
   308  	if err != nil {
   309  		t.Error(err)
   310  	}
   311  
   312  	buf.Reset()
   313  	msgp.Encode(&buf, &v)
   314  	err = msgp.NewReader(&buf).Skip()
   315  	if err != nil {
   316  		t.Error(err)
   317  	}
   318  }
   319  
   320  func BenchmarkEncodeNeighbors(b *testing.B) {
   321  	v := Neighbors{}
   322  	var buf bytes.Buffer
   323  	msgp.Encode(&buf, &v)
   324  	b.SetBytes(int64(buf.Len()))
   325  	en := msgp.NewWriter(msgp.Nowhere)
   326  	b.ReportAllocs()
   327  	b.ResetTimer()
   328  	for i := 0; i < b.N; i++ {
   329  		v.EncodeMsg(en)
   330  	}
   331  	en.Flush()
   332  }
   333  
   334  func BenchmarkDecodeNeighbors(b *testing.B) {
   335  	v := Neighbors{}
   336  	var buf bytes.Buffer
   337  	msgp.Encode(&buf, &v)
   338  	b.SetBytes(int64(buf.Len()))
   339  	rd := msgp.NewEndlessReader(buf.Bytes(), b)
   340  	dc := msgp.NewReader(rd)
   341  	b.ReportAllocs()
   342  	b.ResetTimer()
   343  	for i := 0; i < b.N; i++ {
   344  		err := v.DecodeMsg(dc)
   345  		if err != nil {
   346  			b.Fatal(err)
   347  		}
   348  	}
   349  }
   350  
   351  func TestMarshalUnmarshalPing(t *testing.T) {
   352  	v := Ping{}
   353  	bts, err := v.MarshalMsg(nil)
   354  	if err != nil {
   355  		t.Fatal(err)
   356  	}
   357  	left, err := v.UnmarshalMsg(bts)
   358  	if err != nil {
   359  		t.Fatal(err)
   360  	}
   361  	if len(left) > 0 {
   362  		t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left)
   363  	}
   364  
   365  	left, err = msgp.Skip(bts)
   366  	if err != nil {
   367  		t.Fatal(err)
   368  	}
   369  	if len(left) > 0 {
   370  		t.Errorf("%d bytes left over after Skip(): %q", len(left), left)
   371  	}
   372  }
   373  
   374  func BenchmarkMarshalMsgPing(b *testing.B) {
   375  	v := Ping{}
   376  	b.ReportAllocs()
   377  	b.ResetTimer()
   378  	for i := 0; i < b.N; i++ {
   379  		v.MarshalMsg(nil)
   380  	}
   381  }
   382  
   383  func BenchmarkAppendMsgPing(b *testing.B) {
   384  	v := Ping{}
   385  	bts := make([]byte, 0, v.Msgsize())
   386  	bts, _ = v.MarshalMsg(bts[0:0])
   387  	b.SetBytes(int64(len(bts)))
   388  	b.ReportAllocs()
   389  	b.ResetTimer()
   390  	for i := 0; i < b.N; i++ {
   391  		bts, _ = v.MarshalMsg(bts[0:0])
   392  	}
   393  }
   394  
   395  func BenchmarkUnmarshalPing(b *testing.B) {
   396  	v := Ping{}
   397  	bts, _ := v.MarshalMsg(nil)
   398  	b.ReportAllocs()
   399  	b.SetBytes(int64(len(bts)))
   400  	b.ResetTimer()
   401  	for i := 0; i < b.N; i++ {
   402  		_, err := v.UnmarshalMsg(bts)
   403  		if err != nil {
   404  			b.Fatal(err)
   405  		}
   406  	}
   407  }
   408  
   409  func TestEncodeDecodePing(t *testing.T) {
   410  	v := Ping{}
   411  	var buf bytes.Buffer
   412  	msgp.Encode(&buf, &v)
   413  
   414  	m := v.Msgsize()
   415  	if buf.Len() > m {
   416  		t.Logf("WARNING: Msgsize() for %v is inaccurate", v)
   417  	}
   418  
   419  	vn := Ping{}
   420  	err := msgp.Decode(&buf, &vn)
   421  	if err != nil {
   422  		t.Error(err)
   423  	}
   424  
   425  	buf.Reset()
   426  	msgp.Encode(&buf, &v)
   427  	err = msgp.NewReader(&buf).Skip()
   428  	if err != nil {
   429  		t.Error(err)
   430  	}
   431  }
   432  
   433  func BenchmarkEncodePing(b *testing.B) {
   434  	v := Ping{}
   435  	var buf bytes.Buffer
   436  	msgp.Encode(&buf, &v)
   437  	b.SetBytes(int64(buf.Len()))
   438  	en := msgp.NewWriter(msgp.Nowhere)
   439  	b.ReportAllocs()
   440  	b.ResetTimer()
   441  	for i := 0; i < b.N; i++ {
   442  		v.EncodeMsg(en)
   443  	}
   444  	en.Flush()
   445  }
   446  
   447  func BenchmarkDecodePing(b *testing.B) {
   448  	v := Ping{}
   449  	var buf bytes.Buffer
   450  	msgp.Encode(&buf, &v)
   451  	b.SetBytes(int64(buf.Len()))
   452  	rd := msgp.NewEndlessReader(buf.Bytes(), b)
   453  	dc := msgp.NewReader(rd)
   454  	b.ReportAllocs()
   455  	b.ResetTimer()
   456  	for i := 0; i < b.N; i++ {
   457  		err := v.DecodeMsg(dc)
   458  		if err != nil {
   459  			b.Fatal(err)
   460  		}
   461  	}
   462  }
   463  
   464  func TestMarshalUnmarshalPong(t *testing.T) {
   465  	v := Pong{}
   466  	bts, err := v.MarshalMsg(nil)
   467  	if err != nil {
   468  		t.Fatal(err)
   469  	}
   470  	left, err := v.UnmarshalMsg(bts)
   471  	if err != nil {
   472  		t.Fatal(err)
   473  	}
   474  	if len(left) > 0 {
   475  		t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left)
   476  	}
   477  
   478  	left, err = msgp.Skip(bts)
   479  	if err != nil {
   480  		t.Fatal(err)
   481  	}
   482  	if len(left) > 0 {
   483  		t.Errorf("%d bytes left over after Skip(): %q", len(left), left)
   484  	}
   485  }
   486  
   487  func BenchmarkMarshalMsgPong(b *testing.B) {
   488  	v := Pong{}
   489  	b.ReportAllocs()
   490  	b.ResetTimer()
   491  	for i := 0; i < b.N; i++ {
   492  		v.MarshalMsg(nil)
   493  	}
   494  }
   495  
   496  func BenchmarkAppendMsgPong(b *testing.B) {
   497  	v := Pong{}
   498  	bts := make([]byte, 0, v.Msgsize())
   499  	bts, _ = v.MarshalMsg(bts[0:0])
   500  	b.SetBytes(int64(len(bts)))
   501  	b.ReportAllocs()
   502  	b.ResetTimer()
   503  	for i := 0; i < b.N; i++ {
   504  		bts, _ = v.MarshalMsg(bts[0:0])
   505  	}
   506  }
   507  
   508  func BenchmarkUnmarshalPong(b *testing.B) {
   509  	v := Pong{}
   510  	bts, _ := v.MarshalMsg(nil)
   511  	b.ReportAllocs()
   512  	b.SetBytes(int64(len(bts)))
   513  	b.ResetTimer()
   514  	for i := 0; i < b.N; i++ {
   515  		_, err := v.UnmarshalMsg(bts)
   516  		if err != nil {
   517  			b.Fatal(err)
   518  		}
   519  	}
   520  }
   521  
   522  func TestEncodeDecodePong(t *testing.T) {
   523  	v := Pong{}
   524  	var buf bytes.Buffer
   525  	msgp.Encode(&buf, &v)
   526  
   527  	m := v.Msgsize()
   528  	if buf.Len() > m {
   529  		t.Logf("WARNING: Msgsize() for %v is inaccurate", v)
   530  	}
   531  
   532  	vn := Pong{}
   533  	err := msgp.Decode(&buf, &vn)
   534  	if err != nil {
   535  		t.Error(err)
   536  	}
   537  
   538  	buf.Reset()
   539  	msgp.Encode(&buf, &v)
   540  	err = msgp.NewReader(&buf).Skip()
   541  	if err != nil {
   542  		t.Error(err)
   543  	}
   544  }
   545  
   546  func BenchmarkEncodePong(b *testing.B) {
   547  	v := Pong{}
   548  	var buf bytes.Buffer
   549  	msgp.Encode(&buf, &v)
   550  	b.SetBytes(int64(buf.Len()))
   551  	en := msgp.NewWriter(msgp.Nowhere)
   552  	b.ReportAllocs()
   553  	b.ResetTimer()
   554  	for i := 0; i < b.N; i++ {
   555  		v.EncodeMsg(en)
   556  	}
   557  	en.Flush()
   558  }
   559  
   560  func BenchmarkDecodePong(b *testing.B) {
   561  	v := Pong{}
   562  	var buf bytes.Buffer
   563  	msgp.Encode(&buf, &v)
   564  	b.SetBytes(int64(buf.Len()))
   565  	rd := msgp.NewEndlessReader(buf.Bytes(), b)
   566  	dc := msgp.NewReader(rd)
   567  	b.ReportAllocs()
   568  	b.ResetTimer()
   569  	for i := 0; i < b.N; i++ {
   570  		err := v.DecodeMsg(dc)
   571  		if err != nil {
   572  			b.Fatal(err)
   573  		}
   574  	}
   575  }
   576  
   577  func TestMarshalUnmarshalReadPacket(t *testing.T) {
   578  	v := ReadPacket{}
   579  	bts, err := v.MarshalMsg(nil)
   580  	if err != nil {
   581  		t.Fatal(err)
   582  	}
   583  	left, err := v.UnmarshalMsg(bts)
   584  	if err != nil {
   585  		t.Fatal(err)
   586  	}
   587  	if len(left) > 0 {
   588  		t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left)
   589  	}
   590  
   591  	left, err = msgp.Skip(bts)
   592  	if err != nil {
   593  		t.Fatal(err)
   594  	}
   595  	if len(left) > 0 {
   596  		t.Errorf("%d bytes left over after Skip(): %q", len(left), left)
   597  	}
   598  }
   599  
   600  func BenchmarkMarshalMsgReadPacket(b *testing.B) {
   601  	v := ReadPacket{}
   602  	b.ReportAllocs()
   603  	b.ResetTimer()
   604  	for i := 0; i < b.N; i++ {
   605  		v.MarshalMsg(nil)
   606  	}
   607  }
   608  
   609  func BenchmarkAppendMsgReadPacket(b *testing.B) {
   610  	v := ReadPacket{}
   611  	bts := make([]byte, 0, v.Msgsize())
   612  	bts, _ = v.MarshalMsg(bts[0:0])
   613  	b.SetBytes(int64(len(bts)))
   614  	b.ReportAllocs()
   615  	b.ResetTimer()
   616  	for i := 0; i < b.N; i++ {
   617  		bts, _ = v.MarshalMsg(bts[0:0])
   618  	}
   619  }
   620  
   621  func BenchmarkUnmarshalReadPacket(b *testing.B) {
   622  	v := ReadPacket{}
   623  	bts, _ := v.MarshalMsg(nil)
   624  	b.ReportAllocs()
   625  	b.SetBytes(int64(len(bts)))
   626  	b.ResetTimer()
   627  	for i := 0; i < b.N; i++ {
   628  		_, err := v.UnmarshalMsg(bts)
   629  		if err != nil {
   630  			b.Fatal(err)
   631  		}
   632  	}
   633  }
   634  
   635  func TestEncodeDecodeReadPacket(t *testing.T) {
   636  	v := ReadPacket{}
   637  	var buf bytes.Buffer
   638  	msgp.Encode(&buf, &v)
   639  
   640  	m := v.Msgsize()
   641  	if buf.Len() > m {
   642  		t.Logf("WARNING: Msgsize() for %v is inaccurate", v)
   643  	}
   644  
   645  	vn := ReadPacket{}
   646  	err := msgp.Decode(&buf, &vn)
   647  	if err != nil {
   648  		t.Error(err)
   649  	}
   650  
   651  	buf.Reset()
   652  	msgp.Encode(&buf, &v)
   653  	err = msgp.NewReader(&buf).Skip()
   654  	if err != nil {
   655  		t.Error(err)
   656  	}
   657  }
   658  
   659  func BenchmarkEncodeReadPacket(b *testing.B) {
   660  	v := ReadPacket{}
   661  	var buf bytes.Buffer
   662  	msgp.Encode(&buf, &v)
   663  	b.SetBytes(int64(buf.Len()))
   664  	en := msgp.NewWriter(msgp.Nowhere)
   665  	b.ReportAllocs()
   666  	b.ResetTimer()
   667  	for i := 0; i < b.N; i++ {
   668  		v.EncodeMsg(en)
   669  	}
   670  	en.Flush()
   671  }
   672  
   673  func BenchmarkDecodeReadPacket(b *testing.B) {
   674  	v := ReadPacket{}
   675  	var buf bytes.Buffer
   676  	msgp.Encode(&buf, &v)
   677  	b.SetBytes(int64(buf.Len()))
   678  	rd := msgp.NewEndlessReader(buf.Bytes(), b)
   679  	dc := msgp.NewReader(rd)
   680  	b.ReportAllocs()
   681  	b.ResetTimer()
   682  	for i := 0; i < b.N; i++ {
   683  		err := v.DecodeMsg(dc)
   684  		if err != nil {
   685  			b.Fatal(err)
   686  		}
   687  	}
   688  }
   689  
   690  func TestMarshalUnmarshalRpcEndpoint(t *testing.T) {
   691  	v := RpcEndpoint{}
   692  	bts, err := v.MarshalMsg(nil)
   693  	if err != nil {
   694  		t.Fatal(err)
   695  	}
   696  	left, err := v.UnmarshalMsg(bts)
   697  	if err != nil {
   698  		t.Fatal(err)
   699  	}
   700  	if len(left) > 0 {
   701  		t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left)
   702  	}
   703  
   704  	left, err = msgp.Skip(bts)
   705  	if err != nil {
   706  		t.Fatal(err)
   707  	}
   708  	if len(left) > 0 {
   709  		t.Errorf("%d bytes left over after Skip(): %q", len(left), left)
   710  	}
   711  }
   712  
   713  func BenchmarkMarshalMsgRpcEndpoint(b *testing.B) {
   714  	v := RpcEndpoint{}
   715  	b.ReportAllocs()
   716  	b.ResetTimer()
   717  	for i := 0; i < b.N; i++ {
   718  		v.MarshalMsg(nil)
   719  	}
   720  }
   721  
   722  func BenchmarkAppendMsgRpcEndpoint(b *testing.B) {
   723  	v := RpcEndpoint{}
   724  	bts := make([]byte, 0, v.Msgsize())
   725  	bts, _ = v.MarshalMsg(bts[0:0])
   726  	b.SetBytes(int64(len(bts)))
   727  	b.ReportAllocs()
   728  	b.ResetTimer()
   729  	for i := 0; i < b.N; i++ {
   730  		bts, _ = v.MarshalMsg(bts[0:0])
   731  	}
   732  }
   733  
   734  func BenchmarkUnmarshalRpcEndpoint(b *testing.B) {
   735  	v := RpcEndpoint{}
   736  	bts, _ := v.MarshalMsg(nil)
   737  	b.ReportAllocs()
   738  	b.SetBytes(int64(len(bts)))
   739  	b.ResetTimer()
   740  	for i := 0; i < b.N; i++ {
   741  		_, err := v.UnmarshalMsg(bts)
   742  		if err != nil {
   743  			b.Fatal(err)
   744  		}
   745  	}
   746  }
   747  
   748  func TestEncodeDecodeRpcEndpoint(t *testing.T) {
   749  	v := RpcEndpoint{}
   750  	var buf bytes.Buffer
   751  	msgp.Encode(&buf, &v)
   752  
   753  	m := v.Msgsize()
   754  	if buf.Len() > m {
   755  		t.Logf("WARNING: Msgsize() for %v is inaccurate", v)
   756  	}
   757  
   758  	vn := RpcEndpoint{}
   759  	err := msgp.Decode(&buf, &vn)
   760  	if err != nil {
   761  		t.Error(err)
   762  	}
   763  
   764  	buf.Reset()
   765  	msgp.Encode(&buf, &v)
   766  	err = msgp.NewReader(&buf).Skip()
   767  	if err != nil {
   768  		t.Error(err)
   769  	}
   770  }
   771  
   772  func BenchmarkEncodeRpcEndpoint(b *testing.B) {
   773  	v := RpcEndpoint{}
   774  	var buf bytes.Buffer
   775  	msgp.Encode(&buf, &v)
   776  	b.SetBytes(int64(buf.Len()))
   777  	en := msgp.NewWriter(msgp.Nowhere)
   778  	b.ReportAllocs()
   779  	b.ResetTimer()
   780  	for i := 0; i < b.N; i++ {
   781  		v.EncodeMsg(en)
   782  	}
   783  	en.Flush()
   784  }
   785  
   786  func BenchmarkDecodeRpcEndpoint(b *testing.B) {
   787  	v := RpcEndpoint{}
   788  	var buf bytes.Buffer
   789  	msgp.Encode(&buf, &v)
   790  	b.SetBytes(int64(buf.Len()))
   791  	rd := msgp.NewEndlessReader(buf.Bytes(), b)
   792  	dc := msgp.NewReader(rd)
   793  	b.ReportAllocs()
   794  	b.ResetTimer()
   795  	for i := 0; i < b.N; i++ {
   796  		err := v.DecodeMsg(dc)
   797  		if err != nil {
   798  			b.Fatal(err)
   799  		}
   800  	}
   801  }
   802  
   803  func TestMarshalUnmarshalRpcNode(t *testing.T) {
   804  	v := RpcNode{}
   805  	bts, err := v.MarshalMsg(nil)
   806  	if err != nil {
   807  		t.Fatal(err)
   808  	}
   809  	left, err := v.UnmarshalMsg(bts)
   810  	if err != nil {
   811  		t.Fatal(err)
   812  	}
   813  	if len(left) > 0 {
   814  		t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left)
   815  	}
   816  
   817  	left, err = msgp.Skip(bts)
   818  	if err != nil {
   819  		t.Fatal(err)
   820  	}
   821  	if len(left) > 0 {
   822  		t.Errorf("%d bytes left over after Skip(): %q", len(left), left)
   823  	}
   824  }
   825  
   826  func BenchmarkMarshalMsgRpcNode(b *testing.B) {
   827  	v := RpcNode{}
   828  	b.ReportAllocs()
   829  	b.ResetTimer()
   830  	for i := 0; i < b.N; i++ {
   831  		v.MarshalMsg(nil)
   832  	}
   833  }
   834  
   835  func BenchmarkAppendMsgRpcNode(b *testing.B) {
   836  	v := RpcNode{}
   837  	bts := make([]byte, 0, v.Msgsize())
   838  	bts, _ = v.MarshalMsg(bts[0:0])
   839  	b.SetBytes(int64(len(bts)))
   840  	b.ReportAllocs()
   841  	b.ResetTimer()
   842  	for i := 0; i < b.N; i++ {
   843  		bts, _ = v.MarshalMsg(bts[0:0])
   844  	}
   845  }
   846  
   847  func BenchmarkUnmarshalRpcNode(b *testing.B) {
   848  	v := RpcNode{}
   849  	bts, _ := v.MarshalMsg(nil)
   850  	b.ReportAllocs()
   851  	b.SetBytes(int64(len(bts)))
   852  	b.ResetTimer()
   853  	for i := 0; i < b.N; i++ {
   854  		_, err := v.UnmarshalMsg(bts)
   855  		if err != nil {
   856  			b.Fatal(err)
   857  		}
   858  	}
   859  }
   860  
   861  func TestEncodeDecodeRpcNode(t *testing.T) {
   862  	v := RpcNode{}
   863  	var buf bytes.Buffer
   864  	msgp.Encode(&buf, &v)
   865  
   866  	m := v.Msgsize()
   867  	if buf.Len() > m {
   868  		t.Logf("WARNING: Msgsize() for %v is inaccurate", v)
   869  	}
   870  
   871  	vn := RpcNode{}
   872  	err := msgp.Decode(&buf, &vn)
   873  	if err != nil {
   874  		t.Error(err)
   875  	}
   876  
   877  	buf.Reset()
   878  	msgp.Encode(&buf, &v)
   879  	err = msgp.NewReader(&buf).Skip()
   880  	if err != nil {
   881  		t.Error(err)
   882  	}
   883  }
   884  
   885  func BenchmarkEncodeRpcNode(b *testing.B) {
   886  	v := RpcNode{}
   887  	var buf bytes.Buffer
   888  	msgp.Encode(&buf, &v)
   889  	b.SetBytes(int64(buf.Len()))
   890  	en := msgp.NewWriter(msgp.Nowhere)
   891  	b.ReportAllocs()
   892  	b.ResetTimer()
   893  	for i := 0; i < b.N; i++ {
   894  		v.EncodeMsg(en)
   895  	}
   896  	en.Flush()
   897  }
   898  
   899  func BenchmarkDecodeRpcNode(b *testing.B) {
   900  	v := RpcNode{}
   901  	var buf bytes.Buffer
   902  	msgp.Encode(&buf, &v)
   903  	b.SetBytes(int64(buf.Len()))
   904  	rd := msgp.NewEndlessReader(buf.Bytes(), b)
   905  	dc := msgp.NewReader(rd)
   906  	b.ReportAllocs()
   907  	b.ResetTimer()
   908  	for i := 0; i < b.N; i++ {
   909  		err := v.DecodeMsg(dc)
   910  		if err != nil {
   911  			b.Fatal(err)
   912  		}
   913  	}
   914  }