@@ -7,7 +7,6 @@ import { createEd25519PeerId } from '@libp2p/peer-id-factory'
77import { expect } from 'aegir/chai'
88import { base58btc } from 'multiformats/bases/base58'
99import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
10- import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
1110import * as ERRORS from '../src/errors.js'
1211import * as ipns from '../src/index.js'
1312import { IpnsEntry } from '../src/pb/ipns.js'
@@ -18,7 +17,7 @@ import type { PeerId } from '@libp2p/interface-peer-id'
1817describe ( 'ipns' , function ( ) {
1918 this . timeout ( 20 * 1000 )
2019
21- const cid = uint8ArrayFromString ( 'QmWEekX7EZLUd9VXRNMRXW3LXe4F6x7mB8oPxY5XLptrBq' )
20+ const contentPath = '/ipfs/bafkqae3imvwgy3zamzzg63janjzs22lqnzzqu'
2221 let peerId : PeerId
2322
2423 before ( async ( ) => {
@@ -30,16 +29,16 @@ describe('ipns', function () {
3029 const sequence = 0
3130 const validity = 1000000
3231
33- const record = await ipns . create ( peerId , cid , sequence , validity )
32+ const record = await ipns . create ( peerId , contentPath , sequence , validity )
3433
35- expect ( record . value ( ) ) . to . equal ( uint8ArrayToString ( cid ) )
34+ expect ( record . value ( ) ) . to . equal ( contentPath )
3635 expect ( record . sequence ( ) ) . to . equal ( BigInt ( 0 ) )
3736 expect ( record . validityType ( ) ) . to . equal ( IpnsEntry . ValidityType . EOL )
3837 expect ( record . validity ( ) ) . to . exist ( )
3938 expect ( record . ttl ( ) ) . to . equal ( BigInt ( validity * 100000 ) )
4039
4140 expect ( record . pb ) . to . deep . include ( {
42- value : cid ,
41+ value : uint8ArrayFromString ( contentPath ) ,
4342 sequence : BigInt ( sequence )
4443 } )
4544 expect ( record . pb ) . to . have . property ( 'validity' )
@@ -53,9 +52,9 @@ describe('ipns', function () {
5352 const sequence = 0
5453 const validity = 1000000
5554
56- const record = await ipns . create ( peerId , cid , sequence , validity , { v1Compatible : false } )
55+ const record = await ipns . create ( peerId , contentPath , sequence , validity , { v1Compatible : false } )
5756
58- expect ( record . value ( ) ) . to . equal ( uint8ArrayToString ( cid ) )
57+ expect ( record . value ( ) ) . to . equal ( contentPath )
5958 expect ( record . sequence ( ) ) . to . equal ( BigInt ( 0 ) )
6059 expect ( record . validityType ( ) ) . to . equal ( IpnsEntry . ValidityType . EOL )
6160 expect ( record . validity ( ) ) . to . exist ( )
@@ -75,7 +74,7 @@ describe('ipns', function () {
7574 // 2033-05-18T03:33:20.000000000Z
7675 const expiration = '2033-05-18T03:33:20.000000000Z'
7776
78- const record = await ipns . createWithExpiration ( peerId , cid , sequence , expiration )
77+ const record = await ipns . createWithExpiration ( peerId , contentPath , sequence , expiration )
7978
8079 await ipnsValidator ( peerIdToRoutingKey ( peerId ) , marshal ( record ) )
8180 expect ( record . pb ) . to . have . property ( 'validity' )
@@ -87,7 +86,7 @@ describe('ipns', function () {
8786 // 2033-05-18T03:33:20.000000000Z
8887 const expiration = '2033-05-18T03:33:20.000000000Z'
8988
90- const record = await ipns . createWithExpiration ( peerId , cid , sequence , expiration , { v1Compatible : false } )
89+ const record = await ipns . createWithExpiration ( peerId , contentPath , sequence , expiration , { v1Compatible : false } )
9190
9291 await ipnsValidator ( peerIdToRoutingKey ( peerId ) , marshal ( record ) )
9392 expect ( record . pb ) . to . not . have . property ( 'validity' )
@@ -98,23 +97,23 @@ describe('ipns', function () {
9897 const sequence = 0
9998 const validity = 1000000
10099
101- const record = await ipns . create ( peerId , cid , sequence , validity )
100+ const record = await ipns . create ( peerId , contentPath , sequence , validity )
102101 await ipnsValidator ( peerIdToRoutingKey ( peerId ) , marshal ( record ) )
103102 } )
104103
105104 it ( 'should create an ipns record (V2) and validate it correctly' , async ( ) => {
106105 const sequence = 0
107106 const validity = 1000000
108107
109- const record = await ipns . create ( peerId , cid , sequence , validity , { v1Compatible : false } )
108+ const record = await ipns . create ( peerId , contentPath , sequence , validity , { v1Compatible : false } )
110109 await ipnsValidator ( peerIdToRoutingKey ( peerId ) , marshal ( record ) )
111110 } )
112111
113112 it ( 'should fail to validate a v1 (deprecated legacy) message' , async ( ) => {
114113 const sequence = 0
115114 const validity = 1000000
116115
117- const record = await ipns . create ( peerId , cid , sequence , validity )
116+ const record = await ipns . create ( peerId , contentPath , sequence , validity )
118117
119118 // remove the extra fields added for v2 sigs
120119 delete record . pb . data
@@ -130,7 +129,7 @@ describe('ipns', function () {
130129 const sequence = 0
131130 const validity = 1000000
132131
133- const record = await ipns . create ( peerId , cid , sequence , validity )
132+ const record = await ipns . create ( peerId , contentPath , sequence , validity )
134133
135134 // remove v2 sig
136135 delete record . pb . signatureV2
@@ -145,7 +144,7 @@ describe('ipns', function () {
145144 const sequence = 0
146145 const validity = 1000000
147146
148- const record = await ipns . create ( peerId , cid , sequence , validity )
147+ const record = await ipns . create ( peerId , contentPath , sequence , validity )
149148
150149 // corrupt the record by changing the value to random bytes
151150 record . pb . value = randomBytes ( 46 )
@@ -157,7 +156,7 @@ describe('ipns', function () {
157156 const sequence = 0
158157 const validity = 0.00001
159158
160- const record = await ipns . create ( peerId , cid , sequence , validity )
159+ const record = await ipns . create ( peerId , contentPath , sequence , validity )
161160
162161 await new Promise ( resolve => setTimeout ( resolve , 1 ) )
163162
@@ -168,7 +167,7 @@ describe('ipns', function () {
168167 const sequence = 0
169168 const validity = 1000000
170169
171- const createdRecord = await ipns . create ( peerId , cid , sequence , validity )
170+ const createdRecord = await ipns . create ( peerId , contentPath , sequence , validity )
172171
173172 const marshalledData = marshal ( createdRecord )
174173 const unmarshalledData = unmarshal ( marshalledData )
@@ -220,7 +219,7 @@ describe('ipns', function () {
220219 const sequence = 0
221220 const validity = 1000000
222221
223- const record = await ipns . create ( peerId , cid , sequence , validity )
222+ const record = await ipns . create ( peerId , contentPath , sequence , validity )
224223
225224 expect ( record . pb ) . to . deep . include ( {
226225 pubKey : peerId . publicKey
@@ -238,7 +237,7 @@ describe('ipns', function () {
238237 const validity = 1000000
239238
240239 const ed25519 = await createEd25519PeerId ( )
241- const record = await ipns . create ( ed25519 , cid , sequence , validity )
240+ const record = await ipns . create ( ed25519 , contentPath , sequence , validity )
242241
243242 expect ( record . pb ) . to . not . have . property ( 'pubKey' ) // ed25519 keys should not be embedded
244243 } )
@@ -247,7 +246,7 @@ describe('ipns', function () {
247246 const sequence = 0
248247 const validity = 1000000
249248
250- const record = await ipns . create ( peerId , cid , sequence , validity )
249+ const record = await ipns . create ( peerId , contentPath , sequence , validity )
251250 delete record . pb . pubKey
252251
253252 const marshalledData = marshal ( record )
@@ -260,7 +259,7 @@ describe('ipns', function () {
260259 const sequence = 0
261260 const validity = 1000000
262261
263- const record = await ipns . create ( peerId , cid , sequence , validity )
262+ const record = await ipns . create ( peerId , contentPath , sequence , validity )
264263
265264 const publicKey = await extractPublicKey ( peerId , record )
266265 expect ( publicKey ) . to . deep . include ( {
0 commit comments