2023-03-10 14:41:07 +11:00
|
|
|
import { IProtoMessage } from "@waku/interfaces";
|
feat!: Introduce routing info concept
Concepts are being mixed up between the global network config (static vs auto sharding), that needs to be the same of all nodes in the network, individual node configuration (eg relay node subscribing to a given shard), and the routing characteristic of a specific message (eg pubsub topic, shard).
This stops proper configuration of nwaku post 0.36.0 because we know need to be deliberate on whether nwaku nodes are running with auto or static sharding.
It also included various back and forth conversions between shards, pubsub topics, etc.
With this change, we tidy up the network configuration, and make it explicit whether it is static or auto sharded.
We also introduce the concept of routing info, which is specific to a message, and tied to the overall network configuration.
Routing info abstract pubsub topic, shard, and autosharding needs. Which should lead to easier tidy up of the pubsub concept at a later stage.
# Conflicts:
# packages/core/src/lib/connection_manager/connection_manager.ts
# packages/core/src/lib/metadata/metadata.ts
# packages/interfaces/src/metadata.ts
# packages/interfaces/src/sharding.ts
# packages/relay/src/create.ts
# packages/sdk/src/filter/filter.ts
# packages/sdk/src/filter/types.ts
# packages/sdk/src/light_push/light_push.spec.ts
# packages/tests/tests/sharding/auto_sharding.spec.ts
# packages/tests/tests/sharding/static_sharding.spec.ts
# Conflicts:
# packages/sdk/src/store/store.ts
2025-07-11 13:33:45 +10:00
|
|
|
import { createRoutingInfo } from "@waku/utils";
|
2022-11-23 16:59:15 +11:00
|
|
|
import { expect } from "chai";
|
|
|
|
|
import fc from "fast-check";
|
|
|
|
|
|
|
|
|
|
import { getPublicKey } from "./crypto/index.js";
|
2022-12-05 15:14:17 +11:00
|
|
|
import { createDecoder, createEncoder } from "./ecies.js";
|
2022-11-23 16:59:15 +11:00
|
|
|
|
feat!: Introduce routing info concept
Concepts are being mixed up between the global network config (static vs auto sharding), that needs to be the same of all nodes in the network, individual node configuration (eg relay node subscribing to a given shard), and the routing characteristic of a specific message (eg pubsub topic, shard).
This stops proper configuration of nwaku post 0.36.0 because we know need to be deliberate on whether nwaku nodes are running with auto or static sharding.
It also included various back and forth conversions between shards, pubsub topics, etc.
With this change, we tidy up the network configuration, and make it explicit whether it is static or auto sharded.
We also introduce the concept of routing info, which is specific to a message, and tied to the overall network configuration.
Routing info abstract pubsub topic, shard, and autosharding needs. Which should lead to easier tidy up of the pubsub concept at a later stage.
# Conflicts:
# packages/core/src/lib/connection_manager/connection_manager.ts
# packages/core/src/lib/metadata/metadata.ts
# packages/interfaces/src/metadata.ts
# packages/interfaces/src/sharding.ts
# packages/relay/src/create.ts
# packages/sdk/src/filter/filter.ts
# packages/sdk/src/filter/types.ts
# packages/sdk/src/light_push/light_push.spec.ts
# packages/tests/tests/sharding/auto_sharding.spec.ts
# packages/tests/tests/sharding/static_sharding.spec.ts
# Conflicts:
# packages/sdk/src/store/store.ts
2025-07-11 13:33:45 +10:00
|
|
|
const testContentTopic = "/js-waku/1/tests/bytes";
|
|
|
|
|
const testRoutingInfo = createRoutingInfo(
|
|
|
|
|
{
|
|
|
|
|
clusterId: 0,
|
|
|
|
|
numShardsInCluster: 14
|
|
|
|
|
},
|
|
|
|
|
{ contentTopic: testContentTopic }
|
|
|
|
|
);
|
2024-04-28 11:15:17 +02:00
|
|
|
|
2022-11-23 16:59:15 +11:00
|
|
|
describe("Ecies Encryption", function () {
|
2023-10-23 17:53:56 +03:00
|
|
|
this.timeout(20000);
|
2022-11-23 16:59:15 +11:00
|
|
|
it("Round trip binary encryption [ecies, no signature]", async function () {
|
|
|
|
|
await fc.assert(
|
|
|
|
|
fc.asyncProperty(
|
|
|
|
|
fc.uint8Array({ minLength: 1 }),
|
|
|
|
|
fc.uint8Array({ min: 1, minLength: 32, maxLength: 32 }),
|
2024-04-28 11:15:17 +02:00
|
|
|
async (payload, privateKey) => {
|
2022-11-23 16:59:15 +11:00
|
|
|
const publicKey = getPublicKey(privateKey);
|
|
|
|
|
|
2023-02-02 11:37:28 +05:30
|
|
|
const encoder = createEncoder({
|
feat!: Introduce routing info concept
Concepts are being mixed up between the global network config (static vs auto sharding), that needs to be the same of all nodes in the network, individual node configuration (eg relay node subscribing to a given shard), and the routing characteristic of a specific message (eg pubsub topic, shard).
This stops proper configuration of nwaku post 0.36.0 because we know need to be deliberate on whether nwaku nodes are running with auto or static sharding.
It also included various back and forth conversions between shards, pubsub topics, etc.
With this change, we tidy up the network configuration, and make it explicit whether it is static or auto sharded.
We also introduce the concept of routing info, which is specific to a message, and tied to the overall network configuration.
Routing info abstract pubsub topic, shard, and autosharding needs. Which should lead to easier tidy up of the pubsub concept at a later stage.
# Conflicts:
# packages/core/src/lib/connection_manager/connection_manager.ts
# packages/core/src/lib/metadata/metadata.ts
# packages/interfaces/src/metadata.ts
# packages/interfaces/src/sharding.ts
# packages/relay/src/create.ts
# packages/sdk/src/filter/filter.ts
# packages/sdk/src/filter/types.ts
# packages/sdk/src/light_push/light_push.spec.ts
# packages/tests/tests/sharding/auto_sharding.spec.ts
# packages/tests/tests/sharding/static_sharding.spec.ts
# Conflicts:
# packages/sdk/src/store/store.ts
2025-07-11 13:33:45 +10:00
|
|
|
contentTopic: testContentTopic,
|
|
|
|
|
routingInfo: testRoutingInfo,
|
2023-08-16 20:18:13 +05:30
|
|
|
publicKey
|
2023-02-02 11:37:28 +05:30
|
|
|
});
|
2022-11-23 16:59:15 +11:00
|
|
|
const bytes = await encoder.toWire({ payload });
|
|
|
|
|
|
feat!: Introduce routing info concept
Concepts are being mixed up between the global network config (static vs auto sharding), that needs to be the same of all nodes in the network, individual node configuration (eg relay node subscribing to a given shard), and the routing characteristic of a specific message (eg pubsub topic, shard).
This stops proper configuration of nwaku post 0.36.0 because we know need to be deliberate on whether nwaku nodes are running with auto or static sharding.
It also included various back and forth conversions between shards, pubsub topics, etc.
With this change, we tidy up the network configuration, and make it explicit whether it is static or auto sharded.
We also introduce the concept of routing info, which is specific to a message, and tied to the overall network configuration.
Routing info abstract pubsub topic, shard, and autosharding needs. Which should lead to easier tidy up of the pubsub concept at a later stage.
# Conflicts:
# packages/core/src/lib/connection_manager/connection_manager.ts
# packages/core/src/lib/metadata/metadata.ts
# packages/interfaces/src/metadata.ts
# packages/interfaces/src/sharding.ts
# packages/relay/src/create.ts
# packages/sdk/src/filter/filter.ts
# packages/sdk/src/filter/types.ts
# packages/sdk/src/light_push/light_push.spec.ts
# packages/tests/tests/sharding/auto_sharding.spec.ts
# packages/tests/tests/sharding/static_sharding.spec.ts
# Conflicts:
# packages/sdk/src/store/store.ts
2025-07-11 13:33:45 +10:00
|
|
|
const decoder = createDecoder(
|
|
|
|
|
testContentTopic,
|
|
|
|
|
testRoutingInfo,
|
|
|
|
|
privateKey
|
|
|
|
|
);
|
2022-11-23 16:59:15 +11:00
|
|
|
const protoResult = await decoder.fromWireToProtoObj(bytes!);
|
|
|
|
|
if (!protoResult) throw "Failed to proto decode";
|
feat!: Introduce routing info concept
Concepts are being mixed up between the global network config (static vs auto sharding), that needs to be the same of all nodes in the network, individual node configuration (eg relay node subscribing to a given shard), and the routing characteristic of a specific message (eg pubsub topic, shard).
This stops proper configuration of nwaku post 0.36.0 because we know need to be deliberate on whether nwaku nodes are running with auto or static sharding.
It also included various back and forth conversions between shards, pubsub topics, etc.
With this change, we tidy up the network configuration, and make it explicit whether it is static or auto sharded.
We also introduce the concept of routing info, which is specific to a message, and tied to the overall network configuration.
Routing info abstract pubsub topic, shard, and autosharding needs. Which should lead to easier tidy up of the pubsub concept at a later stage.
# Conflicts:
# packages/core/src/lib/connection_manager/connection_manager.ts
# packages/core/src/lib/metadata/metadata.ts
# packages/interfaces/src/metadata.ts
# packages/interfaces/src/sharding.ts
# packages/relay/src/create.ts
# packages/sdk/src/filter/filter.ts
# packages/sdk/src/filter/types.ts
# packages/sdk/src/light_push/light_push.spec.ts
# packages/tests/tests/sharding/auto_sharding.spec.ts
# packages/tests/tests/sharding/static_sharding.spec.ts
# Conflicts:
# packages/sdk/src/store/store.ts
2025-07-11 13:33:45 +10:00
|
|
|
const result = await decoder.fromProtoObj(
|
|
|
|
|
testRoutingInfo.pubsubTopic,
|
|
|
|
|
protoResult
|
|
|
|
|
);
|
2022-11-23 16:59:15 +11:00
|
|
|
if (!result) throw "Failed to decode";
|
|
|
|
|
|
feat!: Introduce routing info concept
Concepts are being mixed up between the global network config (static vs auto sharding), that needs to be the same of all nodes in the network, individual node configuration (eg relay node subscribing to a given shard), and the routing characteristic of a specific message (eg pubsub topic, shard).
This stops proper configuration of nwaku post 0.36.0 because we know need to be deliberate on whether nwaku nodes are running with auto or static sharding.
It also included various back and forth conversions between shards, pubsub topics, etc.
With this change, we tidy up the network configuration, and make it explicit whether it is static or auto sharded.
We also introduce the concept of routing info, which is specific to a message, and tied to the overall network configuration.
Routing info abstract pubsub topic, shard, and autosharding needs. Which should lead to easier tidy up of the pubsub concept at a later stage.
# Conflicts:
# packages/core/src/lib/connection_manager/connection_manager.ts
# packages/core/src/lib/metadata/metadata.ts
# packages/interfaces/src/metadata.ts
# packages/interfaces/src/sharding.ts
# packages/relay/src/create.ts
# packages/sdk/src/filter/filter.ts
# packages/sdk/src/filter/types.ts
# packages/sdk/src/light_push/light_push.spec.ts
# packages/tests/tests/sharding/auto_sharding.spec.ts
# packages/tests/tests/sharding/static_sharding.spec.ts
# Conflicts:
# packages/sdk/src/store/store.ts
2025-07-11 13:33:45 +10:00
|
|
|
expect(result.contentTopic).to.equal(testContentTopic);
|
|
|
|
|
expect(result.pubsubTopic).to.equal(testRoutingInfo.pubsubTopic);
|
2022-11-23 16:59:15 +11:00
|
|
|
expect(result.version).to.equal(1);
|
|
|
|
|
expect(result?.payload).to.deep.equal(payload);
|
|
|
|
|
expect(result.signature).to.be.undefined;
|
2023-12-08 21:52:16 +11:00
|
|
|
expect(result.verifySignature(new Uint8Array())).to.be.false;
|
2022-11-23 16:59:15 +11:00
|
|
|
expect(result.signaturePublicKey).to.be.undefined;
|
2023-08-16 20:18:13 +05:30
|
|
|
}
|
|
|
|
|
)
|
2022-11-23 16:59:15 +11:00
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
2023-12-12 11:47:34 +11:00
|
|
|
it("Round trip binary encryption [ecies, signature]", async function () {
|
|
|
|
|
this.timeout(6000);
|
2022-11-23 16:59:15 +11:00
|
|
|
|
|
|
|
|
await fc.assert(
|
|
|
|
|
fc.asyncProperty(
|
|
|
|
|
fc.uint8Array({ minLength: 1 }),
|
|
|
|
|
fc.uint8Array({ min: 1, minLength: 32, maxLength: 32 }),
|
|
|
|
|
fc.uint8Array({ min: 1, minLength: 32, maxLength: 32 }),
|
2024-04-28 11:15:17 +02:00
|
|
|
async (payload, alicePrivateKey, bobPrivateKey) => {
|
2022-11-23 16:59:15 +11:00
|
|
|
const alicePublicKey = getPublicKey(alicePrivateKey);
|
|
|
|
|
const bobPublicKey = getPublicKey(bobPrivateKey);
|
|
|
|
|
|
2023-02-02 11:37:28 +05:30
|
|
|
const encoder = createEncoder({
|
feat!: Introduce routing info concept
Concepts are being mixed up between the global network config (static vs auto sharding), that needs to be the same of all nodes in the network, individual node configuration (eg relay node subscribing to a given shard), and the routing characteristic of a specific message (eg pubsub topic, shard).
This stops proper configuration of nwaku post 0.36.0 because we know need to be deliberate on whether nwaku nodes are running with auto or static sharding.
It also included various back and forth conversions between shards, pubsub topics, etc.
With this change, we tidy up the network configuration, and make it explicit whether it is static or auto sharded.
We also introduce the concept of routing info, which is specific to a message, and tied to the overall network configuration.
Routing info abstract pubsub topic, shard, and autosharding needs. Which should lead to easier tidy up of the pubsub concept at a later stage.
# Conflicts:
# packages/core/src/lib/connection_manager/connection_manager.ts
# packages/core/src/lib/metadata/metadata.ts
# packages/interfaces/src/metadata.ts
# packages/interfaces/src/sharding.ts
# packages/relay/src/create.ts
# packages/sdk/src/filter/filter.ts
# packages/sdk/src/filter/types.ts
# packages/sdk/src/light_push/light_push.spec.ts
# packages/tests/tests/sharding/auto_sharding.spec.ts
# packages/tests/tests/sharding/static_sharding.spec.ts
# Conflicts:
# packages/sdk/src/store/store.ts
2025-07-11 13:33:45 +10:00
|
|
|
contentTopic: testContentTopic,
|
|
|
|
|
routingInfo: testRoutingInfo,
|
2023-02-02 11:37:28 +05:30
|
|
|
publicKey: bobPublicKey,
|
2023-08-16 20:18:13 +05:30
|
|
|
sigPrivKey: alicePrivateKey
|
2023-02-02 11:37:28 +05:30
|
|
|
});
|
2022-11-23 16:59:15 +11:00
|
|
|
const bytes = await encoder.toWire({ payload });
|
|
|
|
|
|
feat!: Introduce routing info concept
Concepts are being mixed up between the global network config (static vs auto sharding), that needs to be the same of all nodes in the network, individual node configuration (eg relay node subscribing to a given shard), and the routing characteristic of a specific message (eg pubsub topic, shard).
This stops proper configuration of nwaku post 0.36.0 because we know need to be deliberate on whether nwaku nodes are running with auto or static sharding.
It also included various back and forth conversions between shards, pubsub topics, etc.
With this change, we tidy up the network configuration, and make it explicit whether it is static or auto sharded.
We also introduce the concept of routing info, which is specific to a message, and tied to the overall network configuration.
Routing info abstract pubsub topic, shard, and autosharding needs. Which should lead to easier tidy up of the pubsub concept at a later stage.
# Conflicts:
# packages/core/src/lib/connection_manager/connection_manager.ts
# packages/core/src/lib/metadata/metadata.ts
# packages/interfaces/src/metadata.ts
# packages/interfaces/src/sharding.ts
# packages/relay/src/create.ts
# packages/sdk/src/filter/filter.ts
# packages/sdk/src/filter/types.ts
# packages/sdk/src/light_push/light_push.spec.ts
# packages/tests/tests/sharding/auto_sharding.spec.ts
# packages/tests/tests/sharding/static_sharding.spec.ts
# Conflicts:
# packages/sdk/src/store/store.ts
2025-07-11 13:33:45 +10:00
|
|
|
const decoder = createDecoder(
|
|
|
|
|
testContentTopic,
|
|
|
|
|
testRoutingInfo,
|
|
|
|
|
bobPrivateKey
|
|
|
|
|
);
|
2022-11-23 16:59:15 +11:00
|
|
|
const protoResult = await decoder.fromWireToProtoObj(bytes!);
|
|
|
|
|
if (!protoResult) throw "Failed to proto decode";
|
feat!: Introduce routing info concept
Concepts are being mixed up between the global network config (static vs auto sharding), that needs to be the same of all nodes in the network, individual node configuration (eg relay node subscribing to a given shard), and the routing characteristic of a specific message (eg pubsub topic, shard).
This stops proper configuration of nwaku post 0.36.0 because we know need to be deliberate on whether nwaku nodes are running with auto or static sharding.
It also included various back and forth conversions between shards, pubsub topics, etc.
With this change, we tidy up the network configuration, and make it explicit whether it is static or auto sharded.
We also introduce the concept of routing info, which is specific to a message, and tied to the overall network configuration.
Routing info abstract pubsub topic, shard, and autosharding needs. Which should lead to easier tidy up of the pubsub concept at a later stage.
# Conflicts:
# packages/core/src/lib/connection_manager/connection_manager.ts
# packages/core/src/lib/metadata/metadata.ts
# packages/interfaces/src/metadata.ts
# packages/interfaces/src/sharding.ts
# packages/relay/src/create.ts
# packages/sdk/src/filter/filter.ts
# packages/sdk/src/filter/types.ts
# packages/sdk/src/light_push/light_push.spec.ts
# packages/tests/tests/sharding/auto_sharding.spec.ts
# packages/tests/tests/sharding/static_sharding.spec.ts
# Conflicts:
# packages/sdk/src/store/store.ts
2025-07-11 13:33:45 +10:00
|
|
|
const result = await decoder.fromProtoObj(
|
|
|
|
|
testRoutingInfo.pubsubTopic,
|
|
|
|
|
protoResult
|
|
|
|
|
);
|
2022-11-23 16:59:15 +11:00
|
|
|
if (!result) throw "Failed to decode";
|
|
|
|
|
|
feat!: Introduce routing info concept
Concepts are being mixed up between the global network config (static vs auto sharding), that needs to be the same of all nodes in the network, individual node configuration (eg relay node subscribing to a given shard), and the routing characteristic of a specific message (eg pubsub topic, shard).
This stops proper configuration of nwaku post 0.36.0 because we know need to be deliberate on whether nwaku nodes are running with auto or static sharding.
It also included various back and forth conversions between shards, pubsub topics, etc.
With this change, we tidy up the network configuration, and make it explicit whether it is static or auto sharded.
We also introduce the concept of routing info, which is specific to a message, and tied to the overall network configuration.
Routing info abstract pubsub topic, shard, and autosharding needs. Which should lead to easier tidy up of the pubsub concept at a later stage.
# Conflicts:
# packages/core/src/lib/connection_manager/connection_manager.ts
# packages/core/src/lib/metadata/metadata.ts
# packages/interfaces/src/metadata.ts
# packages/interfaces/src/sharding.ts
# packages/relay/src/create.ts
# packages/sdk/src/filter/filter.ts
# packages/sdk/src/filter/types.ts
# packages/sdk/src/light_push/light_push.spec.ts
# packages/tests/tests/sharding/auto_sharding.spec.ts
# packages/tests/tests/sharding/static_sharding.spec.ts
# Conflicts:
# packages/sdk/src/store/store.ts
2025-07-11 13:33:45 +10:00
|
|
|
expect(result.contentTopic).to.equal(testContentTopic);
|
|
|
|
|
expect(result.pubsubTopic).to.equal(testRoutingInfo.pubsubTopic);
|
2022-11-23 16:59:15 +11:00
|
|
|
expect(result.version).to.equal(1);
|
|
|
|
|
expect(result?.payload).to.deep.equal(payload);
|
|
|
|
|
expect(result.signature).to.not.be.undefined;
|
2023-12-08 21:52:16 +11:00
|
|
|
expect(result.verifySignature(alicePublicKey)).to.be.true;
|
2022-11-23 16:59:15 +11:00
|
|
|
expect(result.signaturePublicKey).to.deep.eq(alicePublicKey);
|
2023-08-16 20:18:13 +05:30
|
|
|
}
|
|
|
|
|
)
|
2022-11-23 16:59:15 +11:00
|
|
|
);
|
|
|
|
|
});
|
2023-03-10 14:41:07 +11:00
|
|
|
|
|
|
|
|
it("Check meta is set [ecies]", async function () {
|
|
|
|
|
await fc.assert(
|
|
|
|
|
fc.asyncProperty(
|
|
|
|
|
fc.uint8Array({ minLength: 1 }),
|
|
|
|
|
fc.uint8Array({ min: 1, minLength: 32, maxLength: 32 }),
|
2024-04-28 11:15:17 +02:00
|
|
|
async (payload, privateKey) => {
|
2023-03-10 14:41:07 +11:00
|
|
|
const publicKey = getPublicKey(privateKey);
|
|
|
|
|
const metaSetter = (
|
2023-08-16 20:18:13 +05:30
|
|
|
msg: IProtoMessage & { meta: undefined }
|
2023-03-10 14:41:07 +11:00
|
|
|
): Uint8Array => {
|
|
|
|
|
const buffer = new ArrayBuffer(4);
|
|
|
|
|
const view = new DataView(buffer);
|
|
|
|
|
view.setUint32(0, msg.payload.length, false);
|
|
|
|
|
return new Uint8Array(buffer);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const encoder = createEncoder({
|
feat!: Introduce routing info concept
Concepts are being mixed up between the global network config (static vs auto sharding), that needs to be the same of all nodes in the network, individual node configuration (eg relay node subscribing to a given shard), and the routing characteristic of a specific message (eg pubsub topic, shard).
This stops proper configuration of nwaku post 0.36.0 because we know need to be deliberate on whether nwaku nodes are running with auto or static sharding.
It also included various back and forth conversions between shards, pubsub topics, etc.
With this change, we tidy up the network configuration, and make it explicit whether it is static or auto sharded.
We also introduce the concept of routing info, which is specific to a message, and tied to the overall network configuration.
Routing info abstract pubsub topic, shard, and autosharding needs. Which should lead to easier tidy up of the pubsub concept at a later stage.
# Conflicts:
# packages/core/src/lib/connection_manager/connection_manager.ts
# packages/core/src/lib/metadata/metadata.ts
# packages/interfaces/src/metadata.ts
# packages/interfaces/src/sharding.ts
# packages/relay/src/create.ts
# packages/sdk/src/filter/filter.ts
# packages/sdk/src/filter/types.ts
# packages/sdk/src/light_push/light_push.spec.ts
# packages/tests/tests/sharding/auto_sharding.spec.ts
# packages/tests/tests/sharding/static_sharding.spec.ts
# Conflicts:
# packages/sdk/src/store/store.ts
2025-07-11 13:33:45 +10:00
|
|
|
contentTopic: testContentTopic,
|
|
|
|
|
routingInfo: testRoutingInfo,
|
2023-03-10 14:41:07 +11:00
|
|
|
publicKey,
|
2023-08-16 20:18:13 +05:30
|
|
|
metaSetter
|
2023-03-10 14:41:07 +11:00
|
|
|
});
|
|
|
|
|
const bytes = await encoder.toWire({ payload });
|
|
|
|
|
|
feat!: Introduce routing info concept
Concepts are being mixed up between the global network config (static vs auto sharding), that needs to be the same of all nodes in the network, individual node configuration (eg relay node subscribing to a given shard), and the routing characteristic of a specific message (eg pubsub topic, shard).
This stops proper configuration of nwaku post 0.36.0 because we know need to be deliberate on whether nwaku nodes are running with auto or static sharding.
It also included various back and forth conversions between shards, pubsub topics, etc.
With this change, we tidy up the network configuration, and make it explicit whether it is static or auto sharded.
We also introduce the concept of routing info, which is specific to a message, and tied to the overall network configuration.
Routing info abstract pubsub topic, shard, and autosharding needs. Which should lead to easier tidy up of the pubsub concept at a later stage.
# Conflicts:
# packages/core/src/lib/connection_manager/connection_manager.ts
# packages/core/src/lib/metadata/metadata.ts
# packages/interfaces/src/metadata.ts
# packages/interfaces/src/sharding.ts
# packages/relay/src/create.ts
# packages/sdk/src/filter/filter.ts
# packages/sdk/src/filter/types.ts
# packages/sdk/src/light_push/light_push.spec.ts
# packages/tests/tests/sharding/auto_sharding.spec.ts
# packages/tests/tests/sharding/static_sharding.spec.ts
# Conflicts:
# packages/sdk/src/store/store.ts
2025-07-11 13:33:45 +10:00
|
|
|
const decoder = createDecoder(
|
|
|
|
|
testContentTopic,
|
|
|
|
|
testRoutingInfo,
|
|
|
|
|
privateKey
|
|
|
|
|
);
|
2023-03-10 14:41:07 +11:00
|
|
|
const protoResult = await decoder.fromWireToProtoObj(bytes!);
|
|
|
|
|
if (!protoResult) throw "Failed to proto decode";
|
feat!: Introduce routing info concept
Concepts are being mixed up between the global network config (static vs auto sharding), that needs to be the same of all nodes in the network, individual node configuration (eg relay node subscribing to a given shard), and the routing characteristic of a specific message (eg pubsub topic, shard).
This stops proper configuration of nwaku post 0.36.0 because we know need to be deliberate on whether nwaku nodes are running with auto or static sharding.
It also included various back and forth conversions between shards, pubsub topics, etc.
With this change, we tidy up the network configuration, and make it explicit whether it is static or auto sharded.
We also introduce the concept of routing info, which is specific to a message, and tied to the overall network configuration.
Routing info abstract pubsub topic, shard, and autosharding needs. Which should lead to easier tidy up of the pubsub concept at a later stage.
# Conflicts:
# packages/core/src/lib/connection_manager/connection_manager.ts
# packages/core/src/lib/metadata/metadata.ts
# packages/interfaces/src/metadata.ts
# packages/interfaces/src/sharding.ts
# packages/relay/src/create.ts
# packages/sdk/src/filter/filter.ts
# packages/sdk/src/filter/types.ts
# packages/sdk/src/light_push/light_push.spec.ts
# packages/tests/tests/sharding/auto_sharding.spec.ts
# packages/tests/tests/sharding/static_sharding.spec.ts
# Conflicts:
# packages/sdk/src/store/store.ts
2025-07-11 13:33:45 +10:00
|
|
|
const result = await decoder.fromProtoObj(
|
|
|
|
|
testRoutingInfo.pubsubTopic,
|
|
|
|
|
protoResult
|
|
|
|
|
);
|
2023-03-10 14:41:07 +11:00
|
|
|
if (!result) throw "Failed to decode";
|
|
|
|
|
|
|
|
|
|
const expectedMeta = metaSetter({
|
|
|
|
|
payload: protoResult.payload,
|
|
|
|
|
timestamp: undefined,
|
|
|
|
|
contentTopic: "",
|
|
|
|
|
ephemeral: undefined,
|
|
|
|
|
meta: undefined,
|
|
|
|
|
rateLimitProof: undefined,
|
2023-08-16 20:18:13 +05:30
|
|
|
version: undefined
|
2023-03-10 14:41:07 +11:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
expect(result.meta).to.deep.equal(expectedMeta);
|
2023-08-16 20:18:13 +05:30
|
|
|
}
|
|
|
|
|
)
|
2023-03-10 14:41:07 +11:00
|
|
|
);
|
|
|
|
|
});
|
2022-11-23 16:59:15 +11:00
|
|
|
});
|
2023-04-03 20:15:31 +10:00
|
|
|
|
|
|
|
|
describe("Ensures content topic is defined", () => {
|
|
|
|
|
it("Encoder throws on undefined content topic", () => {
|
|
|
|
|
const wrapper = function (): void {
|
|
|
|
|
createEncoder({
|
|
|
|
|
contentTopic: undefined as unknown as string,
|
feat!: Introduce routing info concept
Concepts are being mixed up between the global network config (static vs auto sharding), that needs to be the same of all nodes in the network, individual node configuration (eg relay node subscribing to a given shard), and the routing characteristic of a specific message (eg pubsub topic, shard).
This stops proper configuration of nwaku post 0.36.0 because we know need to be deliberate on whether nwaku nodes are running with auto or static sharding.
It also included various back and forth conversions between shards, pubsub topics, etc.
With this change, we tidy up the network configuration, and make it explicit whether it is static or auto sharded.
We also introduce the concept of routing info, which is specific to a message, and tied to the overall network configuration.
Routing info abstract pubsub topic, shard, and autosharding needs. Which should lead to easier tidy up of the pubsub concept at a later stage.
# Conflicts:
# packages/core/src/lib/connection_manager/connection_manager.ts
# packages/core/src/lib/metadata/metadata.ts
# packages/interfaces/src/metadata.ts
# packages/interfaces/src/sharding.ts
# packages/relay/src/create.ts
# packages/sdk/src/filter/filter.ts
# packages/sdk/src/filter/types.ts
# packages/sdk/src/light_push/light_push.spec.ts
# packages/tests/tests/sharding/auto_sharding.spec.ts
# packages/tests/tests/sharding/static_sharding.spec.ts
# Conflicts:
# packages/sdk/src/store/store.ts
2025-07-11 13:33:45 +10:00
|
|
|
routingInfo: testRoutingInfo,
|
2023-08-16 20:18:13 +05:30
|
|
|
publicKey: new Uint8Array()
|
2023-04-03 20:15:31 +10:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
expect(wrapper).to.throw("Content topic must be specified");
|
|
|
|
|
});
|
|
|
|
|
it("Encoder throws on empty string content topic", () => {
|
|
|
|
|
const wrapper = function (): void {
|
feat!: Introduce routing info concept
Concepts are being mixed up between the global network config (static vs auto sharding), that needs to be the same of all nodes in the network, individual node configuration (eg relay node subscribing to a given shard), and the routing characteristic of a specific message (eg pubsub topic, shard).
This stops proper configuration of nwaku post 0.36.0 because we know need to be deliberate on whether nwaku nodes are running with auto or static sharding.
It also included various back and forth conversions between shards, pubsub topics, etc.
With this change, we tidy up the network configuration, and make it explicit whether it is static or auto sharded.
We also introduce the concept of routing info, which is specific to a message, and tied to the overall network configuration.
Routing info abstract pubsub topic, shard, and autosharding needs. Which should lead to easier tidy up of the pubsub concept at a later stage.
# Conflicts:
# packages/core/src/lib/connection_manager/connection_manager.ts
# packages/core/src/lib/metadata/metadata.ts
# packages/interfaces/src/metadata.ts
# packages/interfaces/src/sharding.ts
# packages/relay/src/create.ts
# packages/sdk/src/filter/filter.ts
# packages/sdk/src/filter/types.ts
# packages/sdk/src/light_push/light_push.spec.ts
# packages/tests/tests/sharding/auto_sharding.spec.ts
# packages/tests/tests/sharding/static_sharding.spec.ts
# Conflicts:
# packages/sdk/src/store/store.ts
2025-07-11 13:33:45 +10:00
|
|
|
createEncoder({
|
|
|
|
|
contentTopic: "",
|
|
|
|
|
routingInfo: testRoutingInfo,
|
|
|
|
|
publicKey: new Uint8Array()
|
|
|
|
|
});
|
2023-04-03 20:15:31 +10:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
expect(wrapper).to.throw("Content topic must be specified");
|
|
|
|
|
});
|
|
|
|
|
it("Decoder throws on undefined content topic", () => {
|
|
|
|
|
const wrapper = function (): void {
|
feat!: Introduce routing info concept
Concepts are being mixed up between the global network config (static vs auto sharding), that needs to be the same of all nodes in the network, individual node configuration (eg relay node subscribing to a given shard), and the routing characteristic of a specific message (eg pubsub topic, shard).
This stops proper configuration of nwaku post 0.36.0 because we know need to be deliberate on whether nwaku nodes are running with auto or static sharding.
It also included various back and forth conversions between shards, pubsub topics, etc.
With this change, we tidy up the network configuration, and make it explicit whether it is static or auto sharded.
We also introduce the concept of routing info, which is specific to a message, and tied to the overall network configuration.
Routing info abstract pubsub topic, shard, and autosharding needs. Which should lead to easier tidy up of the pubsub concept at a later stage.
# Conflicts:
# packages/core/src/lib/connection_manager/connection_manager.ts
# packages/core/src/lib/metadata/metadata.ts
# packages/interfaces/src/metadata.ts
# packages/interfaces/src/sharding.ts
# packages/relay/src/create.ts
# packages/sdk/src/filter/filter.ts
# packages/sdk/src/filter/types.ts
# packages/sdk/src/light_push/light_push.spec.ts
# packages/tests/tests/sharding/auto_sharding.spec.ts
# packages/tests/tests/sharding/static_sharding.spec.ts
# Conflicts:
# packages/sdk/src/store/store.ts
2025-07-11 13:33:45 +10:00
|
|
|
createDecoder(
|
|
|
|
|
undefined as unknown as string,
|
|
|
|
|
testRoutingInfo,
|
|
|
|
|
new Uint8Array()
|
|
|
|
|
);
|
2023-04-03 20:15:31 +10:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
expect(wrapper).to.throw("Content topic must be specified");
|
|
|
|
|
});
|
|
|
|
|
it("Decoder throws on empty string content topic", () => {
|
|
|
|
|
const wrapper = function (): void {
|
feat!: Introduce routing info concept
Concepts are being mixed up between the global network config (static vs auto sharding), that needs to be the same of all nodes in the network, individual node configuration (eg relay node subscribing to a given shard), and the routing characteristic of a specific message (eg pubsub topic, shard).
This stops proper configuration of nwaku post 0.36.0 because we know need to be deliberate on whether nwaku nodes are running with auto or static sharding.
It also included various back and forth conversions between shards, pubsub topics, etc.
With this change, we tidy up the network configuration, and make it explicit whether it is static or auto sharded.
We also introduce the concept of routing info, which is specific to a message, and tied to the overall network configuration.
Routing info abstract pubsub topic, shard, and autosharding needs. Which should lead to easier tidy up of the pubsub concept at a later stage.
# Conflicts:
# packages/core/src/lib/connection_manager/connection_manager.ts
# packages/core/src/lib/metadata/metadata.ts
# packages/interfaces/src/metadata.ts
# packages/interfaces/src/sharding.ts
# packages/relay/src/create.ts
# packages/sdk/src/filter/filter.ts
# packages/sdk/src/filter/types.ts
# packages/sdk/src/light_push/light_push.spec.ts
# packages/tests/tests/sharding/auto_sharding.spec.ts
# packages/tests/tests/sharding/static_sharding.spec.ts
# Conflicts:
# packages/sdk/src/store/store.ts
2025-07-11 13:33:45 +10:00
|
|
|
createDecoder("", testRoutingInfo, new Uint8Array());
|
2023-04-03 20:15:31 +10:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
expect(wrapper).to.throw("Content topic must be specified");
|
|
|
|
|
});
|
|
|
|
|
});
|