|
@@ -7,7 +7,8 @@ for (const variant of ['', 'Transient']) {
|
|
|
async function fixture() {
|
|
|
const name = `Reentrancy${variant}Mock`;
|
|
|
const mock = await ethers.deployContract(name);
|
|
|
- return { name, mock };
|
|
|
+ const attacker = await ethers.deployContract('ReentrancyAttack');
|
|
|
+ return { name, mock, attacker };
|
|
|
}
|
|
|
|
|
|
beforeEach(async function () {
|
|
@@ -20,9 +21,16 @@ for (const variant of ['', 'Transient']) {
|
|
|
expect(await this.mock.counter()).to.equal(1n);
|
|
|
});
|
|
|
|
|
|
- it('does not allow remote callback', async function () {
|
|
|
- const attacker = await ethers.deployContract('ReentrancyAttack');
|
|
|
- await expect(this.mock.countAndCall(attacker)).to.be.revertedWith('ReentrancyAttack: failed call');
|
|
|
+ it('nonReentrantView function can be called', async function () {
|
|
|
+ await this.mock.viewCallback();
|
|
|
+ });
|
|
|
+
|
|
|
+ it('does not allow remote callback to nonReentrant function', async function () {
|
|
|
+ await expect(this.mock.countAndCall(this.attacker)).to.be.revertedWith('ReentrancyAttack: failed call');
|
|
|
+ });
|
|
|
+
|
|
|
+ it('does not allow remote callback to nonReentrantView function', async function () {
|
|
|
+ await expect(this.mock.countAndCallView(this.attacker)).to.be.revertedWith('ReentrancyAttack: failed call');
|
|
|
});
|
|
|
|
|
|
it('_reentrancyGuardEntered should be true when guarded', async function () {
|