Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-3396

BSON corpus tests don't check relaxed EJSON correctly

      Use Case

      As a node driver user
      I want better assertions from the BSON corpus testing
      So that I have confidence in EJSON serialization

      Currently EJSON relaxed is checked by taking the JS object deserialized from the hex with promote settings disabled. I believe its the promote settings that are making the tests miss a case described in NODE-3390.

      if (v.relaxed_extjson) {
         let rEJ = normalize(v.relaxed_extjson);
         // BSON -> native -> relaxed EJSON matches provided
         expect(nativeToREJSON(nativeFromCB)).to.equal(rEJ);
      
         // relaxed EJSON -> native -> relaxed EJSON unchanged
         expect(nativeToREJSON(jsonToNative(rEJ))).to.equal(rEJ);
       }
      

      Edit Feb 10th 2022:
      jsonToNative parses the extended JSON string with our extended JSON parser in canonical form. Instead we should directly test how the extended json serializer (EJSON.stringify) returns when relaxed: false when taking an input that was parsed with plain JSON.stringify.

      Dependencies

      • None

      Unknowns

      • How much effort it is to test relaxed JSON correctly, normalizing the stringified JSON can be tricky

      Acceptance Criteria

      • Check the Double Inf/NaN test is correctly asserting the results.
      Implementation Requirements
      • Unwrap nested serialization functions into separate assertions.
      Testing Requirements
      • n/a testing ticket
      Documentation Requirements
      • None
      Follow Up Requirements
      • None

            Assignee:
            Unassigned Unassigned
            Reporter:
            neal.beeken@mongodb.com Neal Beeken
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: