diff --git a/examples/gno.land/r/nt/boards2/z_3_a_filetest.gno b/examples/gno.land/r/nt/boards2/z_3_a_filetest.gno index 88812194645..ecfd3e33e06 100644 --- a/examples/gno.land/r/nt/boards2/z_3_a_filetest.gno +++ b/examples/gno.land/r/nt/boards2/z_3_a_filetest.gno @@ -7,26 +7,25 @@ import ( ) const ( - owner = std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // @test1 - name = "foo123" + owner = std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // @test1 + name = "foo123" + newName = "bar123" ) +var bid boards2.BoardID // Operate on board DAO + func init() { std.TestSetOrigCaller(owner) - boards2.CreateBoard(name) + bid = boards2.CreateBoard(name) } func main() { - newName := "bar123" - _, exists := boards2.GetBoardIDFromName(newName) - println("Exists =", exists) - boards2.RenameBoard(name, newName) - bid, _ := boards2.GetBoardIDFromName(newName) - println("ID =", bid) + // Ensure board is renamed by the default board owner + bid2, _ := boards2.GetBoardIDFromName(newName) + println("IDs match =", bid == bid2) } // Output: -// Exists = false -// ID = 1 +// IDs match = true diff --git a/examples/gno.land/r/nt/boards2/z_3_f_filetest.gno b/examples/gno.land/r/nt/boards2/z_3_f_filetest.gno index f910c630d37..b4f9d07a04b 100644 --- a/examples/gno.land/r/nt/boards2/z_3_f_filetest.gno +++ b/examples/gno.land/r/nt/boards2/z_3_f_filetest.gno @@ -12,33 +12,31 @@ import ( const ( owner = std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // @test1 member = std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") // @test2 - bid = boards2.BoardID(0) // Operate on realm DAO members instead of individual boards name = "foo123" newName = "barbaz" ) +var bid boards2.BoardID // Operate on board DAO + func init() { std.TestSetOrigCaller(owner) + bid = boards2.CreateBoard(name) + boards2.InviteMember(bid, member, boards2.RoleOwner) + // Test1 is the boards owner and its address has a user already registered // so a new member must register a user with the new board name. - boards2.InviteMember(bid, member, boards2.RoleOwner) std.TestSetOrigCaller(member) users.Register("", newName, "") - - boards2.CreateBoard(name) } func main() { - _, exists := boards2.GetBoardIDFromName(newName) - println("Exists =", exists) - boards2.RenameBoard(name, newName) - bid, _ := boards2.GetBoardIDFromName(newName) - println("ID =", bid) + // Ensure board is renamed by another board owner + bid2, _ := boards2.GetBoardIDFromName(newName) + println("IDs match =", bid == bid2) } // Output: -// Exists = false -// ID = 1 +// IDs match = true diff --git a/examples/gno.land/r/nt/boards2/z_3_g_filetest.gno b/examples/gno.land/r/nt/boards2/z_3_g_filetest.gno index f4ee3c34741..0c127148b81 100644 --- a/examples/gno.land/r/nt/boards2/z_3_g_filetest.gno +++ b/examples/gno.land/r/nt/boards2/z_3_g_filetest.gno @@ -13,35 +13,30 @@ const ( owner = std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // @test1 member = std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") // @test2 member2 = std.Address("g1vh7krmmzfua5xjmkatvmx09z37w34lsvd2mxa5") - bid = boards2.BoardID(0) // Operate on realm DAO members instead of individual boards name = "foo123" newName = "barbaz" ) +var bid boards2.BoardID // Operate on board DAO + func init() { std.TestSetOrigCaller(owner) + bid = boards2.CreateBoard(name) + boards2.InviteMember(bid, member, boards2.RoleOwner) + // Test1 is the boards owner and its address has a user already registered // so a new member must register a user with the new board name. - boards2.InviteMember(bid, member, boards2.RoleOwner) std.TestSetOrigCaller(member) users.Register("", newName, "") // Invite a new member that doesn't own the user that matches the new board name boards2.InviteMember(bid, member2, boards2.RoleOwner) std.TestSetOrigCaller(member2) - - boards2.CreateBoard(name) } func main() { - _, exists := boards2.GetBoardIDFromName(newName) - println("Exists =", exists) - boards2.RenameBoard(name, newName) - - bid, _ := boards2.GetBoardIDFromName(newName) - println("ID =", bid) } // Error: diff --git a/examples/gno.land/r/nt/boards2/z_3_h_filetest.gno b/examples/gno.land/r/nt/boards2/z_3_h_filetest.gno new file mode 100644 index 00000000000..36d66e682ca --- /dev/null +++ b/examples/gno.land/r/nt/boards2/z_3_h_filetest.gno @@ -0,0 +1,24 @@ +package main + +import ( + "std" + + "gno.land/r/nt/boards2" +) + +const ( + owner = std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // @test1 + name = "foo123" +) + +func init() { + std.TestSetOrigCaller(owner) + boards2.CreateBoard(name) +} + +func main() { + boards2.RenameBoard(name, "short") +} + +// Error: +// the minimum allowed board name length is 6 characters diff --git a/examples/gno.land/r/nt/boards2/z_3_i_filetest.gno b/examples/gno.land/r/nt/boards2/z_3_i_filetest.gno new file mode 100644 index 00000000000..0c127148b81 --- /dev/null +++ b/examples/gno.land/r/nt/boards2/z_3_i_filetest.gno @@ -0,0 +1,43 @@ +package main + +// SEND: 200000000ugnot + +import ( + "std" + + "gno.land/r/demo/users" + "gno.land/r/nt/boards2" +) + +const ( + owner = std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // @test1 + member = std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") // @test2 + member2 = std.Address("g1vh7krmmzfua5xjmkatvmx09z37w34lsvd2mxa5") + name = "foo123" + newName = "barbaz" +) + +var bid boards2.BoardID // Operate on board DAO + +func init() { + std.TestSetOrigCaller(owner) + + bid = boards2.CreateBoard(name) + boards2.InviteMember(bid, member, boards2.RoleOwner) + + // Test1 is the boards owner and its address has a user already registered + // so a new member must register a user with the new board name. + std.TestSetOrigCaller(member) + users.Register("", newName, "") + + // Invite a new member that doesn't own the user that matches the new board name + boards2.InviteMember(bid, member2, boards2.RoleOwner) + std.TestSetOrigCaller(member2) +} + +func main() { + boards2.RenameBoard(name, newName) +} + +// Error: +// board name is a user name registered to a different user diff --git a/examples/gno.land/r/nt/boards2/z_3_j_filetest.gno b/examples/gno.land/r/nt/boards2/z_3_j_filetest.gno new file mode 100644 index 00000000000..309b029e593 --- /dev/null +++ b/examples/gno.land/r/nt/boards2/z_3_j_filetest.gno @@ -0,0 +1,27 @@ +package main + +import ( + "std" + + "gno.land/r/nt/boards2" +) + +const ( + owner = std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // @test1 + user = std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") // @test2 + name = "foo123" +) + +func init() { + std.TestSetOrigCaller(owner) + boards2.CreateBoard(name) + + std.TestSetOrigCaller(user) +} + +func main() { + boards2.RenameBoard(name, "barbaz") +} + +// Error: +// unauthorized