The `sui move test` command still passes when the test should fail because of Sui protocol limitations.
Steps to Reproduce Issue
For example, the program below should fail when we call add_to_many_field.
public struct ABC has key, store{
id: UID
}
public fun create(ctx: &mut TxContext){
let obj = ABC {
id: object::new(ctx)
};
sui::transfer::public_transfer(obj, tx_context::sender(ctx));
}
public fun add_too_many_field(abc: &mut ABC) {
let mut i = 0;
while (i < 1200) {
dynamic_field::add(&mut abc.id, i, i);
let j = *dynamic_field::borrow(&abc.id, i);
i = j + 1;
}
}
However, the test still passes.
#[test]
fun test_too_many_field() {
let sender = @0x01;
let mut scenario = test_scenario::begin(sender);
let ctx = scenario.ctx();
plusone::create(ctx);
test_scenario::next_tx(&mut scenario, sender);
let mut abc: plusone::ABC = test_scenario::take_from_address(&scenario, sender);
plusone::add_too_many_field(&mut abc);
sui::test_utils::destroy(abc);
scenario.end();
}
Expected Result
Return an error when running the test
Actual Result
Test passed.
System Information
- OS: Linux
- Compiler: 1.48.0-1d646f736c8b
Thank you for opening this issue, a team member will review it shortly. Until then, please do not interact with any users that claim to be from Sui support and do not click on any links!
we are aware of this and it's a bit unfortunate. However we do not think move tests should check for limits at the moment. Limits are variable and they change over time. We would have to read protocol config and other Sui data from Move, and tests would fail randomly when changes to limits will occur. And of course those changes are not changes you make but things that depend on what sui checkout you have. One could envision a world where that could somewhat be useful, but given the bandwidth that we have we do not think this is something we should spend time on right now. Hope it makes sense and feel free to comment or give feedback and opinions.
Maybe one thing we should look at is to make limits configurable in tests so that you can test limits. But even that is not clear what would help and what those tests are actually testing
Thank you for the response! We may need to add the note about this situation to the sui docs. We didn't know about this until we got the error on some random tests on testnet and spent around 1 or 2 weeks figuring out what happened. We are lucky to receive help from an experienced developer to solve this.
Summary: My recommendation is to add notes about the sui move test to the Sui docs.