Skip to content

port MsgBlockParser from TypeScript to Kotlinpgp message block parser  #1052

@tomholub

Description

@tomholub

As a part of #1051 we'll need to port the following https://github.com/FlowCrypt/flowcrypt-browser/blob/master/extension/js/common/core/msg-block-parser.ts but only method detectBlocks with its private counterpart detectBlockNext. I recommend to port it line-by-line so that we can easily reason about it - the original parser is well battle tested.

The Android codebase already has a class similar to TypeScript's MsgBlock here https://github.com/FlowCrypt/flowcrypt-browser/blob/master/extension/js/common/core/msg-block.ts - @DenBond7 can you please point us to where is the Android/Kotlin equivalent defined?

For the implementation I'd recommend to do it in this order:

  1. open the typescript codebase in vscode to better understand it
  2. from https://github.com/FlowCrypt/flowcrypt-browser/blob/master/test/source/tests/unit-node.ts copy first 3 tests that start with [unit][MsgBlockParser.detectBlocks] into kotlin
  3. copy the algorithm and translate into Kotlin line by line
  4. most test cases are unfortunately, in browser-extension, run as integration tests. I recommend to find a way to run all tests and export the results into a file, to work as data for unit tests in Kotlin. I'm not entirely sure what the right way to do this is, since the test runner is in NodeJS but the tested code itself runs in puppeteer. When unsure, ask @rrrooommmaaa for help
  5. once exported data for unit tests, write appropriate Kotlin unit tests and fix implementation if necessary

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions