From b89a49d5c18b9ac41c4420a890c25decc5859e20 Mon Sep 17 00:00:00 2001 From: Gonzalo DCL Date: Fri, 17 Jan 2025 10:01:55 -0300 Subject: [PATCH] fix tests --- package-lock.json | 12 +++---- package.json | 2 +- .../@dcl/sdk/src/network/message-bus-sync.ts | 2 +- test/sdk/network/sync-engines.spec.ts | 33 +++++++++++-------- 4 files changed, 27 insertions(+), 22 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2887269dd..60516bb0c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "license": "Apache-2.0", "dependencies": { "@actions/core": "^1.10.0", - "@dcl/protocol": "https://sdk-team-cdn.decentraland.org/@dcl/protocol/branch//dcl-protocol-1.0.0-12791463180.commit-127443e.tgz", + "@dcl/protocol": "https://sdk-team-cdn.decentraland.org/@dcl/protocol/branch//dcl-protocol-1.0.0-12826974654.commit-3b9cde0.tgz", "@dcl/quickjs-emscripten": "^0.21.0-3680274614.commit-1808aa1", "@dcl/ts-proto": "1.153.0", "@types/fs-extra": "^9.0.12", @@ -577,9 +577,9 @@ } }, "node_modules/@dcl/protocol": { - "version": "1.0.0-12791463180.commit-127443e", - "resolved": "https://sdk-team-cdn.decentraland.org/@dcl/protocol/branch//dcl-protocol-1.0.0-12791463180.commit-127443e.tgz", - "integrity": "sha512-8hUkucA9k2J1vFGBQqEKn2JTSKtl0TY21tRIQ0SK64Z7amh3xLLoVHU8NJEpLTlXIjzZpkgNH4xrYm+YMUkR5w==", + "version": "1.0.0-12826974654.commit-3b9cde0", + "resolved": "https://sdk-team-cdn.decentraland.org/@dcl/protocol/branch//dcl-protocol-1.0.0-12826974654.commit-3b9cde0.tgz", + "integrity": "sha512-4ciynEufqpN9jrJjehjMrSroC2cW8S58WcRPVF7Pmkx+4helbOqVBJKh6QpfM3I11QthhTHkYRuWAzVELy3iMQ==", "license": "Apache-2.0", "dependencies": { "@dcl/ts-proto": "1.154.0" @@ -8394,8 +8394,8 @@ } }, "@dcl/protocol": { - "version": "https://sdk-team-cdn.decentraland.org/@dcl/protocol/branch//dcl-protocol-1.0.0-12791463180.commit-127443e.tgz", - "integrity": "sha512-8hUkucA9k2J1vFGBQqEKn2JTSKtl0TY21tRIQ0SK64Z7amh3xLLoVHU8NJEpLTlXIjzZpkgNH4xrYm+YMUkR5w==", + "version": "https://sdk-team-cdn.decentraland.org/@dcl/protocol/branch//dcl-protocol-1.0.0-12826974654.commit-3b9cde0.tgz", + "integrity": "sha512-4ciynEufqpN9jrJjehjMrSroC2cW8S58WcRPVF7Pmkx+4helbOqVBJKh6QpfM3I11QthhTHkYRuWAzVELy3iMQ==", "requires": { "@dcl/ts-proto": "1.154.0" }, diff --git a/package.json b/package.json index d5330e6c8..1fbfb6036 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "bugs": "https://github.com/decentraland/js-sdk-toolchain/issues", "dependencies": { "@actions/core": "^1.10.0", - "@dcl/protocol": "https://sdk-team-cdn.decentraland.org/@dcl/protocol/branch//dcl-protocol-1.0.0-12791463180.commit-127443e.tgz", + "@dcl/protocol": "https://sdk-team-cdn.decentraland.org/@dcl/protocol/branch//dcl-protocol-1.0.0-12826974654.commit-3b9cde0.tgz", "@dcl/quickjs-emscripten": "^0.21.0-3680274614.commit-1808aa1", "@dcl/ts-proto": "1.153.0", "@types/fs-extra": "^9.0.12", diff --git a/packages/@dcl/sdk/src/network/message-bus-sync.ts b/packages/@dcl/sdk/src/network/message-bus-sync.ts index 42a4c1ed9..3727ed41f 100644 --- a/packages/@dcl/sdk/src/network/message-bus-sync.ts +++ b/packages/@dcl/sdk/src/network/message-bus-sync.ts @@ -53,7 +53,7 @@ export function addSyncTransport( } const peerMessages = getMessagesToSend() - const response = await sendBinary({ data: [], peerData: peerMessages }) + const response = await sendBinary({ data: peerMessages.map(($) => $.data).flat(), peerData: peerMessages }) binaryMessageBus.__processMessages(response.data) transportInitialzed = true }, diff --git a/test/sdk/network/sync-engines.spec.ts b/test/sdk/network/sync-engines.spec.ts index 582755450..1d9c2f97f 100644 --- a/test/sdk/network/sync-engines.spec.ts +++ b/test/sdk/network/sync-engines.spec.ts @@ -18,6 +18,7 @@ import { createRendererTransport } from '../../../packages/@dcl/sdk/internal/tra import { ReadWriteByteBuffer } from '../../../packages/@dcl/ecs/src/serialization/ByteBuffer' import { readMessage } from '../../../packages/@dcl/ecs/src/serialization/crdt/message' import { EntityState, PutNetworkComponentOperation } from '../../../packages/@dcl/ecs/src' +import { SendBinaryRequest, SendBinaryResponse } from '~system/CommunicationsController' function defineComponents(engine: IEngine) { return { @@ -73,15 +74,17 @@ describe('Network Parenting', () => { const messagesA: Uint8Array[] = [] const messagesB: Uint8Array[] = [] - const sendBinaryA = async (msg: { data: Uint8Array[] }) => { - for (const value of msg.data) { - const messageType = value.subarray(0, 1)[0] - if (messageType === CommsMessage.CRDT) { - const crdtMessage = value.subarray(1) - intercept(crdtMessage, 'a->b') + const sendBinaryA: (msg: SendBinaryRequest) => Promise = async (msg) => { + for (const value of msg.peerData) { + for (const data of value.data) { + messagesB.push(data) + const messageType = data.subarray(0, 1)[0] + if (messageType === CommsMessage.CRDT) { + const crdtMessage = data.subarray(1) + intercept(crdtMessage, 'a->b') + } } } - messagesB.push(...msg.data) const messages = [...messagesA].map(($) => { const senderBytes = encodeString('B') const serializedMessage = new Uint8Array($.byteLength + senderBytes.byteLength + 1) @@ -93,16 +96,18 @@ describe('Network Parenting', () => { messagesA.length = 0 return { data: messages } } - const sendBinaryB = async (msg: { data: Uint8Array[] }) => { - for (const value of msg.data) { - const messageType = value.subarray(0, 1)[0] - if (messageType === CommsMessage.CRDT) { - const crdtMessage = value.subarray(1) - intercept(crdtMessage, 'b->a') + const sendBinaryB: (msg: SendBinaryRequest) => Promise = async (msg) => { + for (const value of msg.peerData) { + for (const data of value.data) { + messagesA.push(data) + const messageType = data.subarray(0, 1)[0] + if (messageType === CommsMessage.CRDT) { + const crdtMessage = data.subarray(1) + intercept(crdtMessage, 'b->a') + } } } - messagesA.push(...msg.data) const messages = [...messagesB].map(($) => { const senderBytes = encodeString('A') const serializedMessage = new Uint8Array($.byteLength + senderBytes.byteLength + 1)