Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

28 add initial forge test for webauthn verification #52

Merged

Conversation

JohnGuilding
Copy link
Contributor

@JohnGuilding JohnGuilding commented Aug 17, 2023

This PR:

  • Adds intial forge test for Webauthn.sol
  • Adds intial forge test for SafeWebAuthnPlugin.sol
  • Adds TestHelper.sol contract to provide helper functions and abstract common logic
  • Adds a SafeWebAuthnPluginHarness.sol to expose internal functions for testing. This is the recommended way to test internal functions from the foundry docs.

This PR is dependent on #48 Merged

@JohnGuilding JohnGuilding linked an issue Aug 20, 2023 that may be closed by this pull request
@JohnGuilding JohnGuilding marked this pull request as ready for review August 20, 2023 10:05
@JohnGuilding JohnGuilding force-pushed the 28-add-initial-forge-test-for-webauthn-verification branch from f2814d5 to d314bc5 Compare August 21, 2023 17:01
@JohnGuilding JohnGuilding force-pushed the 28-add-initial-forge-test-for-webauthn-verification branch from d314bc5 to 8a2fca9 Compare August 22, 2023 14:22
@JohnGuilding
Copy link
Contributor Author

@jzaki reviewed and happy with the following commits:

Copy link
Contributor

@blakecduncan blakecduncan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor comments but this LGTM!

@@ -0,0 +1,82 @@
// SPDX-License-Identifier: MIT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm I'm inclined to think we may want to put these tests into their own folder. Maybe a unit test folder. Or forge-tests. I don't have a strong opinion but I wonder if we should be more explicit these are different then the other tests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I'm actually leaning towards your second suggestion in your PR. Will update to that:

test/hardhat
test/hardhat/integration
test/forge

@@ -0,0 +1,45 @@
// SPDX-License-Identifier: MIT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will the WebAuthn.sol file eventually live in the primitives directory? I feel like this could be a good fit for that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think so good shout. Issue to do that - #55

];
}

function getUserOpSignature()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this function specific to a userOp that is using a webAuthN signature? It may be worth updating the name to reflect that for clarity

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, updated in follow up

);
}

function getPublicKey()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, if this is a WebAuthN public key it may be worth reflecting that in the name, since we will eventually have different types of public keys

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, updated in follow up

import {SafeWebAuthnPlugin} from "../../src/SafeWebAuthnPlugin.sol";

/** Helper contract to expose internal functions for testing */
contract SafeWebAuthnPluginHarness is SafeWebAuthnPlugin {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@blakecduncan blakecduncan mentioned this pull request Aug 25, 2023
@JohnGuilding JohnGuilding merged commit 4c3274c into main Aug 25, 2023
@JohnGuilding JohnGuilding deleted the 28-add-initial-forge-test-for-webauthn-verification branch August 25, 2023 16:30
@JohnGuilding JohnGuilding mentioned this pull request Aug 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add initial forge test for webauthn verification
3 participants