From 1e91a5aa67ef2da1bbaedafd7d1a91855f4b2993 Mon Sep 17 00:00:00 2001
From: Faidon Liambotis <paravoid@debian.org>
Date: Wed, 11 Sep 2024 13:05:46 +0300
Subject: [PATCH 1/2] tests: fix query ID-related Net::DNS 1.46 breakage

Net::DNS 1.46, commit r1980 stopped generating random query IDs when
->header->id() is called, instead generating them and storing them
internally when the query is encoded. As such, calling ->header->id()
may now return undef.

Workaround this issue by calling ->encode right before retrieving the
(potentially random) query ID.

Identified by Natanael Copa.
---
 t/_GDT.pm | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/t/_GDT.pm b/t/_GDT.pm
index ca94c039..ddde67e9 100644
--- a/t/_GDT.pm
+++ b/t/_GDT.pm
@@ -1056,6 +1056,7 @@ sub query_server {
         );
         send($sock, $qpacket_raw, 0);
         if($expected) {
+            $query->encode;  # generate a random ID, required with Net::DNS >= 1.46
             $expected->header->id($query->header->id);
             my $res_raw;
             recv($sock, $res_raw, 4096, 0);
@@ -1075,6 +1076,7 @@ sub query_server {
         }
 
         if($expected) {
+            $query->encode;  # generate a random ID, required with Net::DNS >= 1.46
             $expected->header->id($query->header->id);
             $size = _GDT->compare_packets($res->send($query), $expected, $limit_v4, $limit_v6, $wrr_v4, $wrr_v6);
         }

From d10b7960f4f46ab48d9719aeea4019e6a24e18e7 Mon Sep 17 00:00:00 2001
From: Faidon Liambotis <paravoid@debian.org>
Date: Wed, 11 Sep 2024 13:13:39 +0300
Subject: [PATCH 2/2] tests: fix UDP packet size-related Net::DNS 1.46 breakage

Net::DNS 1.46, commit r1982 stopped setting the EDNS UDP packet size
based on the resolver opts udppacketsize attribute. Do so manually.

Use ->size() rather than ->udpsize() to retain < 1.37 compatibility with
the trade-off of spurious deprecated warnings emitted with >= 1.37.
---
 t/_GDT.pm | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/t/_GDT.pm b/t/_GDT.pm
index ddde67e9..f9c2f2f6 100644
--- a/t/_GDT.pm
+++ b/t/_GDT.pm
@@ -1075,6 +1075,9 @@ sub query_server {
             $res->$k($ro->{$k})
         }
 
+        # Net::DNS <= 1.45 (r1982) did this internally
+        $query->edns->size($ro->{udppacketsize}) if defined $ro->{udppacketsize};
+
         if($expected) {
             $query->encode;  # generate a random ID, required with Net::DNS >= 1.46
             $expected->header->id($query->header->id);
