PathrockNetwork Gno Explorer
HomeBlocksTransactionsTokensRealmsPackagesValidatorsAnalytics

PathrockNetwork Gno Explorer — an independent explorer for Gno.land Mainnet (gnoland-1), operated by PathrockNetwork. Not an official Gno.land service.

gnowebarchive RPC

gno.land/p/gnoland/boards/v0

Package
Open in gnoweb ↗

Overview

Kind
Pure package
Name
v0
Namespace
gnoland / boards
Files
22 (gnomod.toml)
Exported functions
n/a — not supported for pure packages by the node (vm/qfuncs)
Module
gno.land/p/gnoland/boards/v0
gno
0.9

Files (22)

  • gnomod.tomltoml
  • board.gnogno
  • flag_storage.gnogno
  • id.gnogno
  • permission_set.gnogno
  • permissions.gnogno
  • post_storage.gnogno
  • post.gnogno
  • reply.gnogno
  • repost_storage.gnogno
  • storage.gnogno
  • thread.gnogno
  • board_test.gnogno
  • flag_storage_test.gnogno
  • id_test.gnogno
  • permission_set_test.gnogno
  • post_storage_test.gnogno
  • post_test.gnogno
  • reply_test.gnogno
  • repost_storage_test.gnogno
  • storage_test.gnogno
  • thread_test.gnogno
  • reply_test.gnogno
    1package boards_test23import (4	"testing"56	"gno.land/p/nt/urequire/v0"78	"gno.land/p/gnoland/boards/v0"

    Functions

    not supported for pure packages by the node (vm/qfuncs)

    Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.

    9)
    10
    11func TestNewReply(t *testing.T) {
    12 tests := []struct {
    13 name string
    14 parent func() *boards.Post
    15 creator address
    16 body string
    17 errMsg string
    18 }{
    19 {
    20 name: "ok",
    21 parent: func() *boards.Post {
    22 board := boards.New(1)
    23 id := board.ThreadsSequence.Next()
    24 return &boards.Post{
    25 ID: id,
    26 ThreadID: id,
    27 Board: board,
    28 }
    29 },
    30 creator: "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5",
    31 body: "Foo",
    32 },
    33 {
    34 name: "nil parent",
    35 parent: func() *boards.Post { return nil },
    36 errMsg: "reply requires a parent thread or reply",
    37 },
    38 {
    39 name: "parent without thread ID",
    40 parent: func() *boards.Post {
    41 return &boards.Post{ID: 1}
    42 },
    43 errMsg: "parent has no thread ID assigned",
    44 },
    45 {
    46 name: "parent without board",
    47 parent: func() *boards.Post {
    48 return &boards.Post{ID: 1, ThreadID: 1}
    49 },
    50 errMsg: "parent has no board assigned",
    51 },
    52 {
    53 name: "invalid creator",
    54 parent: func() *boards.Post {
    55 return &boards.Post{ID: 1, ThreadID: 1, Board: boards.New(1)}
    56 },
    57 creator: "foo",
    58 errMsg: "invalid reply creator address: foo",
    59 },
    60 {
    61 name: "empty body",
    62 parent: func() *boards.Post {
    63 return &boards.Post{ID: 1, ThreadID: 1, Board: boards.New(1)}
    64 },
    65 creator: "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5",
    66 body: "",
    67 errMsg: "reply body is required",
    68 },
    69 }
    70
    71 for _, tt := range tests {
    72 t.Run(tt.name, func(t *testing.T) {
    73 parent := tt.parent()
    74
    75 reply, err := boards.NewReply(parent, tt.creator, tt.body)
    76
    77 if tt.errMsg != "" {
    78 urequire.Error(t, err, "expect an error")
    79 urequire.ErrorContains(t, err, tt.errMsg, "expect error to match")
    80 return
    81 }
    82
    83 urequire.NoError(t, err, "expect no error")
    84 urequire.True(t, parent.Board.ThreadsSequence.Last() == reply.ID, "expect ID to match")
    85 urequire.True(t, parent.ID == reply.ParentID, "expect parent ID to match")
    86 urequire.True(t, parent.ThreadID == reply.ThreadID, "expect thread ID to match")
    87 urequire.False(t, reply.Board == nil, "expect board to be assigned")
    88 urequire.True(t, parent.Board.ID == reply.Board.ID, "expect board ID to match")
    89 urequire.Equal(t, tt.body, reply.Body, "expect body to match")
    90 urequire.True(t, reply.Replies != nil, "expect reply to support sub-replies")
    91 urequire.True(t, reply.Flags != nil, "expect reply to support flagging")
    92 urequire.Equal(t, tt.creator, reply.Creator, "expect creator to match")
    93 urequire.False(t, reply.CreatedAt.IsZero(), "expect creation date to be assigned")
    94 })
    95 }
    96}
    97