-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests: Coverage improvements #474
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,6 +109,7 @@ contract('EVM Script', accounts => { | |
|
||
assertEvent(receipt, 'DisableExecutor') | ||
assert.isFalse(executorEntry[1], "executor should now be disabled") | ||
assert.equal(await reg.getScriptExecutor(`0x0000000${newExecutorId}`), ZERO_ADDR, 'getting disabled executor should return zero addr') | ||
}) | ||
|
||
it('can re-enable an executor', async () => { | ||
|
@@ -117,12 +118,14 @@ contract('EVM Script', accounts => { | |
await reg.disableScriptExecutor(newExecutorId, { from: boss }) | ||
let executorEntry = await reg.executors(newExecutorId) | ||
assert.isFalse(executorEntry[1], "executor should now be disabled") | ||
assert.equal(await reg.getScriptExecutor(`0x0000000${newExecutorId}`), ZERO_ADDR, 'getting disabled executor should return zero addr') | ||
|
||
const receipt = await reg.enableScriptExecutor(newExecutorId, { from: boss }) | ||
executorEntry = await reg.executors(newExecutorId) | ||
|
||
assertEvent(receipt, 'EnableExecutor') | ||
assert.isTrue(executorEntry[1], "executor should now be re-enabled") | ||
assert.notEqual(await reg.getScriptExecutor(`0x0000000${newExecutorId}`), ZERO_ADDR, 'getting disabled executor should return non-zero addr') | ||
}) | ||
|
||
it('fails to add a new executor without the correct permissions', async () => { | ||
|
@@ -153,6 +156,13 @@ contract('EVM Script', accounts => { | |
}) | ||
}) | ||
|
||
it('fails to enable a non-existent executor', async () => { | ||
await acl.createPermission(boss, reg.address, await reg.REGISTRY_MANAGER_ROLE(), boss, { from: boss }) | ||
await assertRevert(async () => { | ||
await reg.enableScriptExecutor(newExecutorId + 1, { from: boss }) | ||
}) | ||
}) | ||
|
||
it('fails to disable an already disabled executor', async () => { | ||
await acl.createPermission(boss, reg.address, await reg.REGISTRY_MANAGER_ROLE(), boss, { from: boss }) | ||
await reg.disableScriptExecutor(newExecutorId, { from: boss }) | ||
|
@@ -326,37 +336,23 @@ contract('EVM Script', accounts => { | |
}) | ||
}) | ||
|
||
context('registry', () => { | ||
it('can be disabled', async () => { | ||
context('> Registry actions', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that these tests have been simplified as most of the functionality was already tested earlier. |
||
it("can't be executed once disabled", async () => { | ||
await acl.createPermission(boss, reg.address, await reg.REGISTRY_MANAGER_ROLE(), boss, { from: boss }) | ||
const receipt = await reg.disableScriptExecutor(1, { from: boss }) | ||
const isEnabled = (await reg.executors(1))[1] // enabled flag is second in struct | ||
await reg.disableScriptExecutor(1, { from: boss }) | ||
|
||
assertEvent(receipt, 'DisableExecutor') | ||
assert.equal(await reg.getScriptExecutor('0x00000001'), ZERO_ADDR, 'getting disabled executor should return zero addr') | ||
assert.isFalse(isEnabled, 'executor should be disabled') | ||
return assertRevert(async () => { | ||
await executorApp.execute(encodeCallScript([])) | ||
}) | ||
}) | ||
|
||
it('can be re-enabled', async () => { | ||
let isEnabled | ||
await acl.createPermission(boss, reg.address, await reg.REGISTRY_MANAGER_ROLE(), boss, { from: boss }) | ||
|
||
// First, disable the executor | ||
// Disable then re-enable the executor | ||
await reg.disableScriptExecutor(1, { from: boss }) | ||
isEnabled = (await reg.executors(1))[1] // enabled flag is second in struct | ||
assert.equal(await reg.getScriptExecutor('0x00000001'), ZERO_ADDR, 'getting disabled executor should return zero addr') | ||
assert.isFalse(isEnabled, 'executor should be disabled') | ||
|
||
// Then re-enable it | ||
const receipt = await reg.enableScriptExecutor(1, { from: boss }) | ||
isEnabled = (await reg.executors(1))[1] // enabled flag is second in struct | ||
await reg.enableScriptExecutor(1, { from: boss }) | ||
|
||
assertEvent(receipt, 'EnableExecutor') | ||
assert.notEqual(await reg.getScriptExecutor('0x00000001'), ZERO_ADDR, 'getting enabled executor should be non-zero addr') | ||
assert.isTrue(isEnabled, 'executor should be enabled') | ||
await executorApp.execute(encodeCallScript([])) | ||
}) | ||
}) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This mock has been refactored to be simpler, and more targeted about what's missing.