Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bugs and add improvements for "build-an-anchor-leaderboard" #367

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions curriculum/locales/english/build-an-anchor-leaderboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ You will be working entirely within the `build-an-anchor-leaderboard/rock-destro
4. The player matching the user account public key should be updated with:
- `score` set to the `u64` argument
- `has_payed` set to `false`
5. If no player matching the user account public key exists and has payed, an Anchor error variant of `PlayerNotFound` should be returned.
5. If no player matching the user account public key exists, an Anchor error variant of `PlayerNotFound` should be returned.
6. If player matching the user account public key exists but has not paid, an Anchor error variant of `PlayerHasNotPaid` should be returned.

**`AddPlayerToLeaderboard`**

Expand Down Expand Up @@ -102,9 +103,13 @@ You will be working entirely within the `build-an-anchor-leaderboard/rock-destro
- Assert a player has a `score` value of `100`
- Assert a player has a `hasPayed` value of `false`

4. There should be an `it` block named `"
4. There should be an `it` block named `"throws an error when the user does not exist"`.

- Assert the `PlayerNotFound` error variant is returned when the `user` account has not payed
- Assert the `PlayerNotFound` error variant is returned when the `user` account is not on the leaderboard

5. There should be an `it` block named `"throws an error when the user has not payed"`.

- Assert the `PlayerHasNotPaid` error variant is returned when the `user` account has not payed

#### Types

Expand Down Expand Up @@ -394,6 +399,19 @@ const callExpressions = babelisedCode
assert.include(callExpressions, 'adds a player to the leaderboard');
```

There should be an `it` block named `"throws an error when the user does not exist"`.

```js
const callExpressions = babelisedCode
.getType('CallExpression')
.filter(c => {
return;
c.callee?.name === 'it';
})
.map(c => c.arguments?.[1]?.value);
assert.include(callExpressions, 'throws an error when the user does not exist');
```

There should be an `it` block named `"throws an error when the user has not payed"`.

```js
Expand Down