Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support selection of nested value within query result #75

Closed
wants to merge 4 commits into from

Conversation

evilrobot-01
Copy link
Contributor

  • adds support for selection of nested value within query result, auto-converting balance values accordingly (bigint)
    • isolates change to a single function
  • added simple test to ensure functionality works as expected, useful for regression testing. e.g. yarn zombienet-test -t tests -c tests/config.toml
  • updated interface in readme

Example usage (from test.yml):

              - queries:
                  balance:
                    chain: *relay_chain
                    pallet: system
                    call: account
                    args: [ *account ]
                    selector: 'data.free'
              - asserts:
                  equal:
                    args: [ $balance, 1000000000000000000 ]

@evilrobot-01 evilrobot-01 requested a review from NachoPal October 31, 2022 15:52
@evilrobot-01
Copy link
Contributor Author

This might be improved by taking an array of selectors instead of a single value, which could then collect multiple nested selected values from a query result into an array, provided indexing the array could be supported in the assert yaml:

              - asserts:
                  - equal:
                       args: [ $result[0], true ]
                  - equal:
                       args: [ $result[1], 1000 ]

The basic idea is allowing the checking of certain attributes of a query result against expected values, rather than having to deal with the whole result.

Thinking out loud, maybe an even better approach is to support nested property syntax, where args are parsed and anything after the initial . is just passed to https://lodash.com/docs/#get to resolve the value. I'd be happy to implement if you think that it would ultimately be better than the current PR.

              - asserts:
                  - equal:
                       args: [ $result.booleanValue, true ]
                  - equal:
                       args: [ $result.numericValue, 1000 ]

@evilrobot-01 evilrobot-01 marked this pull request as draft November 10, 2022 12:36
@evilrobot-01
Copy link
Contributor Author

Replaced with #79

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant