@@ -48,15 +48,35 @@ describe('publish', () => {
48
48
expect ( ipnsEntry ) . to . have . property ( 'ttl' , 3_600_000_000_000n ) // 1 hour
49
49
} )
50
50
51
- it ( 'should publish an IPNS record with a custom ttl params' , async function ( ) {
51
+ it ( 'should publish an IPNS record with a custom lifetime params' , async function ( ) {
52
52
const key = await generateKeyPair ( 'Ed25519' )
53
53
const lifetime = 123000
54
+ // lifetime is used to calculate the validity timestamp
54
55
const ipnsEntry = await name . publish ( key , cid , {
55
56
lifetime
56
57
} )
57
58
58
59
expect ( ipnsEntry ) . to . have . property ( 'sequence' , 1n )
59
- expect ( ipnsEntry ) . to . have . property ( 'ttl' , 3_600_000_000_000n )
60
+
61
+ // Ignore the milliseconds after the dot 2025-01-22T12:07:33.650000000Z
62
+ const expectedValidity = new Date ( Date . now ( ) + lifetime ) . toISOString ( ) . split ( '.' ) [ 0 ]
63
+
64
+ expect ( ipnsEntry . validity . split ( '.' ) [ 0 ] ) . to . equal ( expectedValidity )
65
+
66
+ expect ( heliaRouting . put . called ) . to . be . true ( )
67
+ expect ( customRouting . put . called ) . to . be . true ( )
68
+ } )
69
+
70
+ it ( 'should publish an IPNS record with a custom ttl params' , async function ( ) {
71
+ const key = await generateKeyPair ( 'Ed25519' )
72
+ const ttl = 1000 // override the default ttl
73
+
74
+ const ipnsEntry = await name . publish ( key , cid , {
75
+ ttl
76
+ } )
77
+
78
+ expect ( ipnsEntry ) . to . have . property ( 'sequence' , 1n )
79
+ expect ( ipnsEntry ) . to . have . property ( 'ttl' , BigInt ( ttl * 1e+6 ) )
60
80
61
81
expect ( heliaRouting . put . called ) . to . be . true ( )
62
82
expect ( customRouting . put . called ) . to . be . true ( )
0 commit comments