Skip to content

Instantly share code, notes, and snippets.

@reime005
Created December 27, 2020 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reime005/820aa591567ab7948c4449b82af65e61 to your computer and use it in GitHub Desktop.
Save reime005/820aa591567ab7948c4449b82af65e61 to your computer and use it in GitHub Desktop.
it('should allow only the owner to change the contract name', async function() {
const instance = await NameStorageExample.deployed();
const CONTRACT_NAME_TO_CHANGE = "ChangedNameStorageExample";
// check if someone other than the owner is eligible to change the contract name
// function will revert if not the owner tries so
// note: account[0] is the owner of the contract
await expectRevert(
instance.changeContractName(CONTRACT_NAME_TO_CHANGE,
fromAccount(accounts, 1)
)
)
// let the owner change the name
const tx1 = await instance.changeContractName(CONTRACT_NAME_TO_CHANGE);
const contractNameAfter = await instance.contractName();
await assert.equal(contractNameAfter,
CONTRACT_NAME_TO_CHANGE, "not equal");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment