You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am not able to use an event signature as a return type in the cadence testing framework:
Expected Behavior
It would be great to allow these kinds of return signatures so I can cut down on copy/paste code. Usually I need the same type of event over and over when writing tests and was hoping I could write a helper to achieve this more easily
Steps To Reproduce
import Test
import "Foo"
// some tests here
...
// this method is invalid
pub fun getLatestEvent(): Foo.SomeEvent {
return Test.eventsOfType(Type<Foo.SomeEvent>()).removeLast() as! Foo.SomeEvent
}
Environment
- Cadence version: v1.9.2
- Network: Testing
The text was updated successfully, but these errors were encountered:
Unfortunately this comes from Cadence itself. Events are currently not "first-class" citizens, in that they cannot be used as argument types / return types or be constructed and assigned to variables. However, we can use their type for type-casting, as you have done here:
Current Behavior
I am not able to use an event signature as a return type in the cadence testing framework:
Expected Behavior
It would be great to allow these kinds of return signatures so I can cut down on copy/paste code. Usually I need the same type of event over and over when writing tests and was hoping I could write a helper to achieve this more easily
Steps To Reproduce
Environment
The text was updated successfully, but these errors were encountered: