Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis committed Mar 5, 2024
1 parent 1f8c17b commit 2476e06
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
5 changes: 5 additions & 0 deletions x/authority/keeper/policies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ func TestKeeper_SetPolicies(t *testing.T) {

func TestKeeper_IsAuthorized(t *testing.T) {
k, ctx := keepertest.AuthorityKeeper(t)

// Not authorized if no policies
require.False(t, k.IsAuthorized(ctx, sample.AccAddress(), types.PolicyType_groupAdmin))
require.False(t, k.IsAuthorized(ctx, sample.AccAddress(), types.PolicyType_groupEmergency))

policies := sample.Policies()
k.SetPolicies(ctx, policies)

Expand Down
28 changes: 28 additions & 0 deletions x/observer/migrations/v7/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,34 @@ import (
"github.com/zeta-chain/zetacore/x/observer/types"
)

func TestMigrateStore(t *testing.T) {
t.Run("Migrate store from v6 to v7", func(t *testing.T) {
k, ctx, _, _ := keepertest.ObserverKeeper(t)

addr1 := sample.AccAddress()
addr2 := sample.AccAddress()

k.SetParams(ctx, types.Params{
AdminPolicy: []*types.Admin_Policy{
{
PolicyType: types.Policy_Type_group1,
Address: addr1,
},
{
PolicyType: types.Policy_Type_group2,
Address: addr2,
},
},
})

// Migrate store
err := v7.MigrateStore(ctx, k)

// Check if store is migrated
require.NoError(t, err)
})
}

func TestMigratePolicies(t *testing.T) {
t.Run("Migrate policies from observer to authority with 2 types", func(t *testing.T) {
k, ctx, _, zk := keepertest.ObserverKeeper(t)
Expand Down

0 comments on commit 2476e06

Please sign in to comment.