Summary
The test iota_genesis_builder::stardust::migration::tests::basic::basic_migration_with_native_tokens failed intermittently in CI on PR #11697 (attempt 1 of the "Run rust tests" job, job ID 80802386929). The run was rerun and passed on attempt 2. The failure was a Rust unwrap() panic at crates/iota-genesis-builder/src/stardust/migration/tests/basic.rs:352.
Failure evidence
Root cause analysis
Two sources of non-determinism interact in this test:
-
random_output_header() is called for each of the 10 foundry outputs created in the test loop (lines 320–337). This gives each native token a random Object ID, making the order of objects in the execution result's written map unpredictable across runs.
-
written.values().find(...) inside extract_native_tokens_from_bag() (in tests/mod.rs) iterates over a HashMap's values in an arbitrary order to locate the expected coin object. When combined with the randomised Object IDs above, the lookup can fail to match the correct coin object and returns Err("missing coin object") — which then propagates to the .unwrap() at basic.rs:352.
Expected behaviour
The test should pass deterministically regardless of Object ID assignment or HashMap iteration order. The lookup logic should not rely on HashMap iteration order to correlate native-token coins with their expected types.
Suggested fix
Replace the HashMap::values().find(...) approach with a lookup keyed on a stable identifier (e.g. the struct tag or token ID) so that the result does not depend on iteration order. Alternatively, use a deterministic data structure (BTreeMap) for the written map if iteration order matters to the test assertions.
Summary
The test
iota_genesis_builder::stardust::migration::tests::basic::basic_migration_with_native_tokensfailed intermittently in CI on PR #11697 (attempt 1 of the "Run rust tests" job, job ID80802386929). The run was rerun and passed on attempt 2. The failure was a Rustunwrap()panic atcrates/iota-genesis-builder/src/stardust/migration/tests/basic.rs:352.Failure evidence
Root cause analysis
Two sources of non-determinism interact in this test:
random_output_header()is called for each of the 10 foundry outputs created in the test loop (lines 320–337). This gives each native token a random Object ID, making the order of objects in the execution result'swrittenmap unpredictable across runs.written.values().find(...)insideextract_native_tokens_from_bag()(intests/mod.rs) iterates over aHashMap's values in an arbitrary order to locate the expected coin object. When combined with the randomised Object IDs above, the lookup can fail to match the correct coin object and returnsErr("missing coin object")— which then propagates to the.unwrap()atbasic.rs:352.Expected behaviour
The test should pass deterministically regardless of Object ID assignment or HashMap iteration order. The lookup logic should not rely on HashMap iteration order to correlate native-token coins with their expected types.
Suggested fix
Replace the
HashMap::values().find(...)approach with a lookup keyed on a stable identifier (e.g. the struct tag or token ID) so that the result does not depend on iteration order. Alternatively, use a deterministic data structure (BTreeMap) for thewrittenmap if iteration order matters to the test assertions.