From 2476e06f9728491839ab0990aa412431346ae51e Mon Sep 17 00:00:00 2001 From: lumtis Date: Tue, 5 Mar 2024 19:06:54 +0100 Subject: [PATCH] add more tests --- x/authority/keeper/policies_test.go | 5 +++++ x/observer/migrations/v7/migrate_test.go | 28 ++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/x/authority/keeper/policies_test.go b/x/authority/keeper/policies_test.go index 527278435c..13c0c4d80b 100644 --- a/x/authority/keeper/policies_test.go +++ b/x/authority/keeper/policies_test.go @@ -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) diff --git a/x/observer/migrations/v7/migrate_test.go b/x/observer/migrations/v7/migrate_test.go index 39b56bcf22..d0379ece3e 100644 --- a/x/observer/migrations/v7/migrate_test.go +++ b/x/observer/migrations/v7/migrate_test.go @@ -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)