@@ -9,6 +9,7 @@ import { equals } from "uint8arrays/equals";
9
9
import { ERR_INVALID_ID } from "./constants.js" ;
10
10
import { EnrCreator } from "./creator.js" ;
11
11
import { EnrDecoder } from "./decoder.js" ;
12
+ import { EnrEncoder } from "./encoder.js" ;
12
13
import { ENR } from "./enr.js" ;
13
14
import { getPrivateKeyFromPeerId } from "./peer_id.js" ;
14
15
@@ -34,7 +35,7 @@ describe("ENR", function () {
34
35
lightPush : false ,
35
36
} ;
36
37
37
- const txt = await enr . encodeTxt ( privateKey ) ;
38
+ const txt = await EnrEncoder . toString ( enr , privateKey ) ;
38
39
const enr2 = await EnrDecoder . fromString ( txt ) ;
39
40
40
41
if ( ! enr . signature ) throw "enr.signature is undefined" ;
@@ -113,7 +114,7 @@ describe("ENR", function () {
113
114
enr . setLocationMultiaddr ( multiaddr ( "/ip4/18.223.219.100/udp/9000" ) ) ;
114
115
115
116
enr . set ( "id" , new Uint8Array ( [ 0 ] ) ) ;
116
- const txt = await enr . encodeTxt ( privateKey ) ;
117
+ const txt = await EnrEncoder . toString ( enr , privateKey ) ;
117
118
118
119
await EnrDecoder . fromString ( txt ) ;
119
120
assert . fail ( "Expect error here" ) ;
@@ -199,7 +200,7 @@ describe("ENR", function () {
199
200
record = await EnrCreator . fromPublicKey ( secp . getPublicKey ( privateKey ) ) ;
200
201
record . setLocationMultiaddr ( multiaddr ( "/ip4/127.0.0.1/udp/30303" ) ) ;
201
202
record . seq = seq ;
202
- await record . encodeTxt ( privateKey ) ;
203
+ await EnrEncoder . toString ( record , privateKey ) ;
203
204
} ) ;
204
205
205
206
it ( "should properly compute the node id" , ( ) => {
@@ -209,7 +210,7 @@ describe("ENR", function () {
209
210
} ) ;
210
211
211
212
it ( "should encode/decode to RLP encoding" , async function ( ) {
212
- const encoded = await record . encode ( privateKey ) ;
213
+ const encoded = await EnrEncoder . toBytes ( record , privateKey ) ;
213
214
const decoded = await EnrDecoder . fromRLP ( encoded ) ;
214
215
215
216
record . forEach ( ( value , key ) => {
@@ -403,7 +404,7 @@ describe("ENR", function () {
403
404
it ( "should set field with all protocols disabled" , async ( ) => {
404
405
enr . waku2 = waku2Protocols ;
405
406
406
- const txt = await enr . encodeTxt ( privateKey ) ;
407
+ const txt = await EnrEncoder . toString ( enr , privateKey ) ;
407
408
const decoded = ( await EnrDecoder . fromString ( txt ) ) . waku2 ! ;
408
409
409
410
expect ( decoded . relay ) . to . equal ( false ) ;
@@ -419,7 +420,7 @@ describe("ENR", function () {
419
420
waku2Protocols . lightPush = true ;
420
421
421
422
enr . waku2 = waku2Protocols ;
422
- const txt = await enr . encodeTxt ( privateKey ) ;
423
+ const txt = await EnrEncoder . toString ( enr , privateKey ) ;
423
424
const decoded = ( await EnrDecoder . fromString ( txt ) ) . waku2 ! ;
424
425
425
426
expect ( decoded . relay ) . to . equal ( true ) ;
@@ -432,7 +433,7 @@ describe("ENR", function () {
432
433
waku2Protocols . relay = true ;
433
434
434
435
enr . waku2 = waku2Protocols ;
435
- const txt = await enr . encodeTxt ( privateKey ) ;
436
+ const txt = await EnrEncoder . toString ( enr , privateKey ) ;
436
437
const decoded = ( await EnrDecoder . fromString ( txt ) ) . waku2 ! ;
437
438
438
439
expect ( decoded . relay ) . to . equal ( true ) ;
@@ -445,7 +446,7 @@ describe("ENR", function () {
445
446
waku2Protocols . store = true ;
446
447
447
448
enr . waku2 = waku2Protocols ;
448
- const txt = await enr . encodeTxt ( privateKey ) ;
449
+ const txt = await EnrEncoder . toString ( enr , privateKey ) ;
449
450
const decoded = ( await EnrDecoder . fromString ( txt ) ) . waku2 ! ;
450
451
451
452
expect ( decoded . relay ) . to . equal ( false ) ;
@@ -458,7 +459,7 @@ describe("ENR", function () {
458
459
waku2Protocols . filter = true ;
459
460
460
461
enr . waku2 = waku2Protocols ;
461
- const txt = await enr . encodeTxt ( privateKey ) ;
462
+ const txt = await EnrEncoder . toString ( enr , privateKey ) ;
462
463
const decoded = ( await EnrDecoder . fromString ( txt ) ) . waku2 ! ;
463
464
464
465
expect ( decoded . relay ) . to . equal ( false ) ;
@@ -471,7 +472,7 @@ describe("ENR", function () {
471
472
waku2Protocols . lightPush = true ;
472
473
473
474
enr . waku2 = waku2Protocols ;
474
- const txt = await enr . encodeTxt ( privateKey ) ;
475
+ const txt = await EnrEncoder . toString ( enr , privateKey ) ;
475
476
const decoded = ( await EnrDecoder . fromString ( txt ) ) . waku2 ! ;
476
477
477
478
expect ( decoded . relay ) . to . equal ( false ) ;
0 commit comments