anza-xyz / move

Move compiler targeting llvm supported backends
https://discord.gg/wFgfjG9J
Apache License 2.0
108 stars 33 forks source link

[Bug] stdlib bcs tests encode_128 and encode_129 break on non-empty vector destroying #333

Closed dmakarov closed 11 months ago

dmakarov commented 1 year ago

🐛 Bug

Move native run-time doesn't currently handle destroying vectors with elements (only empty vectors can be destroyed). The tests encode_128, and encode_129 depend on being able to destroy non-empty vectors at the end of the test functions. encode_129 is expected_failure test. It passes because the test doesn't check the abort code, but it aborts for a different reason.

To reproduce

Run encode_128 and encode_129 tests

Code snippet to reproduce

cargo run -p move-cli --features solana-backend --bin move -- test --solana -p language/move-stdlib encode_129

Stack trace/error message

event 0: "panicked at 'assertion failed: `(left == right)`\n  left: `0`,\n right: `1`: can't destroy vectors with elements yet', language/move-native/src/rt.rs:17:5"
event 1: "0x65, 0x65, 0x65, 0x65, 0x65"
[DEBUG language/solana/move-to-solana/src/runner.rs:359] Solana VM abort with code 101
[ PASS    ] 0x1::bcs_tests::encode_129

Test Statistics:

┌────────────────────────────┬────────────┬───────────────────────────┐
│         Test Name          │    Time    │         Gas Used          │
├────────────────────────────┼────────────┼───────────────────────────┤
│ 0x1::bcs_tests::encode_129 │   0.002    │           10949           │
└────────────────────────────┴────────────┴───────────────────────────┘

Test result: OK. Total tests: 1; passed: 1; failed: 0

Expected Behavior

Test passes but because its execution reached the limit of max_call_depth.

The test encode_128 should pass without expected failure.