diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b7f66a79..7fe5313f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -23,9 +23,6 @@ concurrency: jobs: golangci: env: - # for private repo access - GOPRIVATE: github.com/initia-labs - GITHUB_ACCESS_TOKEN: ${{ secrets.GH_READ_TOKEN }} GOLANGCI_LINT_VERSION: v1.59.1 name: golangci-lint runs-on: ubuntu-latest @@ -42,15 +39,15 @@ jobs: **/**.go go.mod go.sum - # for private repo access - - run: git config --global url.https://${GITHUB_ACCESS_TOKEN}:x-oauth-basic@github.com/.insteadOf https://github.com/ # install golangci-lint - - run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION} + - run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@${{ env.GOLANGCI_LINT_VERSION }} - name: run go linters (long) if: env.GIT_DIFF id: lint_long run: | make lint + env: + GIT_DIFF: ${{ env.GIT_DIFF }} - uses: technote-space/get-diff-action@v6.1.2 if: steps.lint_long.outcome == 'skipped' with: @@ -68,10 +65,6 @@ jobs: # Use --check or --exit-code when available (Go 1.19?) # https://github.com/golang/go/issues/27005 tidy: - env: - # for private repo access - GOPRIVATE: github.com/initia-labs,github.com/skip-mev/slinky - GITHUB_ACCESS_TOKEN: ${{ secrets.GH_READ_TOKEN }} runs-on: ubuntu-latest name: tidy steps: @@ -81,8 +74,6 @@ jobs: with: go-version: 1.22 check-latest: true - # for private repo access - - run: git config --global url.https://${GITHUB_ACCESS_TOKEN}:x-oauth-basic@github.com/.insteadOf https://github.com/ - run: | go mod tidy CHANGES_IN_REPO=$(git status --porcelain) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cd2955f9..f6bc55e7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,9 +22,6 @@ jobs: test-coverage-upload: name: Run test and upload codecov env: - # for private repo access - GOPRIVATE: github.com/initia-labs/* - GITHUB_ACCESS_TOKEN: ${{ secrets.GH_READ_TOKEN }} CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} runs-on: ubuntu-latest steps: @@ -40,25 +37,29 @@ jobs: **/**.go go.mod go.sum - # for private repo access - - run: git config --global url.https://${GITHUB_ACCESS_TOKEN}:x-oauth-basic@github.com/.insteadOf https://github.com/ - name: test & coverage report creation run: | go test ./... -mod=readonly -timeout 12m -race -coverprofile=coverage.txt -covermode=atomic -tags='ledger test_ledger_mock' if: ${{ env.GIT_DIFF != '' }} + env: + GIT_DIFF: ${{ env.GIT_DIFF }} - name: filter out DONTCOVER run: | excludelist="$(find ./ -type f -name '*.go' | xargs grep -l 'DONTCOVER')" excludelist+=" $(find ./ -type f -name '*.pb.go')" for filename in ${excludelist}; do - filename=$(echo $filename | sed 's/^./github.com\/initia-labs\/initia/g') + filename=$(echo $filename | sed 's/^./github.com\/initia-labs\/OPinit/g') echo "Excluding ${filename} from coverage report..." sed -i.bak "/$(echo $filename | sed 's/\//\\\//g')/d" coverage.txt done if: ${{ env.GIT_DIFF != '' }} + env: + GIT_DIFF: ${{ env.GIT_DIFF }} - uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} files: ./coverage.txt fail_ci_if_error: true if: ${{ env.GIT_DIFF != '' }} + env: + GIT_DIFF: ${{ env.GIT_DIFF }} diff --git a/x/opchild/ante/common_test.go b/x/opchild/ante/common_test.go index d077a741..9ca1e25f 100644 --- a/x/opchild/ante/common_test.go +++ b/x/opchild/ante/common_test.go @@ -80,22 +80,6 @@ var ( addrs[4].String(), } - valAddrs = []sdk.ValAddress{ - sdk.ValAddress(pubKeys[0].Address()), - sdk.ValAddress(pubKeys[1].Address()), - sdk.ValAddress(pubKeys[2].Address()), - sdk.ValAddress(pubKeys[3].Address()), - sdk.ValAddress(pubKeys[4].Address()), - } - - valAddrsStr = []string{ - valAddrs[0].String(), - valAddrs[1].String(), - valAddrs[2].String(), - valAddrs[3].String(), - valAddrs[4].String(), - } - testDenoms = []string{ "test1", "test2", @@ -210,11 +194,6 @@ type TestKeepers struct { Faucet *TestFaucet } -// createDefaultTestInput common settings for createTestInput -func createDefaultTestInput(t testing.TB) (context.Context, TestKeepers) { - return createTestInput(t, false) -} - // createTestInput encoders can be nil to accept the defaults, or set it to override some of the message handlers (like default) func createTestInput(t testing.TB, isCheckTx bool) (context.Context, TestKeepers) { return _createTestInput(t, isCheckTx, dbm.NewMemDB()) @@ -295,7 +274,7 @@ func _createTestInput( authtypes.NewModuleAddress(opchildtypes.ModuleName).String(), ctx.Logger(), ) - bankKeeper.SetParams(ctx, banktypes.DefaultParams()) + require.NoError(t, bankKeeper.SetParams(ctx, banktypes.DefaultParams())) msgRouter := baseapp.NewMsgServiceRouter() msgRouter.SetInterfaceRegistry(encodingConfig.InterfaceRegistry) diff --git a/x/opchild/client/cli/tx_test.go b/x/opchild/client/cli/tx_test.go index 46a3d7ed..70f9b468 100644 --- a/x/opchild/client/cli/tx_test.go +++ b/x/opchild/client/cli/tx_test.go @@ -427,8 +427,9 @@ func (s *CLITestSuite) TestNewSetBridgeInfo() { require.NoError(err) defer os.Remove(validConfig.Name()) - invalidConfig.WriteString(`{}`) - validConfig.WriteString(`{ + _, err = invalidConfig.WriteString(`{}`) + s.NoError(err) + _, err = validConfig.WriteString(`{ "challengers": ["init1q6jhwnarkw2j5qqgx3qlu20k8nrdglft5ksr0g"], "proposer": "init1k2svyvm60r8rhnzr9vemk5f6fksvm6tyeujp3c", "submission_interval": "100s", @@ -440,6 +441,7 @@ func (s *CLITestSuite) TestNewSetBridgeInfo() { "chain_type": "INITIA" } }`) + s.NoError(err) testCases := []struct { name string diff --git a/x/opchild/keeper/common_test.go b/x/opchild/keeper/common_test.go index 78e61d2a..f9c2e306 100644 --- a/x/opchild/keeper/common_test.go +++ b/x/opchild/keeper/common_test.go @@ -295,7 +295,7 @@ func _createTestInput( authtypes.NewModuleAddress(opchildtypes.ModuleName).String(), ctx.Logger(), ) - bankKeeper.SetParams(ctx, banktypes.DefaultParams()) + require.NoError(t, bankKeeper.SetParams(ctx, banktypes.DefaultParams())) msgRouter := baseapp.NewMsgServiceRouter() msgRouter.SetInterfaceRegistry(encodingConfig.InterfaceRegistry) diff --git a/x/opchild/keeper/executor_change_test.go b/x/opchild/keeper/executor_change_test.go index 563b7ead..26f68698 100644 --- a/x/opchild/keeper/executor_change_test.go +++ b/x/opchild/keeper/executor_change_test.go @@ -1,9 +1,11 @@ package keeper_test import ( + "crypto/rand" "encoding/base64" "fmt" - "math/rand" + "math" + "math/big" "testing" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" @@ -16,16 +18,18 @@ func Test_RegisterExecutorChangePlan(t *testing.T) { _, input := createTestInput(t, false) // Arguments - l1ProposalID := rand.Uint64() - height := rand.Uint64() + l1ProposalID, err := rand.Int(rand.Reader, big.NewInt(math.MaxInt64)) + require.NoError(t, err) + height, err := rand.Int(rand.Reader, big.NewInt(math.MaxInt64)) + require.NoError(t, err) nextValAddr := valAddrsStr[0] nextExecutorAddr := []string{addrsStr[0], addrsStr[1]} consensusPubKey := "l7aqGv+Zjbm0rallfqfqz+3iN31iOmgJCafWV5pGs6o=" moniker := "moniker" info := "info" - err := input.OPChildKeeper.RegisterExecutorChangePlan( - l1ProposalID, height, nextValAddr, + err = input.OPChildKeeper.RegisterExecutorChangePlan( + l1ProposalID.Uint64(), height.Uint64(), nextValAddr, moniker, fmt.Sprintf(`{"@type":"/cosmos.crypto.ed25519.PubKey","key":"%s"}`, consensusPubKey), info, @@ -42,10 +46,10 @@ func Test_RegisterExecutorChangePlan(t *testing.T) { }, moniker) require.NoError(t, err) require.Equal(t, types.ExecutorChangePlan{ - ProposalID: l1ProposalID, - Height: height, + ProposalID: l1ProposalID.Uint64(), + Height: height.Uint64(), NextExecutors: []string{addrsStr[0], addrsStr[1]}, NextValidator: expectedValidator, Info: info, - }, input.OPChildKeeper.ExecutorChangePlans[height]) + }, input.OPChildKeeper.ExecutorChangePlans[height.Uint64()]) } diff --git a/x/opchild/keeper/genesis_test.go b/x/opchild/keeper/genesis_test.go index ef50e838..4ecd5cff 100644 --- a/x/opchild/keeper/genesis_test.go +++ b/x/opchild/keeper/genesis_test.go @@ -14,7 +14,7 @@ import ( func Test_GenesisImportExport(t *testing.T) { ctx, input := createDefaultTestInput(t) - input.OPChildKeeper.SetNextL2Sequence(ctx, 1) + require.NoError(t, input.OPChildKeeper.SetNextL2Sequence(ctx, 1)) seq, err := input.OPChildKeeper.IncreaseNextL2Sequence(ctx) require.NoError(t, err) @@ -23,8 +23,10 @@ func Test_GenesisImportExport(t *testing.T) { require.NoError(t, err) require.Equal(t, uint64(2), seq) - input.OPChildKeeper.IncreaseNextL1Sequence(ctx) // 2 - input.OPChildKeeper.IncreaseNextL1Sequence(ctx) // 3 + _, err = input.OPChildKeeper.IncreaseNextL1Sequence(ctx) // 2 + require.NoError(t, err) + _, err = input.OPChildKeeper.IncreaseNextL1Sequence(ctx) // 3 + require.NoError(t, err) genState := input.OPChildKeeper.ExportGenesis(ctx) require.Nil(t, genState.BridgeInfo) diff --git a/x/opchild/keeper/historical_info_test.go b/x/opchild/keeper/historical_info_test.go index 43bc3141..59eb3599 100644 --- a/x/opchild/keeper/historical_info_test.go +++ b/x/opchild/keeper/historical_info_test.go @@ -17,11 +17,11 @@ func Test_HistoricalInfo(t *testing.T) { params, err := input.OPChildKeeper.GetParams(ctx) require.NoError(t, err) params.HistoricalEntries = 2 - input.OPChildKeeper.SetParams(ctx, params) + require.NoError(t, input.OPChildKeeper.SetParams(ctx, params)) - input.OPChildKeeper.TrackHistoricalInfo(sdkCtx.WithBlockHeight(1)) - input.OPChildKeeper.TrackHistoricalInfo(sdkCtx.WithBlockHeight(2)) - input.OPChildKeeper.TrackHistoricalInfo(sdkCtx.WithBlockHeight(3)) + require.NoError(t, input.OPChildKeeper.TrackHistoricalInfo(sdkCtx.WithBlockHeight(1))) + require.NoError(t, input.OPChildKeeper.TrackHistoricalInfo(sdkCtx.WithBlockHeight(2))) + require.NoError(t, input.OPChildKeeper.TrackHistoricalInfo(sdkCtx.WithBlockHeight(3))) _, err = input.OPChildKeeper.GetHistoricalInfo(ctx, 1) require.ErrorIs(t, err, collections.ErrNotFound) diff --git a/x/opchild/keeper/host_validator_store_test.go b/x/opchild/keeper/host_validator_store_test.go index d1812887..119e8919 100644 --- a/x/opchild/keeper/host_validator_store_test.go +++ b/x/opchild/keeper/host_validator_store_test.go @@ -56,7 +56,8 @@ func Test_GetHostPubKeyByConsAddr(t *testing.T) { require.Error(t, err) // set validator - hostValidatorStore.SetValidator(ctx, val) + err = hostValidatorStore.SetValidator(ctx, val) + require.NoError(t, err) valPubKeyAfter, err := hostValidatorStore.GetPubKeyByConsAddr(ctx, consAddr) require.NoError(t, err) @@ -80,7 +81,8 @@ func Test_HostValidatorByConsAddr(t *testing.T) { require.Error(t, err) // set validator - hostValidatorStore.SetValidator(ctx, val) + err = hostValidatorStore.SetValidator(ctx, val) + require.NoError(t, err) valAfter, err := hostValidatorStore.ValidatorByConsAddr(ctx, consAddr) require.NoError(t, err) diff --git a/x/opchild/keeper/msg_server_test.go b/x/opchild/keeper/msg_server_test.go index e7e790a9..4c0539be 100644 --- a/x/opchild/keeper/msg_server_test.go +++ b/x/opchild/keeper/msg_server_test.go @@ -54,10 +54,12 @@ func Test_MsgServer_ExecuteMessages(t *testing.T) { val, err := types.NewValidator(valAddrs[0], valPubKeys[0], "val1") require.NoError(t, err) - input.OPChildKeeper.SetValidator(ctx, val) + err = input.OPChildKeeper.SetValidator(ctx, val) + require.NoError(t, err) // apply validator updates - input.OPChildKeeper.BlockValidatorUpdates(ctx) + _, err = input.OPChildKeeper.BlockValidatorUpdates(ctx) + require.NoError(t, err) moduleAddr, err := input.AccountKeeper.AddressCodec().BytesToString(authtypes.NewModuleAddress(types.ModuleName)) require.NoError(t, err) @@ -83,7 +85,8 @@ func Test_MsgServer_ExecuteMessages(t *testing.T) { require.NoError(t, err) // apply validator updates - input.OPChildKeeper.BlockValidatorUpdates(ctx) + _, err = input.OPChildKeeper.BlockValidatorUpdates(ctx) + require.NoError(t, err) vals, err := input.OPChildKeeper.GetAllValidators(ctx) require.NoError(t, err) @@ -148,7 +151,8 @@ func Test_MsgServer_AddValidator(t *testing.T) { params, err := ms.GetParams(ctx) require.NoError(t, err) params.MaxValidators = 1 - ms.SetParams(ctx, params) + err = ms.SetParams(ctx, params) + require.NoError(t, err) msg, err = types.NewMsgAddValidator("val2", moduleAddr, valAddrsStr[1], valPubKeys[1]) require.NoError(t, err) @@ -160,7 +164,8 @@ func Test_MsgServer_AddValidator(t *testing.T) { params, err = ms.GetParams(ctx) require.NoError(t, err) params.MaxValidators = 2 - ms.SetParams(ctx, params) + err = ms.SetParams(ctx, params) + require.NoError(t, err) _, err = ms.AddValidator(ctx, msg) require.NoError(t, err) @@ -176,7 +181,8 @@ func Test_MsgServer_RemoveValidator(t *testing.T) { val, err := types.NewValidator(valAddrs[0], valPubKeys[0], "val1") require.NoError(t, err) - input.OPChildKeeper.SetValidator(ctx, val) + err = input.OPChildKeeper.SetValidator(ctx, val) + require.NoError(t, err) // invalid signer msg, err := types.NewMsgRemoveValidator(addrsStr[0], valAddrsStr[0]) diff --git a/x/opchild/keeper/params_test.go b/x/opchild/keeper/params_test.go index f393d05d..faf5b280 100644 --- a/x/opchild/keeper/params_test.go +++ b/x/opchild/keeper/params_test.go @@ -16,7 +16,8 @@ func Test_Params(t *testing.T) { params.MinGasPrices = sdk.NewDecCoins() params.FeeWhitelist = []string{addrsStr[0], addrsStr[1]} - input.OPChildKeeper.SetParams(ctx, params) + err = input.OPChildKeeper.SetParams(ctx, params) + require.NoError(t, err) minGasPrices, err := input.OPChildKeeper.MinGasPrices(ctx) require.NoError(t, err) @@ -45,9 +46,9 @@ func Test_Change_MaxValidators(t *testing.T) { err = input.OPChildKeeper.SetParams(ctx, params) require.NoError(t, err) - input.OPChildKeeper.Validators.Set(ctx, []byte{0}, types.Validator{}) + err = input.OPChildKeeper.Validators.Set(ctx, []byte{0}, types.Validator{}) require.NoError(t, err) - input.OPChildKeeper.Validators.Set(ctx, []byte{1}, types.Validator{}) + err = input.OPChildKeeper.Validators.Set(ctx, []byte{1}, types.Validator{}) require.NoError(t, err) // cannot be lower than current number of validators diff --git a/x/opchild/keeper/querier_test.go b/x/opchild/keeper/querier_test.go index c77e2197..bbfba323 100644 --- a/x/opchild/keeper/querier_test.go +++ b/x/opchild/keeper/querier_test.go @@ -23,7 +23,7 @@ func Test_QueryValidator(t *testing.T) { val, err := types.NewValidator(valAddrs[0], valPubKeys[0], "validator1") require.NoError(t, err) - input.OPChildKeeper.SetValidator(ctx, val) + require.NoError(t, input.OPChildKeeper.SetValidator(ctx, val)) q := keeper.NewQuerier(input.OPChildKeeper) res, err := q.Validator(ctx, &types.QueryValidatorRequest{ValidatorAddr: val.OperatorAddress}) @@ -40,8 +40,8 @@ func Test_QueryValidators(t *testing.T) { val2, err := types.NewValidator(valAddrs[1], valPubKeys[1], "validator2") require.NoError(t, err) - input.OPChildKeeper.SetValidator(ctx, val1) - input.OPChildKeeper.SetValidator(ctx, val2) + require.NoError(t, input.OPChildKeeper.SetValidator(ctx, val1)) + require.NoError(t, input.OPChildKeeper.SetValidator(ctx, val2)) q := keeper.NewQuerier(input.OPChildKeeper) res, err := q.Validators(ctx, &types.QueryValidatorsRequest{}) @@ -83,7 +83,7 @@ func Test_QueryParams(t *testing.T) { params, err := input.OPChildKeeper.GetParams(ctx) require.NoError(t, err) params.MinGasPrices = sdk.NewDecCoins(sdk.NewInt64DecCoin("stake", 1)) - input.OPChildKeeper.SetParams(ctx, params) + require.NoError(t, input.OPChildKeeper.SetParams(ctx, params)) q := keeper.NewQuerier(input.OPChildKeeper) res, err := q.Params(ctx, &types.QueryParamsRequest{}) diff --git a/x/opchild/keeper/sequence_test.go b/x/opchild/keeper/sequence_test.go index b9c001f4..816a4b78 100644 --- a/x/opchild/keeper/sequence_test.go +++ b/x/opchild/keeper/sequence_test.go @@ -13,7 +13,8 @@ func Test_NextL1GetNextL1Sequence(t *testing.T) { require.NoError(t, err) require.Equal(t, uint64(1), res) - input.OPChildKeeper.IncreaseNextL1Sequence(ctx) + _, err = input.OPChildKeeper.IncreaseNextL1Sequence(ctx) + require.NoError(t, err) res, err = input.OPChildKeeper.GetNextL1Sequence(ctx) require.NoError(t, err) require.Equal(t, uint64(2), res) @@ -26,7 +27,7 @@ func Test_SetAndSetNextL2Sequence(t *testing.T) { require.NoError(t, err) require.Equal(t, uint64(1), seq) - input.OPChildKeeper.SetNextL2Sequence(ctx, 1204) + require.NoError(t, input.OPChildKeeper.SetNextL2Sequence(ctx, 1204)) seq, err = input.OPChildKeeper.GetNextL2Sequence(ctx) require.NoError(t, err) require.Equal(t, uint64(1204), seq) diff --git a/x/opchild/keeper/staking_test.go b/x/opchild/keeper/staking_test.go index 83588b12..3fe4aae3 100644 --- a/x/opchild/keeper/staking_test.go +++ b/x/opchild/keeper/staking_test.go @@ -13,7 +13,7 @@ func Test_MaxValidators(t *testing.T) { params, err := input.OPChildKeeper.GetParams(ctx) require.NoError(t, err) params.MaxValidators = 10 - input.OPChildKeeper.SetParams(ctx, params) + require.NoError(t, input.OPChildKeeper.SetParams(ctx, params)) maxValidators, err := input.OPChildKeeper.MaxValidators(ctx) require.NoError(t, err) @@ -26,7 +26,7 @@ func Test_HistoricalEntries(t *testing.T) { params, err := input.OPChildKeeper.GetParams(ctx) require.NoError(t, err) params.HistoricalEntries = 10 - input.OPChildKeeper.SetParams(ctx, params) + require.NoError(t, input.OPChildKeeper.SetParams(ctx, params)) entries, err := input.OPChildKeeper.HistoricalEntries(ctx) require.NoError(t, err) diff --git a/x/opchild/keeper/val_state_change_test.go b/x/opchild/keeper/val_state_change_test.go index 275313e6..c3961647 100644 --- a/x/opchild/keeper/val_state_change_test.go +++ b/x/opchild/keeper/val_state_change_test.go @@ -21,8 +21,8 @@ func Test_BlockValidatorUpdates(t *testing.T) { require.NoError(t, err) // set validators - input.OPChildKeeper.SetValidator(ctx, val1) - input.OPChildKeeper.SetValidator(ctx, val2) + require.NoError(t, input.OPChildKeeper.SetValidator(ctx, val1)) + require.NoError(t, input.OPChildKeeper.SetValidator(ctx, val2)) // apply val updates updates, err := input.OPChildKeeper.BlockValidatorUpdates(ctx) @@ -48,7 +48,7 @@ func Test_BlockValidatorUpdates(t *testing.T) { // val2 removed val2.ConsPower = 0 - input.OPChildKeeper.SetValidator(ctx, val2) + require.NoError(t, input.OPChildKeeper.SetValidator(ctx, val2)) updates, err = input.OPChildKeeper.BlockValidatorUpdates(ctx) require.NoError(t, err) require.Equal(t, []abci.ValidatorUpdate{val2.ABCIValidatorUpdateZero()}, updates) diff --git a/x/opchild/keeper/validator_test.go b/x/opchild/keeper/validator_test.go index 9fd625a4..7db02766 100644 --- a/x/opchild/keeper/validator_test.go +++ b/x/opchild/keeper/validator_test.go @@ -22,14 +22,14 @@ func Test_GetValidator(t *testing.T) { require.False(t, found) // set validator - input.OPChildKeeper.SetValidator(ctx, val) + require.NoError(t, input.OPChildKeeper.SetValidator(ctx, val)) valAfter, found := input.OPChildKeeper.GetValidator(ctx, valAddrs[1]) require.True(t, found) require.Equal(t, val, valAfter) // remove validator - input.OPChildKeeper.RemoveValidator(ctx, valAddrs[1]) + require.NoError(t, input.OPChildKeeper.RemoveValidator(ctx, valAddrs[1])) // should be empty _, found = input.OPChildKeeper.GetValidator(ctx, valAddrs[1]) @@ -51,15 +51,15 @@ func Test_GetValidatorByConsAddr(t *testing.T) { require.False(t, found) // set validator - input.OPChildKeeper.SetValidator(ctx, val) - input.OPChildKeeper.SetValidatorByConsAddr(ctx, val) + require.NoError(t, input.OPChildKeeper.SetValidator(ctx, val)) + require.NoError(t, input.OPChildKeeper.SetValidatorByConsAddr(ctx, val)) valAfter, found := input.OPChildKeeper.GetValidatorByConsAddr(ctx, consAddr) require.True(t, found) require.Equal(t, val, valAfter) // remove validator - input.OPChildKeeper.RemoveValidator(ctx, valAddrs[1]) + require.NoError(t, input.OPChildKeeper.RemoveValidator(ctx, valAddrs[1])) // should be empty _, found = input.OPChildKeeper.GetValidatorByConsAddr(ctx, consAddr) @@ -76,8 +76,8 @@ func Test_GetAllValidators(t *testing.T) { val2, err := types.NewValidator(valAddrs[2], valPubKeys[1], "validator2") require.NoError(t, err) - input.OPChildKeeper.SetValidator(ctx, val1) - input.OPChildKeeper.SetValidator(ctx, val2) + require.NoError(t, input.OPChildKeeper.SetValidator(ctx, val1)) + require.NoError(t, input.OPChildKeeper.SetValidator(ctx, val2)) vals, err := input.OPChildKeeper.GetAllValidators(ctx) require.NoError(t, err) @@ -96,8 +96,8 @@ func Test_GetValidators(t *testing.T) { val2, err := types.NewValidator(valAddrs[2], valPubKeys[1], "validator2") require.NoError(t, err) - input.OPChildKeeper.SetValidator(ctx, val1) - input.OPChildKeeper.SetValidator(ctx, val2) + require.NoError(t, input.OPChildKeeper.SetValidator(ctx, val1)) + require.NoError(t, input.OPChildKeeper.SetValidator(ctx, val2)) vals, err := input.OPChildKeeper.GetValidators(ctx, 1) require.NoError(t, err) @@ -119,17 +119,17 @@ func Test_LastValidatorPower(t *testing.T) { require.Equal(t, int64(0), beforePower) // set validator with power index - input.OPChildKeeper.SetValidator(ctx, val1) - input.OPChildKeeper.SetValidator(ctx, val2) - input.OPChildKeeper.SetLastValidatorPower(ctx, valAddrs[1], 100) - input.OPChildKeeper.SetLastValidatorPower(ctx, valAddrs[2], 200) + require.NoError(t, input.OPChildKeeper.SetValidator(ctx, val1)) + require.NoError(t, input.OPChildKeeper.SetValidator(ctx, val2)) + require.NoError(t, input.OPChildKeeper.SetLastValidatorPower(ctx, valAddrs[1], 100)) + require.NoError(t, input.OPChildKeeper.SetLastValidatorPower(ctx, valAddrs[2], 200)) afterPower, err := input.OPChildKeeper.GetLastValidatorPower(ctx, valAddrs[1]) require.NoError(t, err) require.Equal(t, int64(100), afterPower) // iterate all powers - input.OPChildKeeper.IterateLastValidatorPowers(ctx, func(key []byte, power int64) (stop bool, err error) { + require.NoError(t, input.OPChildKeeper.IterateLastValidatorPowers(ctx, func(key []byte, power int64) (stop bool, err error) { valAddr := sdk.ValAddress(key) if valAddr.Equals(valAddrs[1]) { require.Equal(t, int64(100), power) @@ -139,7 +139,7 @@ func Test_LastValidatorPower(t *testing.T) { } return false, nil - }) + })) // get last validators from the power index vals, err := input.OPChildKeeper.GetLastValidators(ctx) diff --git a/x/ophost/client/cli/tx_test.go b/x/ophost/client/cli/tx_test.go index 1b1e42f1..13338c2d 100644 --- a/x/ophost/client/cli/tx_test.go +++ b/x/ophost/client/cli/tx_test.go @@ -148,6 +148,7 @@ func (s *CLITestSuite) TestNewRecordBatchCmd() { } } +//nolint:dupl func (s *CLITestSuite) TestNewCreateBridge() { require := s.Require() cmd := cli.NewCreateBridge(s.ac) @@ -162,8 +163,9 @@ func (s *CLITestSuite) TestNewCreateBridge() { require.NoError(err) defer os.Remove(validConfig.Name()) - invalidConfig.WriteString(`{}`) - validConfig.WriteString(`{ + _, err = invalidConfig.WriteString(`{}`) + s.NoError(err) + _, err = validConfig.WriteString(`{ "challengers": ["init1q6jhwnarkw2j5qqgx3qlu20k8nrdglft5ksr0g"], "proposer": "init1k2svyvm60r8rhnzr9vemk5f6fksvm6tyeujp3c", "submission_interval": "100s", @@ -175,6 +177,7 @@ func (s *CLITestSuite) TestNewCreateBridge() { "chain_type": "CELESTIA" } }`) + s.NoError(err) testCases := []struct { name string @@ -494,6 +497,7 @@ func (s *CLITestSuite) TestNewInitiateTokenDeposit() { } } +//nolint:dupl func (s *CLITestSuite) TestNewFinalizeTokenWithdrawal() { require := s.Require() cmd := cli.NewFinalizeTokenWithdrawal(s.ac) @@ -508,8 +512,9 @@ func (s *CLITestSuite) TestNewFinalizeTokenWithdrawal() { require.NoError(err) defer os.Remove(validConfig.Name()) - invalidConfig.WriteString(`{}`) - validConfig.WriteString(`{ + _, err = invalidConfig.WriteString(`{}`) + s.NoError(err) + _, err = validConfig.WriteString(`{ "bridge_id": 1, "output_index": 1180, "withdrawal_proofs": [ @@ -522,6 +527,7 @@ func (s *CLITestSuite) TestNewFinalizeTokenWithdrawal() { "storage_root": "KGlalV+mBHC7YFOLNX3g9LLzmyvP7QCm42HKo9N3Lu8=", "latest_block_hash": "6oFdc+PEkXVJAo5IpXJ91vbCT9FNuKCz5VSlaFmxG+Y=" }`) + s.NoError(err) testCases := []struct { name string diff --git a/x/ophost/keeper/bridge_test.go b/x/ophost/keeper/bridge_test.go index 06fd595d..a9c6b820 100644 --- a/x/ophost/keeper/bridge_test.go +++ b/x/ophost/keeper/bridge_test.go @@ -48,7 +48,7 @@ func Test_IterateBridgeConfig(t *testing.T) { require.NoError(t, input.OPHostKeeper.SetBridgeConfig(ctx, 1, config1)) require.NoError(t, input.OPHostKeeper.SetBridgeConfig(ctx, 2, config2)) - input.OPHostKeeper.IterateBridgeConfig(ctx, func(bridgeId uint64, bridgeConfig types.BridgeConfig) (stop bool, err error) { + err := input.OPHostKeeper.IterateBridgeConfig(ctx, func(bridgeId uint64, bridgeConfig types.BridgeConfig) (stop bool, err error) { if bridgeId == 1 { require.Equal(t, config1, bridgeConfig) } else { @@ -57,4 +57,5 @@ func Test_IterateBridgeConfig(t *testing.T) { return false, nil }) + require.NoError(t, err) } diff --git a/x/ophost/keeper/common_test.go b/x/ophost/keeper/common_test.go index e375436e..19845fd4 100644 --- a/x/ophost/keeper/common_test.go +++ b/x/ophost/keeper/common_test.go @@ -279,7 +279,8 @@ func _createTestInput( authtypes.NewModuleAddress(govtypes.ModuleName).String(), ctx.Logger(), ) - bankKeeper.SetParams(ctx, banktypes.DefaultParams()) + err := bankKeeper.SetParams(ctx, banktypes.DefaultParams()) + require.NoError(t, err) msgRouter := baseapp.NewMsgServiceRouter() msgRouter.SetInterfaceRegistry(encodingConfig.InterfaceRegistry) @@ -297,7 +298,8 @@ func _createTestInput( ) ophostParams := ophosttypes.DefaultParams() - ophostKeeper.SetParams(ctx, ophostParams) + err = ophostKeeper.SetParams(ctx, ophostParams) + require.NoError(t, err) // register handlers to msg router ophosttypes.RegisterMsgServer(msgRouter, ophostkeeper.NewMsgServerImpl(*ophostKeeper)) diff --git a/x/ophost/keeper/genesis_test.go b/x/ophost/keeper/genesis_test.go index de59c96a..0c4cf0c2 100644 --- a/x/ophost/keeper/genesis_test.go +++ b/x/ophost/keeper/genesis_test.go @@ -33,11 +33,11 @@ func Test_GenesisExport(t *testing.T) { require.NoError(t, input.OPHostKeeper.SetBridgeConfig(ctx, 1, config1)) require.NoError(t, input.OPHostKeeper.SetBridgeConfig(ctx, 2, config2)) - input.OPHostKeeper.SetNextBridgeId(ctx, 3) - input.OPHostKeeper.SetNextL1Sequence(ctx, 1, 100) - input.OPHostKeeper.SetNextL1Sequence(ctx, 2, 200) - input.OPHostKeeper.SetNextOutputIndex(ctx, 1, 10) - input.OPHostKeeper.SetNextOutputIndex(ctx, 2, 20) + require.NoError(t, input.OPHostKeeper.SetNextBridgeId(ctx, 3)) + require.NoError(t, input.OPHostKeeper.SetNextL1Sequence(ctx, 1, 100)) + require.NoError(t, input.OPHostKeeper.SetNextL1Sequence(ctx, 2, 200)) + require.NoError(t, input.OPHostKeeper.SetNextOutputIndex(ctx, 1, 10)) + require.NoError(t, input.OPHostKeeper.SetNextOutputIndex(ctx, 2, 20)) output1 := types.Output{ OutputRoot: []byte{1, 2, 3}, @@ -58,15 +58,15 @@ func Test_GenesisExport(t *testing.T) { require.NoError(t, input.OPHostKeeper.SetOutputProposal(ctx, 1, 2, output2)) require.NoError(t, input.OPHostKeeper.SetOutputProposal(ctx, 2, 1, output3)) - input.OPHostKeeper.SetTokenPair(ctx, 1, "l2denom", "l1denom") - input.OPHostKeeper.SetTokenPair(ctx, 2, "l12denom", "l11denom") + require.NoError(t, input.OPHostKeeper.SetTokenPair(ctx, 1, "l2denom", "l1denom")) + require.NoError(t, input.OPHostKeeper.SetTokenPair(ctx, 2, "l12denom", "l11denom")) - input.OPHostKeeper.RecordProvenWithdrawal(ctx, 1, [32]byte{1, 2, 3}) - input.OPHostKeeper.RecordProvenWithdrawal(ctx, 1, [32]byte{3, 4, 5}) + require.NoError(t, input.OPHostKeeper.RecordProvenWithdrawal(ctx, 1, [32]byte{1, 2, 3})) + require.NoError(t, input.OPHostKeeper.RecordProvenWithdrawal(ctx, 1, [32]byte{3, 4, 5})) - input.OPHostKeeper.SetBatchInfo(ctx, 1, types.BatchInfo{Submitter: addrsStr[0], ChainType: types.BatchInfo_CHAIN_TYPE_INITIA}, types.Output{}) - input.OPHostKeeper.SetBatchInfo(ctx, 1, types.BatchInfo{Submitter: addrsStr[1], ChainType: types.BatchInfo_CHAIN_TYPE_CELESTIA}, output1) - input.OPHostKeeper.SetBatchInfo(ctx, 1, types.BatchInfo{Submitter: addrsStr[0], ChainType: types.BatchInfo_CHAIN_TYPE_INITIA}, output3) + require.NoError(t, input.OPHostKeeper.SetBatchInfo(ctx, 1, types.BatchInfo{Submitter: addrsStr[0], ChainType: types.BatchInfo_CHAIN_TYPE_INITIA}, types.Output{})) + require.NoError(t, input.OPHostKeeper.SetBatchInfo(ctx, 1, types.BatchInfo{Submitter: addrsStr[1], ChainType: types.BatchInfo_CHAIN_TYPE_CELESTIA}, output1)) + require.NoError(t, input.OPHostKeeper.SetBatchInfo(ctx, 1, types.BatchInfo{Submitter: addrsStr[0], ChainType: types.BatchInfo_CHAIN_TYPE_INITIA}, output3)) genState := input.OPHostKeeper.ExportGenesis(ctx) require.Equal(t, uint64(3), genState.NextBridgeId) diff --git a/x/ophost/keeper/output_test.go b/x/ophost/keeper/output_test.go index c96db115..a66d890a 100644 --- a/x/ophost/keeper/output_test.go +++ b/x/ophost/keeper/output_test.go @@ -59,7 +59,7 @@ func Test_IterateOutputProposal(t *testing.T) { err = input.OPHostKeeper.SetOutputProposal(ctx, 2, 1, output4) require.NoError(t, err) - input.OPHostKeeper.IterateOutputProposals(ctx, 1, func(key collections.Pair[uint64, uint64], output types.Output) (stop bool, err error) { + err = input.OPHostKeeper.IterateOutputProposals(ctx, 1, func(key collections.Pair[uint64, uint64], output types.Output) (stop bool, err error) { require.Equal(t, key.K1(), uint64(1)) switch key.K2() { case 1: @@ -74,6 +74,7 @@ func Test_IterateOutputProposal(t *testing.T) { return false, nil }) + require.NoError(t, err) } func Test_IsFinalized(t *testing.T) { diff --git a/x/ophost/keeper/params_test.go b/x/ophost/keeper/params_test.go index 78993ff6..9031cee0 100644 --- a/x/ophost/keeper/params_test.go +++ b/x/ophost/keeper/params_test.go @@ -13,7 +13,7 @@ func Test_Params(t *testing.T) { params := input.OPHostKeeper.GetParams(ctx) params.RegistrationFee = sdk.NewCoins() - input.OPHostKeeper.SetParams(ctx, params) - + err := input.OPHostKeeper.SetParams(ctx, params) + require.NoError(t, err) require.True(t, input.OPHostKeeper.RegistrationFee(ctx).IsZero()) } diff --git a/x/ophost/keeper/querier_test.go b/x/ophost/keeper/querier_test.go index ac4d223e..414e4d79 100644 --- a/x/ophost/keeper/querier_test.go +++ b/x/ophost/keeper/querier_test.go @@ -83,7 +83,8 @@ func Test_QueryTokenPair(t *testing.T) { L1Denom: "l1denom", L2Denom: types.L2Denom(1, "l1denom"), } - input.OPHostKeeper.SetTokenPair(ctx, 1, pair.L2Denom, pair.L1Denom) + err := input.OPHostKeeper.SetTokenPair(ctx, 1, pair.L2Denom, pair.L1Denom) + require.NoError(t, err) q := keeper.NewQuerier(input.OPHostKeeper) res, err := q.TokenPairByL1Denom(ctx, &types.QueryTokenPairByL1DenomRequest{ @@ -111,8 +112,8 @@ func Test_QueryTokenPairs(t *testing.T) { L1Denom: "l1denom2", L2Denom: types.L2Denom(1, "l1denom2"), } - input.OPHostKeeper.SetTokenPair(ctx, 1, pair1.L2Denom, pair1.L1Denom) - input.OPHostKeeper.SetTokenPair(ctx, 1, pair2.L2Denom, pair2.L1Denom) + require.NoError(t, input.OPHostKeeper.SetTokenPair(ctx, 1, pair1.L2Denom, pair1.L1Denom)) + require.NoError(t, input.OPHostKeeper.SetTokenPair(ctx, 1, pair2.L2Denom, pair2.L1Denom)) q := keeper.NewQuerier(input.OPHostKeeper) res, err := q.TokenPairs(ctx, &types.QueryTokenPairsRequest{ diff --git a/x/ophost/keeper/token_pair_test.go b/x/ophost/keeper/token_pair_test.go index 763fb6c1..d6af88f5 100644 --- a/x/ophost/keeper/token_pair_test.go +++ b/x/ophost/keeper/token_pair_test.go @@ -13,7 +13,7 @@ func Test_TokenPair(t *testing.T) { L1Denom: "l1_denom", L2Denom: "l2_denom", } - input.OPHostKeeper.SetTokenPair(ctx, 1, tokenPair.L2Denom, tokenPair.L1Denom) + require.NoError(t, input.OPHostKeeper.SetTokenPair(ctx, 1, tokenPair.L2Denom, tokenPair.L1Denom)) l1Denom, err := input.OPHostKeeper.GetTokenPair(ctx, 1, tokenPair.L2Denom) require.Equal(t, tokenPair.L1Denom, l1Denom) @@ -35,11 +35,11 @@ func Test_IterateTokenPair(t *testing.T) { L1Denom: "l31_denom", L2Denom: "l32_denom", } - input.OPHostKeeper.SetTokenPair(ctx, 1, tokenPair1.L2Denom, tokenPair1.L1Denom) - input.OPHostKeeper.SetTokenPair(ctx, 1, tokenPair2.L2Denom, tokenPair2.L1Denom) - input.OPHostKeeper.SetTokenPair(ctx, 2, tokenPair3.L2Denom, tokenPair3.L1Denom) + require.NoError(t, input.OPHostKeeper.SetTokenPair(ctx, 1, tokenPair1.L2Denom, tokenPair1.L1Denom)) + require.NoError(t, input.OPHostKeeper.SetTokenPair(ctx, 1, tokenPair2.L2Denom, tokenPair2.L1Denom)) + require.NoError(t, input.OPHostKeeper.SetTokenPair(ctx, 2, tokenPair3.L2Denom, tokenPair3.L1Denom)) - input.OPHostKeeper.IterateTokenPair(ctx, 1, func(bridgeId uint64, tokenPair types.TokenPair) (stop bool, err error) { + require.NoError(t, input.OPHostKeeper.IterateTokenPair(ctx, 1, func(bridgeId uint64, tokenPair types.TokenPair) (stop bool, err error) { require.Equal(t, bridgeId, uint64(1)) if tokenPair.L1Denom == tokenPair1.L1Denom { require.Equal(t, tokenPair1, tokenPair) @@ -47,5 +47,5 @@ func Test_IterateTokenPair(t *testing.T) { require.Equal(t, tokenPair2, tokenPair) } return false, nil - }) + })) } diff --git a/x/ophost/keeper/withdrawal_test.go b/x/ophost/keeper/withdrawal_test.go index 33ce1693..04cb5797 100644 --- a/x/ophost/keeper/withdrawal_test.go +++ b/x/ophost/keeper/withdrawal_test.go @@ -9,9 +9,9 @@ import ( func Test_ProvenWithdrawal(t *testing.T) { ctx, input := createDefaultTestInput(t) - input.OPHostKeeper.RecordProvenWithdrawal(ctx, 1, [32]byte{1, 2, 3}) - input.OPHostKeeper.RecordProvenWithdrawal(ctx, 1, [32]byte{4, 5, 6}) - input.OPHostKeeper.RecordProvenWithdrawal(ctx, 2, [32]byte{7, 8, 9}) + require.NoError(t, input.OPHostKeeper.RecordProvenWithdrawal(ctx, 1, [32]byte{1, 2, 3})) + require.NoError(t, input.OPHostKeeper.RecordProvenWithdrawal(ctx, 1, [32]byte{4, 5, 6})) + require.NoError(t, input.OPHostKeeper.RecordProvenWithdrawal(ctx, 2, [32]byte{7, 8, 9})) found, err := input.OPHostKeeper.HasProvenWithdrawal(ctx, 1, [32]byte{1, 2, 3}) require.NoError(t, err) @@ -21,12 +21,12 @@ func Test_ProvenWithdrawal(t *testing.T) { require.NoError(t, err) require.True(t, found) - input.OPHostKeeper.IterateProvenWithdrawals(ctx, 1, func(bridgeId uint64, withdrawalHash [32]byte) (bool, error) { + require.NoError(t, input.OPHostKeeper.IterateProvenWithdrawals(ctx, 1, func(bridgeId uint64, withdrawalHash [32]byte) (bool, error) { require.Equal(t, uint64(1), bridgeId) if withdrawalHash != [32]byte{1, 2, 3} { require.Equal(t, [32]byte{4, 5, 6}, withdrawalHash) } return false, nil - }) + })) }