test: deep.equal crashes when comparing Buffer and UInt8Array

This commit is contained in:
fryorcraken.eth 2022-08-24 12:46:51 +10:00
parent ebb0e786cb
commit 280058de4a
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
1 changed files with 7 additions and 2 deletions

View File

@ -1,6 +1,7 @@
import { createSecp256k1PeerId } from "@libp2p/peer-id-factory"; import { createSecp256k1PeerId } from "@libp2p/peer-id-factory";
import { Multiaddr } from "@multiformats/multiaddr"; import { Multiaddr } from "@multiformats/multiaddr";
import { assert, expect } from "chai"; import { assert, expect } from "chai";
import { equals } from "uint8arrays/equals";
import { getPublicKey } from "../crypto"; import { getPublicKey } from "../crypto";
import { bytesToHex, hexToBytes, utf8ToBytes } from "../utils"; import { bytesToHex, hexToBytes, utf8ToBytes } from "../utils";
@ -211,8 +212,12 @@ describe("ENR", function () {
}); });
it("should encode/decode to RLP encoding", async function () { it("should encode/decode to RLP encoding", async function () {
const decoded = await ENR.decode(await record.encode(privateKey)); const encoded = await record.encode(privateKey);
expect(decoded).to.deep.equal(record); const decoded = await ENR.decode(encoded);
record.forEach((value, key) => {
expect(equals(decoded.get(key)!, value)).to.be.true;
});
}); });
it("should encode/decode to text encoding", async function () { it("should encode/decode to text encoding", async function () {