-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
registry: implement stateless property
- Loading branch information
1 parent
c9bf227
commit 3e562fe
Showing
8 changed files
with
139 additions
and
58 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,7 @@ describe('Deployer', () => { | |
|
||
context('when the implementation is registered', () => { | ||
beforeEach('register implementation', async () => { | ||
await registry.connect(mimic).register('[email protected]', authorizer.address) | ||
await registry.connect(mimic).register('[email protected]', authorizer.address, false) | ||
}) | ||
|
||
context('when the implementation is not deprecated', () => { | ||
|
@@ -172,8 +172,8 @@ describe('Deployer', () => { | |
|
||
context('when the implementation is registered', () => { | ||
beforeEach('register implementations', async () => { | ||
await registry.connect(mimic).register('[email protected]', smartVault.address) | ||
await registry.connect(mimic).register('[email protected]', PRICE_ORACLE) | ||
await registry.connect(mimic).register('[email protected]', smartVault.address, false) | ||
await registry.connect(mimic).register('[email protected]', PRICE_ORACLE, true) | ||
}) | ||
|
||
context('when the implementation is not deprecated', () => { | ||
|
@@ -292,10 +292,10 @@ describe('Deployer', () => { | |
const FEE_CONTROLLER = '0x0000000000000000000000000000000000000001' | ||
const WNT = '0x0000000000000000000000000000000000000002' | ||
const smartVaultImpl = await deploy(ARTIFACTS.SMART_VAULT, [registry.address, FEE_CONTROLLER, WNT]) | ||
await registry.connect(mimic).register('[email protected]', smartVaultImpl.address) | ||
await registry.connect(mimic).register('[email protected]', smartVaultImpl.address, false) | ||
|
||
const PRICE_ORACLE = '0x0000000000000000000000000000000000000004' | ||
await registry.connect(mimic).register('[email protected]', PRICE_ORACLE) | ||
await registry.connect(mimic).register('[email protected]', PRICE_ORACLE, true) | ||
|
||
const tx = await deployer.deploySmartVault(namespace, 'smart-vault', { | ||
impl: smartVaultImpl.address, | ||
|
@@ -316,7 +316,7 @@ describe('Deployer', () => { | |
|
||
context('when the implementation is registered', () => { | ||
beforeEach('register implementations', async () => { | ||
await registry.connect(mimic).register('[email protected]', task.address) | ||
await registry.connect(mimic).register('[email protected]', task.address, false) | ||
}) | ||
|
||
context('when the implementation is not deprecated', () => { | ||
|
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 |
---|---|---|
|
@@ -44,35 +44,57 @@ describe('Registry', () => { | |
|
||
context('when the requested implementation was not created', () => { | ||
context('when the requested implementation is not registered', () => { | ||
it('creates and registers the requested implementation', async () => { | ||
const tx = await registry.create(name, bytecode) | ||
context('when the requested implementation is considered stateless', () => { | ||
const stateless = true | ||
|
||
const event = await assertEvent(tx, 'Registered', { name }) | ||
it('creates and registers the requested implementation', async () => { | ||
const tx = await registry.create(name, bytecode, stateless) | ||
|
||
const implementation = event.args.implementation | ||
expect(await registry.isRegistered(implementation)).to.be.true | ||
expect(await registry.isDeprecated(implementation)).to.be.false | ||
const event = await assertEvent(tx, 'Registered', { name, stateless }) | ||
|
||
const implementation = event.args.implementation | ||
expect(await registry.isRegistered(implementation)).to.be.true | ||
expect(await registry.isStateless(implementation)).to.be.true | ||
expect(await registry.isDeprecated(implementation)).to.be.false | ||
}) | ||
}) | ||
|
||
context('when the requested implementation is not considered stateless', () => { | ||
const stateless = false | ||
|
||
it('creates and registers the requested implementation', async () => { | ||
const tx = await registry.create(name, bytecode, stateless) | ||
|
||
const event = await assertEvent(tx, 'Registered', { name, stateless }) | ||
|
||
const implementation = event.args.implementation | ||
expect(await registry.isRegistered(implementation)).to.be.true | ||
expect(await registry.isStateless(implementation)).to.be.false | ||
expect(await registry.isDeprecated(implementation)).to.be.false | ||
}) | ||
}) | ||
}) | ||
|
||
context('when the requested implementation is registered', () => { | ||
beforeEach('register', async () => { | ||
await registry.register(name, implementation) | ||
await registry.register(name, implementation, true) | ||
}) | ||
|
||
it('reverts', async () => { | ||
await expect(registry.register(name, implementation)).to.be.revertedWith('REGISTRY_IMPL_ALREADY_REGISTERED') | ||
await expect(registry.register(name, implementation, true)).to.be.revertedWith( | ||
'REGISTRY_IMPL_ALREADY_REGISTERED' | ||
) | ||
}) | ||
}) | ||
}) | ||
|
||
context('when the requested implementation was created', () => { | ||
beforeEach('create', async () => { | ||
await registry.create(name, bytecode) | ||
await registry.create(name, bytecode, true) | ||
}) | ||
|
||
it('reverts', async () => { | ||
await expect(registry.create(name, bytecode)).to.be.revertedWith('DEPLOYMENT_FAILED') | ||
await expect(registry.create(name, bytecode, true)).to.be.revertedWith('DEPLOYMENT_FAILED') | ||
}) | ||
}) | ||
}) | ||
|
@@ -83,7 +105,7 @@ describe('Registry', () => { | |
}) | ||
|
||
it('reverts', async () => { | ||
await expect(registry.create(name, implementation)).to.be.revertedWith('Ownable: caller is not the owner') | ||
await expect(registry.create(name, implementation, true)).to.be.revertedWith('Ownable: caller is not the owner') | ||
}) | ||
}) | ||
}) | ||
|
@@ -97,27 +119,44 @@ describe('Registry', () => { | |
}) | ||
|
||
context('when the requested implementation is not registered', () => { | ||
it('registers the requested implementation', async () => { | ||
await registry.register(name, implementation) | ||
context('when the requested implementation is considered stateless', () => { | ||
const stateless = true | ||
|
||
it('registers the requested implementation', async () => { | ||
const tx = await registry.register(name, implementation, stateless) | ||
|
||
expect(await registry.isRegistered(implementation)).to.be.true | ||
expect(await registry.isDeprecated(implementation)).to.be.false | ||
await assertEvent(tx, 'Registered', { name, implementation, stateless }) | ||
|
||
expect(await registry.isRegistered(implementation)).to.be.true | ||
expect(await registry.isStateless(implementation)).to.be.true | ||
expect(await registry.isDeprecated(implementation)).to.be.false | ||
}) | ||
}) | ||
|
||
it('emits an event', async () => { | ||
const tx = await registry.register(name, implementation) | ||
context('when the requested implementation is not considered stateless', () => { | ||
const stateless = false | ||
|
||
it('registers the requested implementation', async () => { | ||
const tx = await registry.register(name, implementation, stateless) | ||
|
||
await assertEvent(tx, 'Registered', { name, implementation, stateless }) | ||
|
||
await assertEvent(tx, 'Registered', { name, implementation }) | ||
expect(await registry.isRegistered(implementation)).to.be.true | ||
expect(await registry.isStateless(implementation)).to.be.false | ||
expect(await registry.isDeprecated(implementation)).to.be.false | ||
}) | ||
}) | ||
}) | ||
|
||
context('when the requested implementation is registered', () => { | ||
beforeEach('register', async () => { | ||
await registry.register(name, implementation) | ||
await registry.register(name, implementation, true) | ||
}) | ||
|
||
it('reverts', async () => { | ||
await expect(registry.register(name, implementation)).to.be.revertedWith('REGISTRY_IMPL_ALREADY_REGISTERED') | ||
await expect(registry.register(name, implementation, true)).to.be.revertedWith( | ||
'REGISTRY_IMPL_ALREADY_REGISTERED' | ||
) | ||
}) | ||
}) | ||
}) | ||
|
@@ -128,7 +167,9 @@ describe('Registry', () => { | |
}) | ||
|
||
it('reverts', async () => { | ||
await expect(registry.register(name, implementation)).to.be.revertedWith('Ownable: caller is not the owner') | ||
await expect(registry.register(name, implementation, true)).to.be.revertedWith( | ||
'Ownable: caller is not the owner' | ||
) | ||
}) | ||
}) | ||
}) | ||
|
@@ -147,14 +188,15 @@ describe('Registry', () => { | |
|
||
context('when the requested implementation is registered', () => { | ||
beforeEach('register', async () => { | ||
await registry.register('[email protected]', implementation) | ||
await registry.register('[email protected]', implementation, true) | ||
}) | ||
|
||
context('when the requested implementation is not deprecated', () => { | ||
it('registers the requested implementation', async () => { | ||
await registry.deprecate(implementation) | ||
|
||
expect(await registry.isRegistered(implementation)).to.be.true | ||
expect(await registry.isStateless(implementation)).to.be.true | ||
expect(await registry.isDeprecated(implementation)).to.be.true | ||
}) | ||
|
||
|
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
Oops, something went wrong.