-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from initia-labs/feat/allowed-publishers
feat: add allowed_publishers params
- Loading branch information
Showing
29 changed files
with
366 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package keeper_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/initia-labs/initia/x/move/keeper" | ||
"github.com/initia-labs/initia/x/move/types" | ||
vmtypes "github.com/initia-labs/initiavm/types" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func Test_CodeKeeper_GetParams(t *testing.T) { | ||
ctx, input := createDefaultTestInput(t) | ||
|
||
allowArbitrary, allowedPublishers, err := keeper.NewCodeKeeper(&input.MoveKeeper).GetParams(ctx) | ||
require.NoError(t, err) | ||
require.Equal(t, types.DefaultArbitraryEnabled, allowArbitrary) | ||
require.Empty(t, allowedPublishers) | ||
} | ||
|
||
func Test_CodeKeeper_SetParams(t *testing.T) { | ||
ctx, input := createDefaultTestInput(t) | ||
codeKeeper := keeper.NewCodeKeeper(&input.MoveKeeper) | ||
|
||
err := codeKeeper.SetAllowArbitrary(ctx, false) | ||
require.NoError(t, err) | ||
|
||
err = codeKeeper.SetAllowedPublishers(ctx, []vmtypes.AccountAddress{vmtypes.StdAddress, vmtypes.TestAddress}) | ||
require.NoError(t, err) | ||
|
||
allowArbitrary, err := codeKeeper.GetAllowArbitrary(ctx) | ||
require.NoError(t, err) | ||
require.False(t, allowArbitrary) | ||
|
||
allowedPublishers, err := codeKeeper.GetAllowedPublishers(ctx) | ||
require.NoError(t, err) | ||
require.Equal(t, []vmtypes.AccountAddress{vmtypes.StdAddress, vmtypes.TestAddress}, allowedPublishers) | ||
} | ||
|
||
func Test_CodeKeeper_MustContains_StdAddr(t *testing.T) { | ||
ctx, input := createDefaultTestInput(t) | ||
codeKeeper := keeper.NewCodeKeeper(&input.MoveKeeper) | ||
|
||
err := codeKeeper.SetAllowedPublishers(ctx, []vmtypes.AccountAddress{vmtypes.TestAddress}) | ||
require.Error(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.