How to test a sway library other than creating a test contract reference to the library?
Hi @felix200912 , great question! Sway has in-language testing you can use for this. You can check out how that works in the Sway docs here: Unit Testing - The Sway Programming Language
This is what I am looking for! Just to clarify, this unit testing can only be testing functions with no storage access (or basically no blockchain state access) right?
Are you referring to checking the state of a node or testing a function with the storage annotation?
From the Sway book:
Unit tests decorated with the
#[test(script)]attribute that are declared within
contractprojects may also call directly into their associated contract’s ABI.
I’ve not tested this feature myself yet, though I do use sway unit testing extensively when developing libraries.
Ref:forc test - The Sway Programming Language
Yes I was referring to testing functions that have storage access, like the ones with
Thanks for clarifying! Yes, you can test functions with storage access.