How to test nonReentrant modifier from ReentrancyGuard.sol

Hi, is there a straightforward way to write a hardhat chai test that verifies the nonReentrant modifier is working as expected in a function (correctly prevents reentrancy)? Is this test necessary and are there any best practices to follow in this case? Thanks.

There you go.

1 Like

Thanks. In this case I would create a new instance of

const attacker = await ReentrancyAttack.new();

and use the attacker to call my function with the nonReentrant modifier?