diff --git a/contracts/tokens/SecurityToken.sol b/contracts/tokens/SecurityToken.sol index 65ab132d9..1efeac03f 100644 --- a/contracts/tokens/SecurityToken.sol +++ b/contracts/tokens/SecurityToken.sol @@ -360,6 +360,7 @@ contract SecurityToken is ERC20, ReentrancyGuard, SecurityTokenStorage, IERC1594 */ function changeName(string calldata _name) external { _onlyOwner(); + require(bytes(_name).length > 0); emit UpdateTokenName(name, _name); name = _name; } diff --git a/test/o_security_token.js b/test/o_security_token.js index 780cee7c4..fed5fe2b8 100644 --- a/test/o_security_token.js +++ b/test/o_security_token.js @@ -215,6 +215,10 @@ contract("SecurityToken", async (accounts) => { await catchRevert(I_SecurityToken.changeName("new token name")); }); + it("Should not allow 0 length name", async() => { + await catchRevert(I_SecurityToken.changeName("", { from: token_owner })); + }); + it("Should allow authorized address to change name", async() => { let snapId = await takeSnapshot(); await I_SecurityToken.changeName("new token name", { from: token_owner });