fixed some issues in random tests
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
import { getStruct } from 'y-protocols/sync.js'
|
||||
import * as decoding from 'funlib/decoding.js'
|
||||
import { GC } from '../structs/GC.js'
|
||||
import { Delete } from '../structs/Delete.js'
|
||||
import { Y } from '../utils/Y.js' // eslint-disable-line
|
||||
import { Item } from '../structs/Item.js' // eslint-disable-line
|
||||
|
||||
@@ -56,6 +57,9 @@ function _integrateRemoteStructHelper (y, struct) {
|
||||
decoder.pos = oldPos
|
||||
if (missing.length === 0) {
|
||||
y._readyToIntegrate.push(missingDef.struct)
|
||||
// TODO: sorting should be optimized
|
||||
// Sorting because deletes may change the origin of ops
|
||||
y._readyToIntegrate.sort((a, b) => a.constructor === b.constructor ? 0 : (a.constructor === Delete ? 1 : -1))
|
||||
} else {
|
||||
// TODO: throw error here
|
||||
}
|
||||
@@ -84,6 +88,7 @@ export const integrateRemoteStructs = (decoder, y) => {
|
||||
let decoderPos = decoder.pos
|
||||
let missing = struct._fromBinary(y, decoder)
|
||||
if (missing.length === 0) {
|
||||
y._readyToIntegrate.sort((a, b) => a.constructor === b.constructor ? 0 : (a.constructor === Delete ? 1 : -1))
|
||||
while (struct != null) {
|
||||
_integrateRemoteStructHelper(y, struct)
|
||||
struct = y._readyToIntegrate.shift()
|
||||
@@ -121,6 +126,7 @@ export const integrateRemoteStruct = (decoder, y) => {
|
||||
let decoderPos = decoder.pos
|
||||
let missing = struct._fromBinary(y, decoder)
|
||||
if (missing.length === 0) {
|
||||
y._readyToIntegrate.sort((a, b) => a.constructor === b.constructor ? 0 : (a.constructor === Delete ? 1 : -1))
|
||||
while (struct != null) {
|
||||
_integrateRemoteStructHelper(y, struct)
|
||||
struct = y._readyToIntegrate.shift()
|
||||
|
||||
Reference in New Issue
Block a user