Skip to content

Commit 224dca2

Browse files
committed
fixup! fix(warm-storage): check metadata withCDN key in addition to cdnRailId for CDN status
1 parent fea69f5 commit 224dca2

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

packages/synapse-sdk/src/test/warm-storage-service.test.ts

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,92 @@ describe('WarmStorageService', () => {
332332
assert.isTrue(managedDataSets[0].isManaged)
333333
})
334334

335+
it('should set withCDN true when cdnRailId > 0 and withCDN metadata key present', async () => {
336+
server.use(
337+
JSONRPC({
338+
...presets.basic,
339+
warmStorageView: {
340+
...presets.basic.warmStorageView,
341+
clientDataSets: () => [[242n]],
342+
getDataSet: () => [
343+
{
344+
pdpRailId: 48n,
345+
cacheMissRailId: 50n,
346+
cdnRailId: 51n, // CDN rail exists
347+
payer: ADDRESSES.client1,
348+
payee: ADDRESSES.payee1,
349+
serviceProvider: ADDRESSES.serviceProvider1,
350+
commissionBps: 100n,
351+
clientDataSetId: 0n,
352+
pdpEndEpoch: 0n,
353+
providerId: 1n,
354+
dataSetId: 242n,
355+
},
356+
],
357+
getAllDataSetMetadata: () => [
358+
['withCDN'], // withCDN key present
359+
[''],
360+
],
361+
},
362+
pdpVerifier: {
363+
...presets.basic.pdpVerifier,
364+
dataSetLive: () => [true],
365+
getNextPieceId: () => [2n],
366+
getDataSetListener: () => [ADDRESSES.calibration.warmStorage],
367+
},
368+
})
369+
)
370+
const warmStorageService = await createWarmStorageService()
371+
const detailedDataSets = await warmStorageService.getClientDataSetsWithDetails(ADDRESSES.client1)
372+
373+
assert.lengthOf(detailedDataSets, 1)
374+
assert.equal(detailedDataSets[0].cdnRailId, 51)
375+
assert.isTrue(detailedDataSets[0].withCDN)
376+
})
377+
378+
it('should set withCDN false when cdnRailId > 0 but withCDN metadata key missing (terminated)', async () => {
379+
server.use(
380+
JSONRPC({
381+
...presets.basic,
382+
warmStorageView: {
383+
...presets.basic.warmStorageView,
384+
clientDataSets: () => [[242n]],
385+
getDataSet: () => [
386+
{
387+
pdpRailId: 48n,
388+
cacheMissRailId: 50n,
389+
cdnRailId: 51n, // CDN rail still exists
390+
payer: ADDRESSES.client1,
391+
payee: ADDRESSES.payee1,
392+
serviceProvider: ADDRESSES.serviceProvider1,
393+
commissionBps: 100n,
394+
clientDataSetId: 0n,
395+
pdpEndEpoch: 0n,
396+
providerId: 1n,
397+
dataSetId: 242n,
398+
},
399+
],
400+
getAllDataSetMetadata: () => [
401+
[], // No metadata keys - CDN was terminated
402+
[],
403+
],
404+
},
405+
pdpVerifier: {
406+
...presets.basic.pdpVerifier,
407+
dataSetLive: () => [true],
408+
getNextPieceId: () => [2n],
409+
getDataSetListener: () => [ADDRESSES.calibration.warmStorage],
410+
},
411+
})
412+
)
413+
const warmStorageService = await createWarmStorageService()
414+
const detailedDataSets = await warmStorageService.getClientDataSetsWithDetails(ADDRESSES.client1)
415+
416+
assert.lengthOf(detailedDataSets, 1)
417+
assert.equal(detailedDataSets[0].cdnRailId, 51)
418+
assert.isFalse(detailedDataSets[0].withCDN) // CDN terminated, metadata cleared
419+
})
420+
335421
it('should throw error when contract calls fail', async () => {
336422
server.use(
337423
JSONRPC({

0 commit comments

Comments
 (0)