Add failing tests for newly discovered bug

This commit is contained in:
Tracy Rust 2024-04-01 23:28:00 -04:00
parent 5f6acc8837
commit 1aedcd5ac4
1 changed files with 84 additions and 1 deletions

View File

@ -569,3 +569,86 @@ test("Record digestion is order independent", () => {
}); });
*/ */
describe("records anchored to each other and future timestamp resolves", () => {
let prop;
let reca;
let recb;
beforeEach(() => {
prop = constructActiveProperty("machine1", "bananas");
//So the hallmark here is that they both are aware of each other... Which shouldn't be possible
// and a brief look above I didn't see a case testing it (but it's late and I'm tired so maybe I missed it)
// either way this got through and caused an inconsistent sync in Binder so I'm enshrining it.
reca = createRecord(prop, "delete", null);
reca.timestamp = 1;
reca.machineId = "a";
reca.machineIndex = 1;
reca.anchors = {"b": 1};
recb = createRecord(prop, "write", true);
recb.timestamp = 2; //still fails if same...
recb.machineId = "b";
recb.machineIndex = 1;
recb.anchors = {"a": 1};
});
test("B before A, and the property is alive", () => {
digestRecordIntoProperty(prop, recb);
digestRecordIntoProperty(prop, reca);
expect(readPropertyValue(prop)).toBe(true);
});
test("A before B, and the property is alive", () => {
digestRecordIntoProperty(prop, reca);
digestRecordIntoProperty(prop, recb);
expect(readPropertyValue(prop)).toBe(true);
});
});
describe("records anchored to each other, same timestamps", () => {
let prop;
let reca;
let recb;
beforeEach(() => {
prop = constructActiveProperty("machine1", "bananas");
//So the hallmark here is that they both are aware of each other... Which shouldn't be possible
// and a brief look above I didn't see a case testing it (but it's late and I'm tired so maybe I missed it)
// either way this got through and caused an inconsistent sync in Binder so I'm enshrining it.
reca = createRecord(prop, "delete", null);
reca.timestamp = 1;
reca.machineId = "a";
reca.machineIndex = 1;
reca.anchors = {"b": 1};
recb = createRecord(prop, "write", true);
recb.timestamp = 1;
recb.machineId = "b";
recb.machineIndex = 1;
recb.anchors = {"a": 1};
});
//Write takes precedence over delete when all else is in conflict.
test("B before A, and the property is alive", () => {
digestRecordIntoProperty(prop, recb);
digestRecordIntoProperty(prop, reca);
expect(readPropertyValue(prop)).toBe(true);
});
test("A before B, and the property is alive", () => {
digestRecordIntoProperty(prop, reca);
digestRecordIntoProperty(prop, recb);
expect(readPropertyValue(prop)).toBe(true);
});
});