osmosis icon indicating copy to clipboard operation
osmosis copied to clipboard

[tests: CL Hooks]: Test hook execution order to increase coverage

Open AlpinYukseloglu opened this issue 2 years ago • 0 comments

Background

It is important we ensure that the before hooks are actually executed before the after hooks in their respective function. While this is obviously correct in its current implementation, we should make sure that this is covered in tests so that future changes/additions to hook logic does not accidentally break this order.

Suggested Design

The current hook tests have a CW contract that sends 1 token with a denom corresponding to the hook trigger (e.g. beforeCreatePosition). One viable approach could be to either update this contract or make a second one where the number of tokens sent corresponds to the order the hooks were triggered.

Specifically, each hook trigger would increment a counter in state similar to in the counter test contract in x/concentrated-liquidity/testcontracts, and then assertions would be run on the specific number of tokens to ensure ordering is correct.

Acceptance Criteria

All new and existing tests pass

AlpinYukseloglu avatar Nov 11 '23 00:11 AlpinYukseloglu