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

flow test should deploy smart contracts defined in flow.json #1377

Open
wfalcon0x opened this issue Feb 2, 2024 · 2 comments
Open

flow test should deploy smart contracts defined in flow.json #1377

wfalcon0x opened this issue Feb 2, 2024 · 2 comments
Assignees
Labels
Feature A new user feature or a new package API Feedback

Comments

@wfalcon0x
Copy link

Instructions

Issue To Be Solved

Currently we need to explicitly deploy a smart contract in the cadence unit or integration tests, e.g.:

import "FLIXRegistry"
...
...
access(all)
fun setup() {
    let flixRegistryErr = Test.deployContract(
        name: "FLIXRegistry",
        path: "../contracts/flix_registry.cdc",
        arguments: []
    )
...

In the above example FLIXRegistry cannot be referenced in the code before it was deployed with Test.deployContract, even if it is imported on the the top, and defined in the flow.json as follows:

{
  "contracts": {
    "FLIXRegistry": {
      "source": "cadence/contracts/flix_registry.cdc",
      "aliases": {
        "emulator": "0xf8d6e0586b0a20c7",
        "testing": "0x0000000000000007"
      }
    },
...

(Optional): Suggest A Solution

It could increase developer experience if smart contracts defined in the flow.json are readily available in the unit tests, so the developers only have to import those as dependencies.
Also it could keep the unit tests code more concise and clean.

(Optional): Context

@wfalcon0x wfalcon0x added Feature A new user feature or a new package API Feedback labels Feb 2, 2024
@chasefleming
Copy link
Member

@wfalcon0x do they need to be deployed? It seems like you'd want to keep control of deployment in your tests for state. Would the issue be solved for you if the import syntax worked correctly in tests?

@chasefleming chasefleming assigned jribbink and unassigned chasefleming Feb 8, 2024
@wfalcon0x
Copy link
Author

It was my assumption that they need to be deployed to make it work based on the current behaviour. But I think you make a good point, and there are 2 separate issues.

  1. for the actual problem I faced they don't need to be deployed, i just wanted to be able to reference a resource, before they were deployed
  2. it would be nice to have a way to deploy them, so I don't have to control the deployment from the test in every case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature A new user feature or a new package API Feedback
Projects
Status: No status
Development

No branches or pull requests

3 participants