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

[r/boards] [meta] tests #3623

Open
6 of 19 tasks
salmad3 opened this issue Jan 28, 2025 · 1 comment
Open
6 of 19 tasks

[r/boards] [meta] tests #3623

salmad3 opened this issue Jan 28, 2025 · 1 comment
Assignees

Comments

@salmad3
Copy link
Member

salmad3 commented Jan 28, 2025

Context:

This META issue tracks filetest coverage for all publicly callable methods in the boards realm.

Each checkbox corresponds to creating filetests (or updating existing ones) that thoroughly cover that function’s logic and edge cases.

render.gno:

  • Render(path string) string
    • Boards Listing
      • Empty boards (0 boards) → shows “no items.”
      • Bulk boards (50+) → verify pagination with ?page=...; test out-of-bounds pages.
    • Board View
      • Check hidden threads do not appear or appear flagged.
      • Invalid board name or unknown board → error message.
    • Thread View
      • If thread is hidden, show “Thread has been flagged…”
      • Large threads (100+ posts) → pagination.
    • Reply View
      • Display hidden replies as flagged, but child replies still visible.
      • Non-existent reply → error message.

public.gno:

  • GetBoardIDFromName(name string) (BoardID, bool)

    • Checks name collisions vs. existing boards (Naming → duplicates).
    • If board does not exist, returns false.
    • Possibly ensure “board name = user name” scenario is handled (Naming → user realm conflict).
  • CreateBoard(name string) BoardID @jeronimoalbi

    • Permissions: Must have board:create. Unauthorized → panic.
    • Naming: Duplicate names → “board already exists.” <6 chars → panic, address-like → panic, user realm conflict → panic.
    • Load: Creating 50+ boards to confirm listing/pagination.
  • RenameBoard(name, newName string) @jeronimoalbi

    • Permissions: Must have rename permission (WithPermission).
    • Existing: If newName used, panic “board already exists.”
    • Address/Short: If <6 chars or address-like → panic.
    • Aliases: Confirm repeated renames (A→B, B→C).
  • FlagThread(bid BoardID, postID PostID, reason string)

    • Permissions: Must have thread:flag.
    • Single-Flag: If threshold=1, hides immediately; second flag → “already flagged.”
    • Multiple-Flags: If threshold>1, final flag hides.
    • Already Hidden: Additional flags may panic or do nothing.
    • Unauthorized: Must panic if lacking thread:flag.
  • CreateThread(bid BoardID, title, body string) PostID

    • Permissions: Must have thread:create.
    • Board Existence: If board missing, fail.
    • Private Board: Non-member fails if invite-only.
    • Body: Large/empty body check.
    • Load: Test 100+ threads, confirm render pagination.
  • CreateReply(bid BoardID, threadID, replyID PostID, body string) PostID

    • Permissions: Possibly thread:create or any member.
    • Hidden Thread: Must fail “thread was hidden.”
    • Nested: If replyID != threadID, replying to another reply.
    • Unauthorized: If private board, non-member fails.
  • FlagReply(bid BoardID, threadID, replyID PostID, reason string)

    • Permissions: Need reply:flag.
    • Threshold: Single/multi-flag hide.
    • Already Hidden: Additional flags → panic/do nothing.
    • Reply Existence: If missing, fail.
  • CreateRepost(bid BoardID, threadID PostID, title, body string, dstBoardID BoardID) PostID

    • Permissions: Need thread:repost.
    • Hidden Thread: If original hidden, fail “flagged.”
    • Private Board: Must be a member if private.
    • Cross-Board: Check repost counters, possible chain A→B→C.
  • DeleteThread(bid BoardID, threadID PostID)

    • Permissions: thread:delete.
    • Nonexistent: “thread does not exist.”
    • Hidden: If already hidden, do we allow a “hard delete”?
    • Replies: Removing all replies or blocked?
  • DeleteReply(bid BoardID, threadID, replyID PostID)

    • Permissions: reply:delete.
    • Nonexistent: “reply not found: X.”
    • Nested: If it has children, block or cascade?
  • EditThread(bid BoardID, threadID PostID, title, body string)

    • Permissions: thread:edit or thread owner.
    • Hidden: If hidden, do we allow editing?
    • Large/Empty: Confirm no meltdown.
  • EditReply(bid BoardID, threadID, replyID PostID, title, body string)

    • Creator vs. Admin: Only original author or an admin?
    • Hidden: If reply hidden, typically no edit.
    • Large/Empty: Similar checks.
  • InviteMember(bid BoardID, user std.Address, role Role) @jeronimoalbi

    • Permissions: member:invite; unauthorized → panic.
    • Double Invite: “user already exists.”
    • Invite as Owner: Possibly restricted to owners only.
  • RemoveMember(bid BoardID, user std.Address) @jeronimoalbi

    • Permissions: member:remove.
    • Remove Owner: If last owner, disallowed?
    • Nonexistent: “member not found.”
  • HasMemberRole(bid BoardID, member std.Address, role Role) bool @jeronimoalbi

    • Basic checks: returns false if user missing.
    • Unknown role → false.
    • Possibly test multiple roles or superRole.
  • ChangeMemberRole(bid BoardID, member std.Address, role Role) @jeronimoalbi

    • Permissions: role:change.
    • Admin → Owner or removing last owner, confirm rules.

Cross-Cutting Scenarios (Concurrency, Fuzzing, Load):

Some scenarios apply globally across multiple functions:

  • Load & Stress
    • Bulk creation of boards/threads/replies.
    • High concurrency or rapid calls (e.g., multiple invites, multiple flags).
  • Fuzz & Random
    • Provide random inputs for board names, addresses, roles. Catch partial states or unexpected panics.

We can incorporate these into existing filetests (for example, a filetest that tries to create 1,000 threads or random board names), or separate them out if that’s simpler.

Notes:

  • Some testing already exists.
  • We will keep this issue open until every function is fully tested. Please add any newly introduced public methods here as well, so we track them from the start.
@salmad3
Copy link
Member Author

salmad3 commented Jan 28, 2025

@jeronimoalbi @x1unix you can add your name beside the functions in issue description.

jeronimoalbi added a commit that referenced this issue Jan 28, 2025
Add a missing filetests for `CreateBoard()` function.

Related to #3623 

This covers all tests for the function:
- Creation success
- Fail w/ empty board name
- Fail w/ existing board name
- Fail w/ non user call
- Fail w/ an address as board name
- Fail because name is registered and not owned in `users` realm
- Fail w/ short name
- Creation success with owned name registered in `users` realm
- Fail for non realm DAO member
jeronimoalbi added a commit that referenced this issue Jan 28, 2025
Add a missing filetests for `RenameBoard()` function.

Related to #3623.

This covers all tests for the function:
- Rename success by default board owner
- Fail w/ empty board name
- Fail w/ existing board name
- Fail when renaming unexisting board
- Fail w/ an address as board name
- Rename success by another board owner
- Fail because name is registered and not owned in `users` realm
- Fail w/ short name
- Rename success with owned name registered in `users` realm
- Fail for non board DAO member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Triage
Development

No branches or pull requests

2 participants