flip-fest icon indicating copy to clipboard operation
flip-fest copied to clipboard

JS Testing Feature: Multiple return values from interaction

Open srinjoyc opened this issue 4 years ago β€’ 13 comments

πŸ‘‹ Β  If you are interested in working on this issue, please check out the Getting Started guide on HackerEarth!

Description (Problem Statement)

The JS Testing Framework has two functions: sendTransaction and executeScript that currently return a single result from their execution. It does not have a good way of handling errors that should be caught and processed. This can cause issues with multiple interactions called in succession.

Experience Required

  • Great proficiency with JavaScript
  • Good understanding of Cadence and Flow JS SDK

Minimum Feature Set (Acceptance Criteria)

  • Catch error inside interaction code and always return tuple [result, error].

  • This should make it easier to assert the result of interaction using jest and other libraries.

  • Flow Cadut interactions are already implemented in such a way (refer to this piece of code as an example - https://github.com/onflow/flow-cadut/blob/main/src/interactions.js#L55-L63) so it's mostly a refactoring task.

Extension Feature Set (Optional)

Parse error message and provide an error in form of an object, containing at least errorCode, message. If possible extract more information and format it in a human-readable and usable way.

Milestone Requirements

  1. Meet the minimum feature set and optionally the extension.

Software Requirements

Maintainability

Code should be written with best practices in mind.

Other Requirements

Documentation

  • Documentation should be updated according to the changes made.

Code standards or guidelines

Judging Criteria

Resources

srinjoyc avatar Sep 15 '21 14:09 srinjoyc

Hey, Flow Surfer! My name is Max. I am core member of Developer Experience team and I will be your Point-of-Contact for this task. If you stumble into any challenges with this task, feel free to contact me via replies to this issue or over Flow Discord (my handle is MaxStarka#5714).

Looking forward to work with you! :)

MaxStalker avatar Sep 15 '21 19:09 MaxStalker

Hey Max, I want to make sure I'm understanding this correctly.

Since we are changing the return types of executeScript and executeTransaction in the flow-js-testing library, won't that break any existing code that uses these functions? Not sure how to get around this.

For example, I'm imagining the intended refactor for executeScript is the following:

export const executeScript = async (...props) => {
    try {
        const extractor = extractParameters("script");
        const { code, args } = await extractor(props);
        
        const ix = [fcl.script(code)];
        // add arguments if any
        if (args) {
          ix.push(fcl.args(resolveArguments(args, code)));
        }
        const response = await fcl.send(ix);
        const result = await fcl.decode(response);
        [result, null]
    } catch (e) {
        return [null, e]
    }
}

Am I on the right track here?

OmarMalik avatar Sep 16 '21 23:09 OmarMalik

@OmarMalik that is correct - this will be breaking change if your code previously wasn't using Jest helper methods.

There are 3 ways to go:

  • use fcl.config param to decide how returned value shall look and whether to catch error or not
  • introduce the breaking change with new release and make it clear how developer can refactor it
  • mix two aforementioned solutions by introducing new fcl.configparam in next release and deprecate it and old way of doing things in following

Your call ;)

MaxStalker avatar Sep 17 '21 14:09 MaxStalker

Hey, @OmarMalik are you still working on this issue? :)

MaxStalker avatar Oct 13 '21 20:10 MaxStalker

@OmarMalik if you are still working on this FLIP issue, can you let us know? If not, and if ok with @MaxStalker I'm hoping to do this one in the time that remains with @j00lz. Thanks

hichana avatar Oct 24 '21 02:10 hichana

TeamExponential members: https://github.com/justjoolz https://github.com/hichana We would like to take on this flip if ok @MaxStalker.

hichana avatar Oct 25 '21 08:10 hichana

Green light, @hichana !

MaxStalker avatar Oct 26 '21 18:10 MaxStalker

Hello @MaxStalker, we have made our final submission for this FLIP fest issue: #91 Looking forward to your feedback and/or approval. Thank you

hichana avatar Oct 29 '21 07:10 hichana

πŸŽ‰ Milestone Achieved! πŸŽ‰

Thank you for your submission and participation!

MaxStalker avatar Nov 05 '21 21:11 MaxStalker

Cheers @MaxStalker :)

hichana avatar Nov 05 '21 22:11 hichana

Good day @hichana!

Thanks so much for all your hardwork & participation. In order to finalize winners & prepare for prize payout, we'll need the following actions from your end.

Please provide the following information byΒ Nov 17, 2021, (in this GH Issue is fine):

1. Team Information

  • Team Members Information - Github Username + Email Contact + Percentage of prize allocation (total should = 100%)
  • All mentioned members MUST react to the post with a πŸ‘ which will act as confirmation that the information is correct, or a πŸ‘Ž to indicate that the information is not correct.
  • We will be reaching out via e-mail

πŸŽ–IMPORTANT: We will only proceed with prize payouts once all members have confirmed with πŸ‘ on the post.

2. Video Demo (optional)

  • Please provide a 5-minute video demo to be featured & showcased in the FLIP Fest Closing Ceremonies
  • Link format & Downloadable (eg. Google Drive, Vimeo)
  • Content Format (Problem Statement, your work / how you solved it, final outcome)

We will be hosting Closing Ceremonies on November 23rd, 8AM PT where we'll having closing remarks from Dete & will be announcing the winners! I'll share the details here before Nov 17.

kimcodeashian avatar Nov 13 '21 00:11 kimcodeashian

Thank you :)

Team Information:

hichana avatar Nov 13 '21 12:11 hichana

Hey folks,

We've received and reviewed over 82 submissions! What an amazing community on Flow! To commemorate all the hard work done, we have finalized winners and will be announcing them during our Closing Ceremony on Nov 23rd, 8AM PT. Be sure to join us - there may be some attendance prizes & a keynote from our CTO, Dete πŸ˜‰!

RSVP here so you don't miss out! See you then!

kimcodeashian avatar Nov 17 '21 01:11 kimcodeashian