Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
prateekdefi committed Sep 19, 2024
1 parent 3dac8e7 commit 2fdcd35
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
10 changes: 7 additions & 3 deletions packages/perennial/test/integration/core/happyPath.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1997,7 +1997,7 @@ describe('Happy Path', () => {
const POSITION = parse6decimal('10')
const POSITION_B = parse6decimal('1')
const COLLATERAL = parse6decimal('1000')
const { user, userB, dsu, marketFactory } = instanceVars
const { owner, user, userB, dsu, marketFactory } = instanceVars

const market = await createMarket(instanceVars)

Expand All @@ -2014,9 +2014,13 @@ describe('Happy Path', () => {
.connect(user)
['update(address,uint256,uint256,uint256,int256,bool)'](user.address, POSITION, 0, 0, COLLATERAL, false)

// set user as extension for userB with signature
await marketFactory.connect(userB).updateExtension(user.address, true)
// try to update extension using incorrect owner
await expect(marketFactory.connect(userB).updateExtension(user.address, true))
.to.be.revertedWithCustomError(marketFactory, 'OwnableNotOwnerError')
.withArgs(userB.address)

// update extension with owner
await marketFactory.connect(owner).updateExtension(user.address, true)
// user opens long position for userB
await expect(
market
Expand Down
10 changes: 8 additions & 2 deletions packages/perennial/test/unit/marketfactory/MarketFactory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,18 +399,24 @@ describe('MarketFactory', () => {

describe('#updateExtension', async () => {
it('updates the operator status', async () => {
await expect(factory.connect(user).updateExtension(owner.address, true))
await expect(factory.connect(owner).updateExtension(owner.address, true))
.to.emit(factory, 'ExtensionUpdated')
.withArgs(owner.address, true)

expect(await factory.extensions(owner.address)).to.equal(true)

await expect(factory.connect(user).updateExtension(owner.address, false))
await expect(factory.connect(owner).updateExtension(owner.address, false))
.to.emit(factory, 'ExtensionUpdated')
.withArgs(owner.address, false)

expect(await factory.extensions(owner.address)).to.equal(false)
})

it('reverts if not owner', async () => {
await expect(factory.connect(user).updateExtension(user.address, true))
.to.be.revertedWithCustomError(factory, 'OwnableNotOwnerError')
.withArgs(user.address)
})
})

describe('#updateOperator', async () => {
Expand Down

0 comments on commit 2fdcd35

Please sign in to comment.