same(parsed:qname(), pkt:qname(), 'parsed packet has same QNAME')
same(parsed:qtype(), pkt:qtype(), 'parsed packet has same QTYPE')
same(parsed:qclass(), pkt:qclass(), 'parsed packet has same QCLASS')
+ same(parsed:opcode(), pkt:opcode(), 'parsed packet has same opcode')
same(parsed:rcode(), pkt:rcode(), 'parsed packet has same rcode')
same(parsed:rd(), pkt:rd(), 'parsed packet has same RD')
same(parsed:id(), pkt:id(), 'parsed packet has same MSGID')
+ same(parsed:qdcount(), pkt:qdcount(), 'parsed packet has same question count')
same(parsed:ancount(), pkt:ancount(), 'parsed packet has same answer count')
+ same(parsed:nscount(), pkt:nscount(), 'parsed packet has same authority count')
+ same(parsed:arcount(), pkt:arcount(), 'parsed packet has same additional count')
same(parsed:tostring(), pkt:tostring(), 'parsed packet is equal to source packet')
+
-- Test recycling of packets
+ -- Clear_payload keeps header + question intact
+ local cleared = kres.packet(#wire, wire) -- same as "parsed" above
+ ok(cleared:parse(), 'parsing packet from wire works')
+ ok(cleared:clear_payload(), 'clear_payload works')
+ same(cleared:id(), pkt:id(), 'cleared packet has same MSGID')
+ same(cleared:qr(), pkt:qr(), 'cleared packet has same QR')
+ same(cleared:opcode(), pkt:opcode(), 'cleared packet has same OPCODE')
+ same(cleared:aa(), pkt:aa(), 'cleared packet has same AA')
+ same(cleared:tc(), pkt:tc(), 'cleared packet has same TC')
+ same(cleared:rd(), pkt:rd(), 'cleared packet has same RD')
+ same(cleared:ra(), pkt:ra(), 'cleared packet has same RA')
+ same(cleared:ad(), pkt:ad(), 'cleared packet has same AD')
+ same(cleared:cd(), pkt:cd(), 'cleared packet has same CD')
+ same(cleared:rcode(), pkt:rcode(), 'cleared packet has same RCODE')
+ same(cleared:qdcount(), pkt:qdcount(), 'cleared packet has same question count')
+ same(cleared:ancount(), 0, 'cleared packet has no answers')
+ same(cleared:nscount(), 0, 'cleared packet has no authority')
+ same(cleared:arcount(), 0, 'cleared packet has no additional')
+ same(cleared:qname(), pkt:qname(), 'cleared packet has same QNAME')
+ same(cleared:qtype(), pkt:qtype(), 'cleared packet has same QTYPE')
+ same(cleared:qclass(), pkt:qclass(), 'cleared packet has same QCLASS')
+
+ -- Recycle clears question as well
ok(pkt:recycle(), 'recycle() works')
is(pkt:ancount(), 0, 'recycle() clears records')
is(pkt:qname(), nil, 'recycle() clears question')
test_globals,
test_rrset_functions,
test_packet_functions,
-}
\ No newline at end of file
+}