Skip to content

Commit

Permalink
Add revert message to removeStorageRoot (#9010)
Browse files Browse the repository at this point in the history
* Add revert message to removeStorageRoot

* Update unit test
  • Loading branch information
yorhodes authored and martinvol committed May 13, 2022
1 parent b5d80c7 commit 932d51a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/protocol/contracts/common/Accounts.sol
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ contract Accounts is
*/
function removeStorageRoot(uint256 index) external {
require(isAccount(msg.sender), "Unknown account");
require(index < offchainStorageRoots[msg.sender].length);
require(index < offchainStorageRoots[msg.sender].length, "Invalid storage root index");
uint256 lastIndex = offchainStorageRoots[msg.sender].length - 1;
bytes memory url = offchainStorageRoots[msg.sender][index];
offchainStorageRoots[msg.sender][index] = offchainStorageRoots[msg.sender][lastIndex];
Expand Down
4 changes: 2 additions & 2 deletions packages/protocol/test/common/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,8 @@ contract('Accounts', (accounts: string[]) => {
})

describe('when there are no storage roots', async () => {
it('should revert', async () => {
await assertRevert(accountsInstance.removeStorageRoot(0))
it('should revert with message', async () => {
await assertRevert(accountsInstance.removeStorageRoot(0), 'Invalid storage root index')
})
})

Expand Down

0 comments on commit 932d51a

Please sign in to comment.