Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gonpombo8 committed Jan 17, 2025
1 parent fa2b830 commit b89a49d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 22 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/@dcl/sdk/src/network/message-bus-sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down
33 changes: 19 additions & 14 deletions test/sdk/network/sync-engines.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<SendBinaryResponse> = 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)
Expand All @@ -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<SendBinaryResponse> = 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)
Expand Down

0 comments on commit b89a49d

Please sign in to comment.