Skip to content

Commit caa0c72

Browse files
committed
chore: ID-4134: add tests
1 parent ed644cd commit caa0c72

4 files changed

Lines changed: 647 additions & 11 deletions

File tree

tests/ERC165.spec.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
MainModuleDynamicAuth,
99
StartupWalletImpl,
1010
LatestWalletImplLocator,
11+
ImmutableSigner,
1112
Factory,
1213
Factory__factory,
1314
MainModule__factory,
@@ -16,6 +17,7 @@ import {
1617
ERC165CheckerMock__factory,
1718
StartupWalletImpl__factory,
1819
LatestWalletImplLocator__factory,
20+
ImmutableSigner__factory,
1921
} from '../src'
2022

2123
ethers.utils.Logger.setLogLevel(ethers.utils.Logger.levels.ERROR)
@@ -51,6 +53,7 @@ contract('ERC165', () => {
5153
let moduleDynamicAuth: MainModuleDynamicAuth
5254
let startupWalletImpl: StartupWalletImpl
5355
let moduleLocator: LatestWalletImplLocator
56+
let immutableSigner: ImmutableSigner
5457

5558
let owner: ethers.Wallet
5659
let wallet: MainModule
@@ -70,10 +73,12 @@ contract('ERC165', () => {
7073
// Startup and Locator
7174
moduleLocator = await new LatestWalletImplLocator__factory().connect(signer).deploy(await signer.getAddress(), await signer.getAddress())
7275
startupWalletImpl = await new StartupWalletImpl__factory().connect(signer).deploy(moduleLocator.address)
76+
// Deploy ImmutableSigner
77+
immutableSigner = await new ImmutableSigner__factory().connect(signer).deploy(await signer.getAddress(), await signer.getAddress(), await signer.getAddress())
7378
// Deploy MainModule
7479
mainModule = await new MainModule__factory().connect(signer).deploy(factory.address)
7580
moduleUpgradable = await new MainModuleUpgradable__factory().connect(signer).deploy()
76-
moduleDynamicAuth = await new MainModuleDynamicAuth__factory().connect(signer).deploy(factory.address, startupWalletImpl.address)
81+
moduleDynamicAuth = await new MainModuleDynamicAuth__factory().connect(signer).deploy(factory.address, startupWalletImpl.address, immutableSigner.address)
7782
// Deploy ERC165 Checker
7883
erc165checker = await new ERC165CheckerMock__factory().connect(signer).deploy()
7984

tests/ImmutableDeployment.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ describe('E2E Immutable Wallet Deployment', () => {
9393
// Nonce 5
9494
mainModuleDynamicAuth = await new MainModuleDynamicAuth__factory()
9595
.connect(contractDeployerEOA)
96-
.deploy(factory.address, startupWallet.address)
96+
.deploy(factory.address, startupWallet.address, immutableSigner.address)
9797

9898
// Setup the latest implementation address
9999
await moduleLocator
@@ -283,7 +283,7 @@ describe('E2E Immutable Wallet Deployment', () => {
283283
)
284284

285285
await expect(wallet.execute([transaction], nonce, signature)).to.be.revertedWith(
286-
'ModuleAuth#_signatureValidation: INVALID_SIGNATURE'
286+
'ModuleAuthDynamic#_signatureValidation: INVALID_SIGNATURE'
287287
)
288288
})
289289

@@ -336,7 +336,7 @@ describe('E2E Immutable Wallet Deployment', () => {
336336
)
337337

338338
await expect(wallet.execute([transaction], nonce, signature)).to.be.revertedWith(
339-
'ModuleAuth#_signatureValidation: INVALID_SIGNATURE'
339+
'ModuleAuthDynamic#_signatureValidation: INVALID_SIGNATURE'
340340
)
341341
})
342342

@@ -393,7 +393,7 @@ describe('E2E Immutable Wallet Deployment', () => {
393393
)
394394

395395
await expect(wallet.execute([transaction], nonce, signature)).to.be.revertedWith(
396-
'ModuleAuth#_signatureValidation: INVALID_SIGNATURE'
396+
'ModuleAuthDynamic#_signatureValidation: INVALID_SIGNATURE'
397397
)
398398
})
399399
})

tests/ImmutableStartup.spec.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ describe('Wallet Factory', function () {
2323
const StartupWalletImpl= await ethers.getContractFactory('StartupWalletImpl')
2424
const startupWalletImpl = await StartupWalletImpl.deploy(latestWalletImplLocator.address)
2525

26+
// Deploy ImmutableSigner contract for use in MainModuleMock deployments
27+
const ImmutableSigner = await ethers.getContractFactory('ImmutableSigner')
28+
const immutableSigner = await ImmutableSigner.deploy(owner.address, owner.address, owner.address)
29+
2630
const MainModule = await ethers.getContractFactory('MainModuleMockV1')
27-
const mainModuleV1 = await MainModule.deploy(factory.address, startupWalletImpl.address)
31+
const mainModuleV1 = await MainModule.deploy(factory.address, startupWalletImpl.address, immutableSigner.address)
2832

2933
await latestWalletImplLocator.changeWalletImplementation(mainModuleV1.address)
3034

@@ -41,7 +45,8 @@ describe('Wallet Factory', function () {
4145
mainModuleV1,
4246
startupWalletImpl,
4347
salt,
44-
latestWalletImplLocator
48+
latestWalletImplLocator,
49+
immutableSigner
4550

4651
}
4752
}
@@ -132,7 +137,7 @@ describe('Wallet Factory', function () {
132137

133138

134139
it('Should be able to upgrade implementation contracts', async function () {
135-
const { factory, startupWalletImpl } = await loadFixture(setupStartupFixture)
140+
const { factory, startupWalletImpl, immutableSigner } = await loadFixture(setupStartupFixture)
136141

137142
const acc = ethers.Wallet.createRandom()
138143
const salt = encodeImageHash(1, [{ weight: 1, address: acc.address }])
@@ -151,7 +156,7 @@ describe('Wallet Factory', function () {
151156

152157
//console.log("Deploy MainModuleMockV2")
153158
const MainModuleV2 = await ethers.getContractFactory('MainModuleMockV2')
154-
const mainModuleV2 = await MainModuleV2.deploy(factory.address, startupWalletImpl.address)
159+
const mainModuleV2 = await MainModuleV2.deploy(factory.address, startupWalletImpl.address, immutableSigner.address)
155160

156161
// console.log("Upgrade wallet proxy to using MainModuleMockV2")
157162
const networkId = (await ethers.provider.getNetwork()).chainId
@@ -201,10 +206,10 @@ describe('Wallet Factory', function () {
201206

202207

203208
it('Deploying using upgrade should work', async function () {
204-
const { factory, startupWalletImpl, latestWalletImplLocator } = await loadFixture(setupStartupFixture)
209+
const { factory, startupWalletImpl, latestWalletImplLocator, immutableSigner } = await loadFixture(setupStartupFixture)
205210

206211
const MainModuleV2 = await ethers.getContractFactory('MainModuleMockV2')
207-
const mainModuleV2 = await MainModuleV2.deploy(factory.address, startupWalletImpl.address)
212+
const mainModuleV2 = await MainModuleV2.deploy(factory.address, startupWalletImpl.address, immutableSigner.address)
208213

209214
await latestWalletImplLocator.changeWalletImplementation(mainModuleV2.address)
210215

0 commit comments

Comments
 (0)