Skip to content

Commit

Permalink
chore: update test for custom error
Browse files Browse the repository at this point in the history
  • Loading branch information
yk-saito committed Oct 12, 2023
1 parent a382fff commit 2239fdb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ describe('Shield', function () {
const { shield, alice } = await loadFixture(deployWhitelistFixture);

// Verify that an account that is not the owner of the contract will get an error if it tries to execute the setPaused function.
await expect(shield.connect(alice).setPaused(true)).to.be.revertedWith(
'Ownable: caller is not the owner',
);
await expect(shield.connect(alice).setPaused(true))
.to.be.revertedWithCustomError(shield, 'OwnableUnauthorizedAccount')
.withArgs(alice.address);
});
});
context('when set to true', function () {
Expand Down Expand Up @@ -280,9 +280,9 @@ describe('Shield', function () {
const { shield, alice } = await loadFixture(deployWhitelistFixture);

// Verify that an error occurs when an account that is not the owner of the contract tries to execute the withdraw function.
await expect(shield.connect(alice).withdraw()).to.be.revertedWith(
'Ownable: caller is not the owner',
);
await expect(shield.connect(alice).withdraw())
.to.be.revertedWithCustomError(shield, 'OwnableUnauthorizedAccount')
.withArgs(alice.address);
});
});
context('when owner executes', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ describe('Shield', function () {
const { shield, alice } = await loadFixture(deployWhitelistFixture);

// コントラクトのオーナーではないアカウントが、setPaused関数を実行しようとするとエラーとなることを確認します。
await expect(shield.connect(alice).setPaused(true)).to.be.revertedWith(
'Ownable: caller is not the owner',
);
await expect(shield.connect(alice).setPaused(true))
.to.be.revertedWithCustomError(shield, 'OwnableUnauthorizedAccount')
.withArgs(alice.address);
});
});
context('when set to true', function () {
Expand Down Expand Up @@ -280,9 +280,9 @@ describe('Shield', function () {
const { shield, alice } = await loadFixture(deployWhitelistFixture);

// コントラクトのオーナーではないアカウントが、withdraw関数を実行しようとするとエラーとなることを確認します。
await expect(shield.connect(alice).withdraw()).to.be.revertedWith(
'Ownable: caller is not the owner',
);
await expect(shield.connect(alice).withdraw())
.to.be.revertedWithCustomError(shield, 'OwnableUnauthorizedAccount')
.withArgs(alice.address);
});
});
context('when owner executes', function () {
Expand Down

0 comments on commit 2239fdb

Please sign in to comment.