KomodoPlatform / komodo-defi-framework

This is the official Komodo DeFi Framework repository
https://komodoplatform.com/en/docs/komodo-defi-framework/
102 stars 94 forks source link

WASM tests do not catch the logs written by info!/warn!/... #1634

Open artemii235 opened 1 year ago

artemii235 commented 1 year ago

For example, I had to use log_tag! instead of info! here: https://github.com/KomodoPlatform/atomicDEX-API/commit/a53daabed076a0481f5bc18858b9239d3ccd3919#diff-608240539630bec8eb43b211b0b74ec3580b34dda66e339bac21c04b1db6da43R272-R277.

@sergeyboyko0791 Could you please tell if we can catch info!/... output in WASM tests, and how hard will it be?

sergeyboyko0791 commented 1 year ago

I have two ideas on how to catch the logs and (most complex problem) to match them to a corresponding MmCtx instance:

  1. Run the tests consequentially, not simultaneously. Then we can easily use a static log registry, clean it before each test.
  2. Run each WASM test in as a separate process. Then they won't share the static data such as the static log registry.

Both ideas require changing the wasm test runner or using a custom one. I'll try to investigate what can be done.

artemii235 commented 1 year ago

@sergeyboyko0791 This seems not easy. As this task is not a priority, you can postpone it indefinitely 🙂 Maybe we will have more ideas after some time.

sergeyboyko0791 commented 1 year ago

I have also a workaround to implement the 1. point https://github.com/KomodoPlatform/atomicDEX-API/issues/1634#issuecomment-1411841050: We can implement a procedural macro #[mm2_wasm_test] that will do the following:

@artemii235 what do you think?