mirror of
https://github.com/waku-org/js-waku.git
synced 2025-01-26 20:30:07 +00:00
chore(message-hash): use timestamp
in nanoseconds instead of milliseconds (#2094)
* chore: convert timestamp from miliseconds to nanoseconds * chore: test against hash accounting for nanoseconds instead of milliseconds the hash used was calculated using timestamp in milliseconds, instead of nanoseconds (not part of the RFC test vectors)Y
This commit is contained in:
parent
33a9172bbb
commit
fea4f2577b
@ -95,7 +95,7 @@ describe("RFC Test Vectors", () => {
|
||||
|
||||
it("Waku message hash computation (message is IDecodedMessage)", () => {
|
||||
const expectedHash =
|
||||
"bd81b27902ad51f49e8f73ff8db4a96994040c9421da88b7ee8ba07bd39070b2";
|
||||
"3f11bc950dce0e3ffdcf205ae6414c01130bb5d9f20644869bff80407fa52c8f";
|
||||
const pubsubTopic = "/waku/2/default-waku/proto";
|
||||
const message: IDecodedMessage = {
|
||||
payload: new Uint8Array(),
|
||||
|
@ -40,7 +40,15 @@ function tryConvertTimestampToBytes(
|
||||
return;
|
||||
}
|
||||
|
||||
return numberToBytes(timestamp.valueOf());
|
||||
let bigIntTimestamp: bigint;
|
||||
|
||||
if (typeof timestamp === "bigint") {
|
||||
bigIntTimestamp = timestamp;
|
||||
} else {
|
||||
bigIntTimestamp = BigInt(timestamp.valueOf()) * 1000000n;
|
||||
}
|
||||
|
||||
return numberToBytes(bigIntTimestamp);
|
||||
}
|
||||
|
||||
export function messageHashStr(
|
||||
|
Loading…
x
Reference in New Issue
Block a user