Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add missing filetest for member role change
Browse files Browse the repository at this point in the history
jeronimoalbi committed Jan 29, 2025
1 parent 33fb889 commit 671b860
Showing 6 changed files with 47 additions and 38 deletions.
21 changes: 7 additions & 14 deletions examples/gno.land/r/nt/boards2/z_4_a_filetest.gno
Original file line number Diff line number Diff line change
@@ -7,11 +7,10 @@ import (
)

const (
owner = std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // @test1
member = std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") // @test2
initialRole = boards2.RoleGuest
newRole = boards2.RoleAdmin
bid = boards2.BoardID(0) // Operate on realm DAO members instead of individual boards
owner = std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // @test1
member = std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") // @test2
newRole = boards2.RoleAdmin
bid = boards2.BoardID(0) // Operate on realm DAO instead of individual boards
)

func init() {
@@ -20,17 +19,11 @@ func init() {
}

func main() {
if boards2.HasMemberRole(bid, member, initialRole) {
println("ok")
}

boards2.ChangeMemberRole(bid, member, newRole)

if boards2.HasMemberRole(bid, member, newRole) {
println("ok")
}
// Ensure that new role has been changed
println(boards2.HasMemberRole(bid, member, newRole))
}

// Output:
// ok
// ok
// true
23 changes: 8 additions & 15 deletions examples/gno.land/r/nt/boards2/z_4_b_filetest.gno
Original file line number Diff line number Diff line change
@@ -7,32 +7,25 @@ import (
)

const (
owner = std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // @test1
member = std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") // @test2
initialRole = boards2.RoleGuest
newRole = boards2.RoleAdmin
owner = std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // @test1
member = std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") // @test2
newRole = boards2.RoleAdmin
)

var bid boards2.BoardID
var bid boards2.BoardID // Operate on board DAO

func init() {
std.TestSetOrigCaller(owner)
bid = boards2.CreateBoard("foo123") // Operate on board DAO members
bid = boards2.CreateBoard("foo123")
boards2.InviteMember(bid, member, boards2.RoleGuest)
}

func main() {
if boards2.HasMemberRole(bid, member, initialRole) {
println("ok")
}

boards2.ChangeMemberRole(bid, member, newRole)

if boards2.HasMemberRole(bid, member, newRole) {
println("ok")
}
// Ensure that new role has been changed
println(boards2.HasMemberRole(bid, member, newRole))
}

// Output:
// ok
// ok
// true
2 changes: 1 addition & 1 deletion examples/gno.land/r/nt/boards2/z_4_c_filetest.gno
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ const (
owner = std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // @test1
owner2 = std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") // @test2
admin = std.Address("g1vh7krmmzfua5xjmkatvmx09z37w34lsvd2mxa5")
bid = boards2.BoardID(0) // Operate on realm DAO members instead of individual boards
bid = boards2.BoardID(0) // Operate on realm DAO instead of individual boards
)

func init() {
2 changes: 1 addition & 1 deletion examples/gno.land/r/nt/boards2/z_4_d_filetest.gno
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ const (
owner = std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // @test1
admin = std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") // @test2
admin2 = std.Address("g1vh7krmmzfua5xjmkatvmx09z37w34lsvd2mxa5")
bid = boards2.BoardID(0) // Operate on realm DAO members instead of individual boards
bid = boards2.BoardID(0) // Operate on realm DAO instead of individual boards
)

func init() {
17 changes: 10 additions & 7 deletions examples/gno.land/r/nt/boards2/z_4_e_filetest.gno
Original file line number Diff line number Diff line change
@@ -7,20 +7,23 @@ import (
)

const (
owner = std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // @test1
admin = std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") // @test2
bid = boards2.BoardID(0) // Operate on realm DAO members instead of individual boards
owner = std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // @test1
member = std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") // @test2
bid = boards2.BoardID(0) // Operate on realm DAO members instead of individual boards
newRole = boards2.RoleOwner
)

func init() {
std.TestSetOrigCaller(owner)
boards2.InviteMember(bid, admin, boards2.RoleAdmin)
boards2.InviteMember(bid, member, boards2.RoleAdmin)
}

func main() {
boards2.ChangeMemberRole(bid, admin, boards2.RoleOwner) // Owner can promote other members to Owner
println("ok")
boards2.ChangeMemberRole(bid, member, newRole) // Owner can promote other members to Owner

// Ensure that new role has been changed to owner
println(boards2.HasMemberRole(bid, member, newRole))
}

// Output:
// ok
// true
20 changes: 20 additions & 0 deletions examples/gno.land/r/nt/boards2/z_4_h_filetest.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package main

import (
"std"

"gno.land/r/nt/boards2"
)

const owner = std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") // @test2

func init() {
std.TestSetOrigCaller(owner)
}

func main() {
boards2.ChangeMemberRole(0, "g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj", boards2.RoleGuest)
}

// Error:
// unauthorized

0 comments on commit 671b860

Please sign in to comment.