@@ -15,17 +15,29 @@ func TestMultilayerDecode(t *testing.T) {
1515 10 , 184 , 73 , 195 , 65 , 0 , 0 , 0 , 0 , 1 , 3 , 3 , 7 ,
1616 }
1717
18- ethernetFrame := DecodeEthernet (b )
18+ ethernetFrame , err := DecodeEthernet (b )
19+ if err != nil {
20+ t .Fatal (err )
21+ }
22+
1923 if ethernetFrame .EtherType != 0x86dd {
2024 t .Fatalf ("expected to see EtherType %x, got %x" , 0x86dd , ethernetFrame .EtherType )
2125 }
2226
23- ipv6Packet := DecodeIPv6 (ethernetFrame .Payload )
27+ ipv6Packet , err := DecodeIPv6 (ethernetFrame .Payload )
28+ if err != nil {
29+ t .Fatal (err )
30+ }
31+
2432 if ipv6Packet .NextHeader != 0x6 {
2533 t .Fatalf ("expected to see NextHeader %x, got %x" , 0x6 , ipv6Packet .NextHeader )
2634 }
2735
28- tcpPacket := DecodeTCP (ipv6Packet .Payload )
36+ tcpPacket , err := DecodeTCP (ipv6Packet .Payload )
37+ if err != nil {
38+ t .Fatal (err )
39+ }
40+
2941 if tcpPacket .DestinationPort != 80 {
3042 t .Fatalf ("expected to see destination port %v, got %v" , 80 , tcpPacket .DestinationPort )
3143 }
@@ -51,8 +63,8 @@ func BenchmarkMultilayerDecode(b *testing.B) {
5163 }
5264
5365 for i := 0 ; i < b .N ; i ++ {
54- ethernetFrame := DecodeEthernet (buf [:])
55- ipv6Packet := DecodeIPv6 (ethernetFrame .Payload )
66+ ethernetFrame , _ := DecodeEthernet (buf [:])
67+ ipv6Packet , _ := DecodeIPv6 (ethernetFrame .Payload )
5668 DecodeTCP (ipv6Packet .Payload )
5769 }
5870}
0 commit comments