Skip to content

Commit

Permalink
[#312] Add unit test for SafeWebAuthnSignerProxy
Browse files Browse the repository at this point in the history
  • Loading branch information
akshay-ap committed Apr 11, 2024
1 parent a016b8a commit f033351
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,28 @@ describe('SafeWebAuthnSignerProxy', () => {
return { x, y, mockVerifier, signer }
})

describe('forward call', function () {
it('Should forward call to singleton with additional information', async () => {
const { x, y, mockVerifier } = await setupTests()
const [sender] = await ethers.getSigners()
const mockSingleton = await ethers.getContractAt('MockContract', await (await ethers.getContractFactory('MockContract')).deploy())

const signerProxy = await ethers.getContractAt(
'MockContract',
await (await ethers.getContractFactory('SafeWebAuthnSignerProxy')).deploy(mockSingleton, x, y, mockVerifier),
)

const callData = ethers.hexlify(ethers.randomBytes(36))
await signerProxy.givenAnyReturnBool(true)

await sender.sendTransaction({ to: signerProxy.target, value: 0, data: callData })

expect(await signerProxy.invocationCount()).to.equal(1)
const data = ethers.solidityPacked(['bytes', 'uint256', 'uint256', 'address'], [callData, x, y, mockVerifier.target])
expect(await signerProxy.invocationCountForCalldata(data)).to.equal(1)
})
})

describe('constructor', function () {
it('Should set immutables', async () => {
const { x, y, mockVerifier, signer } = await setupTests()
Expand Down

0 comments on commit f033351

Please sign in to comment.