r4bbit b232346f7e
fix: reset featured community index when necessary
The `setFeaturedCommunities()` function in `Directory` contract
overrides the entire list of previously featured communities by design.

However, it does not reset the `featuredCommunitiesIdx` map which
results in the `isCommunityFeatured()` function to return false
positives.

This commit resets the map accordingly and adds assertions to the
existing tests for overriding featured communities.

Things to note:

- The bug being fixed is rather low-severity, but I think we should
  still ensure correctness of all contract functions
- The change will increase gas costs of `setFeaturedCommunities()`, but
  again, I think this fix should still land for correctness-sake

Here are some GAS profiles for `setFeaturedCommunities`

```
| contracts/Directory.sol:Directory contract              |                 |       |        |         |         |
|---------------------------------------------------------|-----------------|-------|--------|---------|---------|
| Deployment Cost                                         | Deployment Size |       |        |         |         |
| 753957                                                  | 3797            |       |        |         |         |
| Function Name                                           | min             | avg   | median | max     | # calls |
|---------------------------------------------------------|-----------------|-------|--------|---------|---------|
|                                                         |                 |       |        |         |         |
| COMMUNITY COUNT: 1                                      |                 |       |        |         |         |
| setFeaturedCommunities (INIT, IDX RESET: NO)            | 71162           | 71162 | 71162  | 71162   | 1       |
| setFeaturedCommunities (INIT, IDX RESET: YES)           | 71294           | 71294 | 71294  | 71294   | 1       |
| setFeaturedCommunities (OVERRIDE, IDX RESET: NO)        | 52476           | 61819 | 61819  | 71162   | 2       |
| setFeaturedCommunities (OVERRIDE, IDX RESET: YES)       | 53348           | 62321 | 62321  | 71294   | 2       |
|                                                         |                 |       |        |         |         |
| COMMUNITY COUNT: 3                                      |                 |       |        |         |         |
| setFeaturedCommunities (INIT, IDX RESET: NO)            | 163640          | 163640 | 163640 | 163640 | 1       |
| setFeaturedCommunities (INIT, IDX RESET: YES)           | 163772          | 163772 | 163772 | 163772 | 1       |
| setFeaturedCommunities (OVERRIDE, IDX RESET: NO)        | 106352          | 134996 | 134996 | 163640 | 2       |
| setFeaturedCommunities (OVERRIDE, IDX RESET: YES)       | 126354          | 145063 | 145063 | 163772 | 2       |
|                                                         |                 |        |        |        |         |
| COMMUNITY COUNT: 5                                      |                 |        |        |        |         |
| setFeaturedCommunities (INIT, IDX RESET: NO)            | 256118          | 256118 | 256118 | 256118 | 1       |
| setFeaturedCommunities (INIT, IDX RESET: YES)           | 256250          | 256250 | 256250 | 256250 | 1       |
| setFeaturedCommunities (OVERRIDE, IDX RESET: NO)        | 195427          | 225772 | 225772 | 256118 | 2       |
| setFeaturedCommunities (OVERRIDE, IDX RESET: YES)       | 199360          | 227805 | 227805 | 256250 | 2       |
```
2023-05-16 09:41:38 +02:00
..
2023-05-12 11:50:59 +02:00