onflow/cadence-tools

[Testing Framework] Error when returning a reference type

Opened this issue · 0 comments

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