Assert the payload of an Aptos module event in a Move test
A state assertion can pass even when a module emits an incorrect event identifier. Aptos exposes typed test-only readers for events emitted during execution.
Select events by the application’s declared type
Import aptos_framework::event into the module. The minimal test emits one Packed event and checks its order number. Replace the direct emit with the production packing operation to verify the real call path.
#[event]
struct Packed has drop, store { order: u64 }
#[test]
fun packs_one_order() {
event::emit(Packed { order: 17 });
let entries = event::emitted_events<Packed>();
assert!(entries.length() == 1 && entries[0].order == 17, 0);
}
Check multiplicity independently of content
An implementation emitting order 17 twice would pass a simple membership check. The length assertion detects the duplicate. Exercise a transaction with two different orders and check both values in emission order. The helper is available to Move tests, while a production indexer reads committed transaction events through its data source.