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

[Testing Framework] Error when returning a reference type #339

Open
joshuahannan opened this issue Apr 11, 2024 · 0 comments
Open

[Testing Framework] Error when returning a reference type #339

joshuahannan opened this issue Apr 11, 2024 · 0 comments
Labels
Bug The issue represents a bug, malfunction, regression Feedback

Comments

@joshuahannan
Copy link
Member

joshuahannan commented Apr 11, 2024

Current Behavior

When executing a script that returns a reference, the error that the testing framework gives is unclear:

- FAIL: testGetIterator
    Execution failed:
    error: slab (0x0.1055) not found: slab not found for stored value
      --> tests/example_nft_test.cdc:262:12

Expected Behavior

Since scripts are normally allowed to return reference types, it would make sense to allow returning these types in the testing framework, or at least have a more clear error.

Steps To Reproduce

  1. Run a script from the testing framework that returns a reference, like this one:
import "FungibleToken"

access(all) fun main(account: Address): &{FungibleToken.Balance} {

    let vaultRef = getAccount(account)
        .capabilities.borrow<&{FungibleToken.Balance}>(/public/flowTokenBalance)
        ?? panic("Could not borrow Balance reference to the Vault")

    return vaultRef
}
  1. Observe the error

Environment

- Network: Emulator

github.com/onflow/cadence v1.0.0-preview.19
github.com/onflow/cadence-tools/test v1.0.0-preview.13
github.com/onflow/flow-emulator v1.0.0-preview.16
@joshuahannan joshuahannan added Bug The issue represents a bug, malfunction, regression Feedback labels Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug The issue represents a bug, malfunction, regression Feedback
Projects
None yet
Development

No branches or pull requests

1 participant