Skip to content

Commit

Permalink
test: function register
Browse files Browse the repository at this point in the history
  • Loading branch information
notJoon committed Jan 6, 2025
1 parent 020c101 commit d8d6e7f
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions gov/governance/fn_registry_test.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package governance

import (
"testing"

"gno.land/r/gnoswap/v1/consts"
)

func TestCreateParameterHandlers(t *testing.T) {
registry := createParameterHandlers()

if registry == nil {
t.Fatal("registry is nil")
}

tests := []struct {
name string
path string
function string
params []string
wantErr bool
}{
{
name: "invalid params",
path: consts.COMMON_PATH,
function: "SetHalt",
params: []string{},
wantErr: true,
},
{
name: "Router SetSwapFee: Pass",
path: consts.ROUTER_PATH,
function: "SetSwapFee",
params: []string{"1000"},
wantErr: false,
},
{
name: "set deposit gns amount",
path: consts.STAKER_PATH,
function: "SetDepositGnsAmount",
params: []string{"1000"},
wantErr: false,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
handler, _ := registry.Get(tt.path, tt.function)

err := handler(tt.params)
if (err != nil) != tt.wantErr {
t.Errorf("unexpected error: %v", err)
}
})
}
}

0 comments on commit d8d6e7f

Please sign in to comment.