Skip to content

Commit

Permalink
Merge branch 'bounty_module_pagination' of https://github.com/safe-gl…
Browse files Browse the repository at this point in the history
…obal/safe-contracts into bounty_module_pagination
  • Loading branch information
mmv08 committed Dec 25, 2022
2 parents 78dadea + 743af7f commit 9b5ecde
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions contracts/base/ModuleManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ contract ModuleManager is SelfAuthorized, Executor {
// Populate return array
uint256 moduleCount = 0;
address currentModule = modules[start];

while (currentModule != address(0x0) && currentModule != SENTINEL_MODULES && moduleCount < pageSize) {
array[moduleCount] = currentModule;
next = currentModule;
currentModule = modules[currentModule];
moduleCount++;
}

next = array[moduleCount == 0 ? 0 : moduleCount - 1];
// Set correct size of returned array
// solhint-disable-next-line no-inline-assembly
assembly {
Expand Down
12 changes: 6 additions & 6 deletions test/core/GnosisSafe.ModuleManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe("ModuleManager", async () => {

await expect(
await safe.getModulesPaginated(AddressOne, 10)
).to.be.deep.equal([[user2.address], AddressOne])
).to.be.deep.equal([[user2.address], user2.address])
})

it('can enable multiple', async () => {
Expand All @@ -72,14 +72,14 @@ describe("ModuleManager", async () => {
).to.emit(safe, "EnabledModule").withArgs(user1.address)

await expect(await safe.isModuleEnabled(user1.address)).to.be.true
await expect(await safe.getModulesPaginated(AddressOne, 10)).to.be.deep.equal([[user1.address], AddressOne])
await expect(await safe.getModulesPaginated(AddressOne, 10)).to.be.deep.equal([[user1.address], user1.address])

await expect(
executeContractCallWithSigners(safe, safe, "enableModule", [user2.address], [user1])
).to.emit(safe, "EnabledModule").withArgs(user2.address)

await expect(await safe.isModuleEnabled(user2.address)).to.be.true
await expect(await safe.getModulesPaginated(AddressOne, 10)).to.be.deep.equal([[user2.address, user1.address], AddressOne])
await expect(await safe.getModulesPaginated(AddressOne, 10)).to.be.deep.equal([[user2.address, user1.address], user1.address])
})
})

Expand Down Expand Up @@ -135,19 +135,19 @@ describe("ModuleManager", async () => {
await expect(await safe.isModuleEnabled(user1.address)).to.be.true
await executeContractCallWithSigners(safe, safe, "enableModule", [user2.address], [user1])
await expect(await safe.isModuleEnabled(user2.address)).to.be.true
await expect(await safe.getModulesPaginated(AddressOne, 10)).to.be.deep.equal([[user2.address, user1.address], AddressOne])
await expect(await safe.getModulesPaginated(AddressOne, 10)).to.be.deep.equal([[user2.address, user1.address], user1.address])

await expect(
executeContractCallWithSigners(safe, safe, "disableModule", [user2.address, user1.address], [user1])
).to.emit(safe, "DisabledModule").withArgs(user1.address)
await expect(await safe.isModuleEnabled(user1.address)).to.be.false
await expect(await safe.getModulesPaginated(AddressOne, 10)).to.be.deep.equal([[user2.address], AddressOne])
await expect(await safe.getModulesPaginated(AddressOne, 10)).to.be.deep.equal([[user2.address], user2.address])

await expect(
executeContractCallWithSigners(safe, safe, "disableModule", [AddressOne, user2.address], [user1])
).to.emit(safe, "DisabledModule").withArgs(user2.address)
await expect(await safe.isModuleEnabled(user2.address)).to.be.false
await expect(await safe.getModulesPaginated(AddressOne, 10)).to.be.deep.equal([[], AddressOne])
await expect(await safe.getModulesPaginated(AddressOne, 10)).to.be.deep.equal([[], AddressZero])
})
})

Expand Down
2 changes: 1 addition & 1 deletion test/migration/subTests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const verificationTests = (setupTests: () => Promise<TestSetup>) => {
).to.emit(migratedSafe, "EnabledModule").withArgs(user2.address)

await expect(await migratedSafe.isModuleEnabled(user2.address)).to.be.true
await expect(await migratedSafe.getModulesPaginated(AddressOne, 10)).to.be.deep.equal([[user2.address], AddressOne])
await expect(await migratedSafe.getModulesPaginated(AddressOne, 10)).to.be.deep.equal([[user2.address], user2.address])

const user2Safe = migratedSafe.connect(user2)
await expect(
Expand Down

0 comments on commit 9b5ecde

Please sign in to comment.