mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-01-24 16:43:20 +00:00
`Message` is a very generic name and JS does not offer strong namespace boundaries. Using `WakuMessage` avoid name clashing with classes of the consumer app.
29 lines
680 B
TypeScript
29 lines
680 B
TypeScript
import fc from 'fast-check';
|
|
|
|
import { WakuMessage } from './waku_message';
|
|
|
|
describe('Waku Message', function () {
|
|
it('Waku message round trip binary serialization', function () {
|
|
fc.assert(
|
|
fc.property(fc.string(), (s) => {
|
|
const msg = WakuMessage.fromUtf8String(s);
|
|
const binary = msg.toBinary();
|
|
const actual = WakuMessage.decode(binary);
|
|
|
|
return actual.isEqualTo(msg);
|
|
})
|
|
);
|
|
});
|
|
|
|
it('Payload to utf-8', function () {
|
|
fc.assert(
|
|
fc.property(fc.string(), (s) => {
|
|
const msg = WakuMessage.fromUtf8String(s);
|
|
const utf8 = msg.utf8Payload();
|
|
|
|
return utf8 === s;
|
|
})
|
|
);
|
|
});
|
|
});
|