Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
DeshErBojhaa committed May 2, 2024
1 parent 7b7f851 commit a4b89d1
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- uses: golangci/golangci-lint-action@v3
with:
version: latest
args: --timeout 10m --tests=false --skip-dirs="e2e"
args: --timeout 10m --tests=false --exclude-dirs="e2e"
skip-pkg-cache: true

protobuf:
Expand Down
4 changes: 2 additions & 2 deletions x/randomness/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import (

// InitGenesis puts data from genesis state into store.
func InitGenesis(ctx sdk.Context, k keeper.Keeper, data types.GenesisState) {
err := k.Seeds.Set(ctx, data.Seed)
err := k.Seed.Set(ctx, data.Seed)
if err != nil {
panic(err)
}
}

// ExportGenesis extracts data from store to genesis state.
func ExportGenesis(ctx sdk.Context, k keeper.Keeper) types.GenesisState {
seed, err := k.Seeds.Get(ctx)
seed, err := k.Seed.Get(ctx)
if err != nil {
return types.GenesisState{}
}
Expand Down
9 changes: 9 additions & 0 deletions x/randomness/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ func NewKeeper(cdc codec.BinaryCodec, storeService storetypes.KVStoreService) *K
}
}

// GetSeed returns the seed.
func (k Keeper) GetSeed(ctx sdk.Context) (string, error) {
seed, err := k.Seed.Get(ctx)
if err != nil {
return "", err
}
return seed, nil
}

// GetValidatorVRFPubKey retrieves from the store the VRF public key
// corresponding to the given validator consensus address.
func (k Keeper) GetValidatorVRFPubKey(ctx sdk.Context, consensusAddr string) (cryptotypes.PubKey, error) {
Expand Down
49 changes: 32 additions & 17 deletions x/wasm-storage/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (s *KeeperTestSuite) TestSetDataRequestWasm() {
Bytecode: compWasm,
WasmType: wasmstoragetypes.WasmTypeDataRequest,
}
s.wasmStorageKeeper.SetDataRequestWasm(s.ctx, mockWasm)
s.Require().NoError(s.wasmStorageKeeper.SetDataRequestWasm(s.ctx, mockWasm))
}

func (s *KeeperTestSuite) TestGetDataRequestWasm() {
Expand All @@ -32,7 +32,8 @@ func (s *KeeperTestSuite) TestGetDataRequestWasm() {
Bytecode: mockedByteArray,
WasmType: wasmstoragetypes.WasmTypeDataRequest,
}
s.wasmStorageKeeper.SetDataRequestWasm(s.ctx, mockWasm)
err := s.wasmStorageKeeper.SetDataRequestWasm(s.ctx, mockWasm)
s.Require().NoError(err)
value, _ := s.wasmStorageKeeper.GetDataRequestWasm(s.ctx, mockWasm.Hash)
s.Assert().NotNil(value)
s.Assert().Equal(*mockWasm, *value)
Expand All @@ -47,7 +48,8 @@ func (s *KeeperTestSuite) TestHasDataRequestWasm() {
}
has, _ := s.wasmStorageKeeper.HasDataRequestWasm(s.ctx, mockWasm)
s.Assert().False(has)
s.wasmStorageKeeper.SetDataRequestWasm(s.ctx, mockWasm)
err := s.wasmStorageKeeper.SetDataRequestWasm(s.ctx, mockWasm)
s.Require().NoError(err)
has, _ = s.wasmStorageKeeper.HasDataRequestWasm(s.ctx, mockWasm)
s.Assert().True(has)
}
Expand All @@ -59,7 +61,7 @@ func (s *KeeperTestSuite) TestSetOverlayWasm() {
Bytecode: mockedByteArray,
WasmType: wasmstoragetypes.WasmTypeRelayer,
}
s.wasmStorageKeeper.SetOverlayWasm(s.ctx, mockWasm)
s.Require().NoError(s.wasmStorageKeeper.SetOverlayWasm(s.ctx, mockWasm))
}

func (s *KeeperTestSuite) TestGetOverlayWasm() {
Expand All @@ -69,7 +71,8 @@ func (s *KeeperTestSuite) TestGetOverlayWasm() {
Bytecode: mockedByteArray,
WasmType: wasmstoragetypes.WasmTypeRelayer,
}
s.wasmStorageKeeper.SetOverlayWasm(s.ctx, mockWasm)
err := s.wasmStorageKeeper.SetOverlayWasm(s.ctx, mockWasm)
s.Require().NoError(err)
value, _ := s.wasmStorageKeeper.GetOverlayWasm(s.ctx, mockWasm.Hash)
s.Assert().NotNil(value)
s.Assert().Equal(*mockWasm, *value)
Expand All @@ -84,7 +87,8 @@ func (s *KeeperTestSuite) TestHasOverlayWasm() {
}
has, _ := s.wasmStorageKeeper.HasOverlayWasm(s.ctx, mockWasm)
s.Assert().False(has)
s.wasmStorageKeeper.SetOverlayWasm(s.ctx, mockWasm)
err := s.wasmStorageKeeper.SetOverlayWasm(s.ctx, mockWasm)
s.Require().NoError(err)
has, _ = s.wasmStorageKeeper.HasOverlayWasm(s.ctx, mockWasm)
s.Assert().True(has)
}
Expand All @@ -102,12 +106,15 @@ func (s *KeeperTestSuite) TestIterateAllDataRequestWasm() {
WasmType: wasmstoragetypes.WasmTypeDataRequest,
}

s.wasmStorageKeeper.SetDataRequestWasm(s.ctx, mockWasm1)
s.wasmStorageKeeper.SetDataRequestWasm(s.ctx, mockWasm2)
s.wasmStorageKeeper.IterateAllDataRequestWasms(s.ctx, func(wasm wasmstoragetypes.Wasm) (stop bool) {
err := s.wasmStorageKeeper.SetDataRequestWasm(s.ctx, mockWasm1)
s.Require().NoError(err)
err = s.wasmStorageKeeper.SetDataRequestWasm(s.ctx, mockWasm2)
s.Require().NoError(err)
err = s.wasmStorageKeeper.IterateAllDataRequestWasms(s.ctx, func(wasm wasmstoragetypes.Wasm) (stop bool) {
s.Assert().Equal(wasmstoragetypes.WasmTypeDataRequest, wasm.GetWasmType())
return true
})
s.Require().NoError(err)
}

func (s *KeeperTestSuite) TestListDateRequestWasm() {
Expand All @@ -123,8 +130,10 @@ func (s *KeeperTestSuite) TestListDateRequestWasm() {
WasmType: wasmstoragetypes.WasmTypeDataRequest,
}

s.wasmStorageKeeper.SetDataRequestWasm(s.ctx, mockWasm1)
s.wasmStorageKeeper.SetDataRequestWasm(s.ctx, mockWasm2)
err := s.wasmStorageKeeper.SetDataRequestWasm(s.ctx, mockWasm1)
s.Require().NoError(err)
err = s.wasmStorageKeeper.SetDataRequestWasm(s.ctx, mockWasm2)
s.Require().NoError(err)
result := s.wasmStorageKeeper.ListDataRequestWasms(s.ctx)
s.Assert().Equal(2, len(result))
s.Assert().Equal(hex.EncodeToString(mockWasm1.Hash)+","+mockWasm1.WasmType.String(), result[0])
Expand All @@ -144,8 +153,10 @@ func (s *KeeperTestSuite) TestListOverlayWasm() {
WasmType: wasmstoragetypes.WasmTypeRelayer,
}

s.wasmStorageKeeper.SetOverlayWasm(s.ctx, mockWasm1)
s.wasmStorageKeeper.SetOverlayWasm(s.ctx, mockWasm2)
err := s.wasmStorageKeeper.SetOverlayWasm(s.ctx, mockWasm1)
s.Require().NoError(err)
err = s.wasmStorageKeeper.SetOverlayWasm(s.ctx, mockWasm2)
s.Require().NoError(err)
result := s.wasmStorageKeeper.ListOverlayWasms(s.ctx)
s.Assert().Equal(2, len(result))
s.Assert().Equal(hex.EncodeToString(mockWasm1.Hash)+","+mockWasm1.WasmType.String(), result[0])
Expand All @@ -165,8 +176,10 @@ func (s *KeeperTestSuite) TestGetAllWasms() {
WasmType: wasmstoragetypes.WasmTypeDataRequest,
}

s.wasmStorageKeeper.SetDataRequestWasm(s.ctx, mockWasm1)
s.wasmStorageKeeper.SetDataRequestWasm(s.ctx, mockWasm2)
err := s.wasmStorageKeeper.SetDataRequestWasm(s.ctx, mockWasm1)
s.Require().NoError(err)
err = s.wasmStorageKeeper.SetDataRequestWasm(s.ctx, mockWasm2)
s.Require().NoError(err)

mockWasmO1 := &wasmstoragetypes.Wasm{
Hash: mockedByteArray,
Expand All @@ -179,8 +192,10 @@ func (s *KeeperTestSuite) TestGetAllWasms() {
WasmType: wasmstoragetypes.WasmTypeRelayer,
}

s.wasmStorageKeeper.SetOverlayWasm(s.ctx, mockWasmO1)
s.wasmStorageKeeper.SetOverlayWasm(s.ctx, mockWasmO2)
err = s.wasmStorageKeeper.SetOverlayWasm(s.ctx, mockWasmO1)
s.Require().NoError(err)
err = s.wasmStorageKeeper.SetOverlayWasm(s.ctx, mockWasmO2)
s.Require().NoError(err)

result := s.wasmStorageKeeper.GetAllWasms(s.ctx)
s.Assert().Equal(4, len(result))
Expand Down

0 comments on commit a4b89d1

Please sign in to comment.