@@ -65,6 +65,7 @@ func TestFetchModeCompat(t *testing.T) {
6565 hydMode peercfg.GalaxyHandlerMode
6666 prefixSelfName bool
6767 echoKey bool
68+ keyExpiry time.Time
6869
6970 enablePeek bool
7071 }
@@ -79,6 +80,7 @@ func TestFetchModeCompat(t *testing.T) {
7980 expVal string // ignored if one of the below is set
8081 expNotFound bool
8182 expErr bool
83+ expiry time.Time
8284 }
8385
8486 v12WorkerPath := filepath .Join (t .TempDir (), "peerv1.2" )
@@ -92,6 +94,8 @@ func TestFetchModeCompat(t *testing.T) {
9294 }
9395 }
9496
97+ baseTime := time .Now ()
98+
9599 for _ , tbl := range []struct {
96100 name string
97101 // Names will be "<version>-<index>" (where "<version>" is either "v1.2" or "head")
@@ -184,6 +188,7 @@ func TestFetchModeCompat(t *testing.T) {
184188 prefixSelfName : true ,
185189 echoKey : true ,
186190 enablePeek : false ,
191+ keyExpiry : baseTime .Add (time .Hour * 31 ),
187192 },
188193 },
189194 headFetchKeys : []fetchKeyExp {
@@ -195,6 +200,7 @@ func TestFetchModeCompat(t *testing.T) {
195200 expVal : "head-0: " + chtest .SingleOwnerKey ("head-0" ) + ": {some value}" ,
196201 expNotFound : false ,
197202 expErr : false ,
203+ expiry : baseTime .Add (time .Hour * 31 ),
198204 },
199205 {
200206 headHostIdx : 0 ,
@@ -204,6 +210,7 @@ func TestFetchModeCompat(t *testing.T) {
204210 expVal : "v1.2-0: " + chtest .FallthroughKey ("v1.2-0" , "head-0" ) + ": {some value}" ,
205211 expNotFound : false ,
206212 expErr : false ,
213+ expiry : time.Time {},
207214 },
208215 {
209216 headHostIdx : 0 ,
@@ -213,6 +220,7 @@ func TestFetchModeCompat(t *testing.T) {
213220 expVal : "v1.2-0: " + chtest .FallthroughKey ("v1.2-0" , "head-0" ) + ": {some value}" ,
214221 expNotFound : false ,
215222 expErr : false ,
223+ expiry : time.Time {},
216224 },
217225 },
218226 galaxyName : "fizzlebat" ,
@@ -230,6 +238,7 @@ func TestFetchModeCompat(t *testing.T) {
230238 prefixSelfName : true ,
231239 echoKey : true ,
232240 enablePeek : false ,
241+ keyExpiry : baseTime .Add (time .Hour * 37 ),
233242 },
234243 {
235244 fetchProto : peercfg .FetchGRPC ,
@@ -240,6 +249,7 @@ func TestFetchModeCompat(t *testing.T) {
240249 prefixSelfName : true ,
241250 echoKey : true ,
242251 enablePeek : false ,
252+ keyExpiry : baseTime .Add (time .Hour * 34 ),
243253 },
244254 {
245255 fetchProto : peercfg .FetchGRPC ,
@@ -250,6 +260,7 @@ func TestFetchModeCompat(t *testing.T) {
250260 prefixSelfName : true ,
251261 echoKey : true ,
252262 enablePeek : false ,
263+ keyExpiry : baseTime .Add (time .Hour * 31 ),
253264 },
254265 },
255266 headFetchKeys : []fetchKeyExp {
@@ -261,6 +272,7 @@ func TestFetchModeCompat(t *testing.T) {
261272 expVal : "" , // ignored
262273 expNotFound : true ,
263274 expErr : false ,
275+ expiry : time.Time {},
264276 },
265277 {
266278 headHostIdx : 0 ,
@@ -270,6 +282,7 @@ func TestFetchModeCompat(t *testing.T) {
270282 expVal : "head-0: " + chtest .FallthroughKey ("head-0" , "head-1" ) + ": {some value}" ,
271283 expNotFound : false ,
272284 expErr : false ,
285+ expiry : baseTime .Add (time .Hour * 37 ),
273286 },
274287 {
275288 headHostIdx : 0 ,
@@ -279,6 +292,7 @@ func TestFetchModeCompat(t *testing.T) {
279292 expVal : "head-0: " + chtest .FallthroughKey ("head-0" , "head-1" ) + ": {some value}" , // already cached
280293 expNotFound : false ,
281294 expErr : false ,
295+ expiry : baseTime .Add (time .Hour * 37 ),
282296 },
283297 {
284298 headHostIdx : 1 ,
@@ -288,6 +302,7 @@ func TestFetchModeCompat(t *testing.T) {
288302 expVal : "head-0: " + chtest .SingleOwnerKey ("head-0" ) + ": {some value}" ,
289303 expNotFound : false ,
290304 expErr : false ,
305+ expiry : baseTime .Add (time .Hour * 37 ),
291306 },
292307 {
293308 headHostIdx : 1 ,
@@ -297,6 +312,7 @@ func TestFetchModeCompat(t *testing.T) {
297312 expVal : "head-2: " + chtest .FallthroughKey ("head-2" , "head-0" ) + ": {some value}" ,
298313 expNotFound : false ,
299314 expErr : false ,
315+ expiry : baseTime .Add (time .Hour * 31 ),
300316 },
301317 {
302318 headHostIdx : 1 ,
@@ -306,6 +322,7 @@ func TestFetchModeCompat(t *testing.T) {
306322 expVal : "head-0: " + chtest .FallthroughKey ("head-1" , "head-0" ) + ": {some value}" ,
307323 expNotFound : false ,
308324 expErr : false ,
325+ expiry : baseTime .Add (time .Hour * 37 ),
309326 },
310327 {
311328 headHostIdx : 1 ,
@@ -315,6 +332,7 @@ func TestFetchModeCompat(t *testing.T) {
315332 expVal : "head-0: " + chtest .FallthroughKey ("head-1" , "head-0" ) + ": {some value}" ,
316333 expNotFound : false ,
317334 expErr : false ,
335+ expiry : baseTime .Add (time .Hour * 37 ),
318336 },
319337 },
320338 galaxyName : "fizzlebat" ,
@@ -1034,7 +1052,8 @@ func TestFetchModeCompat(t *testing.T) {
10341052 Bytes : pInfo .opts .galaxySize ,
10351053 HydrationMode : pInfo .opts .hydMode ,
10361054 // peek isn't implemented for v1.2 peers (but it'll be ignored there anyway)
1037- Peek : peek ,
1055+ Peek : peek ,
1056+ Expiry : pInfo .opts .keyExpiry ,
10381057 }},
10391058 }
10401059 }
@@ -1121,9 +1140,13 @@ func TestFetchModeCompat(t *testing.T) {
11211140
11221141 g := ugs .gs [0 ]
11231142 sc := galaxycache .StringCodec ("" )
1124- _ , getErr := g .GetWithOptions (ctx , fk .getOpts , fk .key , & sc )
1143+ bgInfo , getErr := g .GetWithOptions (ctx , fk .getOpts , fk .key , & sc )
11251144 ugs .u .SetIncludeSelf (origIncSelf ) // restore the IncludeSelf value
11261145
1146+ if ! bgInfo .Expiry .Equal (fk .expiry ) {
1147+ t .Errorf ("key idx %d: unexpected expiry: %s; expected %s" , i , bgInfo .Expiry , fk .expiry )
1148+ }
1149+
11271150 nfErr := (galaxycache .NotFoundErr )(nil )
11281151 isNotFound := errors .As (getErr , & nfErr )
11291152 if isNotFound {
0 commit comments