Skip to content

Instantly share code, notes, and snippets.

@evilrobot-01
evilrobot-01 / test.rs
Created September 28, 2023 16:31
Test: Weight Validation
// Simple test to validate weights resulting from weight functions, generated by benchmarking, against various known limits.
//
// NOTE: this is simply to provide a rough indication of dispatchable weights in relation to block limits, which can be useful for:
// - ensuring a dispatchable does not exceed block, max extrinsic limits and regression testing
// - evaluating if some optimisation results in net reduction in weight usage
// - getting a feel for weights early during pallet development and monitoring through optimisation
//
// Is only as good as the corresponding runtime configuration (i.e. test placed within pallet with mock runtime vs placed within runtime with actual runtime config).
// Also ensure the limits are relevant to your implementation, they may have changed with newer versions and will definitely change with async backing.
// Finally, it uses the generated weight functions directly and therefore does not cater to any post-dispatch weight adjustment resulting from a dispatchable.