Yes, they need to fix the repo as changes with 0.16.0 removed ability to call init
from test modules.
The workaround is to factor out the steps in the current init
to one or more helper functions. That way, a test_init
function can mirror what init
does and you can call the test_init
from test modules.
Before
/// Initialize new deployment
fun init(ctx: &mut TxContext) {
// Do A
// Do B
// Do C
}
#[test_only]
/// Wrapper of module initializer for testing
public fun test_init(ctx: &mut TxContext) {
init(ctx)
}
After
fun do_a(ctx: &mut TxContext) {
// Refactored from init
}
fun do_b(ctx: &mut TxContext) {
// Refactored from init
}
/// Initialize new deployment
fun init(ctx: &mut TxContext) {
do_a(ctx);
do_b(ctx)
}
#[test_only]
/// Wrapper of module initializer for testing
public fun test_init(ctx: &mut TxContext) {
do_a(ctx);
do_b(ctx)
}