farcasterxyz / contracts

Implementation of the Farcaster contracts
https://www.farcaster.xyz/
MIT License
340 stars 122 forks source link

fix: use explicit owner address everywhere #278

Closed horsefacts closed 1 year ago

horsefacts commented 1 year ago

Motivation

In the current TestSuiteSetup contract, we assign address(this) (i.e. the test contract address) as owner and use this value throughout the tests. Since the test contract is the owner, we don't need to use vm.prank to make authenticated calls.

This is convenient, but it makes it harder to test that ownership is configured correctly. In practice the owner will not be the deployer: since we'll be deploying contracts using a CREATE2 factory, we want to transfer ownership to an explicit address at construction time. If the test contract itself is set as the owner, it's difficult to tell whether we're relying on the default behavior of Ownable or transferring ownership correctly. (And in fact, in IdRegistry, we weren't transferring ownership to the _owner arg in the constructor, see #280 ).

Change Summary

Generate an explicit address for owner using makeAddr and use it throughout the tests. Replace admin with owner in key registry and resolver tests.

Merge Checklist

Choose all relevant options below by adding an x now or at any time before submitting for review

Additional Context

Fixes unused _owner argument in IdRegistry constructor.

Close #280


PR-Codex overview

Focus of this PR:

This PR focuses on making changes to several contracts and tests related to the IdRegistry, FnameResolver, and Bundler functionality.

Detailed summary:

The following files were skipped due to too many changes: test/Bundler/Bundler.t.sol, test/KeyRegistry/KeyRegistry.t.sol

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

github-actions[bot] commented 1 year ago

Coverage after merging horsefacts/ownership-transfer-cleanup into main will be

98.13%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   Bundler.sol100%100%100%100%
   FnameResolver.sol96.30%75%100%100%122
   IdRegistry.sol100%100%100%100%
   KeyRegistry.sol100%100%100%100%
   StorageRent.sol98.90%98.48%100%98.96%532, 534
src/lib
   TransferHelper.sol0%0%0%0%15, 15, 15, 25–26, 26, 26