aptos-core
aptos-core copied to clipboard
[Bug] Misleading error message in test
🐛 Bug
Getting an error when running aptos move test using this code, unfortunately the error message is not clear and we should provide a better message around missing resources.
To reproduce
Code snippet to reproduce
struct TodoListRegistry has key, store {
task_count: u64
}
fun init_module() acquires TodoListRegistry, SetTaskEvent {
let newTask = string::utf8(b"Checkout aptos.dev");
create_task(newTask);
}
public entry fun create_task(content: String) acquires TodoListRegistry, SetTaskEvent {
let task_registry = borrow_global_mut<TodoListRegistry>(@myself);
}
#[test]
public entry fun test_set_task_count() acquires TodoListRegistry, SetTaskEvent {
init_module();
}
Stack trace/error message
┌── test_set_task_count ──────
│ ITE: An unknown error was reported. Location: error[E11001]: test failure
│ ┌─ /my-appt/move/core/sources/main.move:34:25
│ │
│ 33 │ public entry fun create_task(content: String) acquires TodoListRegistry, SetTaskEvent {
│ │ ----------- In this function in 0xa917d2256d3087fd8f62182264f9016158a07540895c6e18e75957af9dbea22c::main
│ 34 │ let task_registry = borrow_global_mut<TodoListRegistry>(@myself);
Expected Behavior
borrow_global would fail with RESOURCE_NOT_FOUND if the resource doesn't exist at the specified address
System information
Please complete the following information:
Additional context
The signature of the constructor function should take a signer. i.e
...
fun init_module(s: &signer) {
...
This issue is stale because it has been open 45 days with no activity. Remove the stale label or comment - otherwise this will be closed in 15 days.
This issue is stale because it has been open 45 days with no activity. Remove the stale label or comment - otherwise this will be closed in 15 days.