Skip to content

Commit

Permalink
Merge commit '12d95c7' into releases/v4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
pr0n00gler committed Jul 29, 2024
2 parents f5948a5 + 12d95c7 commit 18a09c8
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 24 deletions.
30 changes: 17 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: CI

on:
push:
tags:
- "*"
branches:
- "main"
- "releases/v3.x"
Expand All @@ -11,6 +13,12 @@ on:
- "main"
- "releases/v3.x"
- "chore/fix-ci"
workflow_dispatch:
inputs:
tag:
description: 'Tag to run the workflow for'
required: false
default: ''

jobs:
docker:
Expand All @@ -23,6 +31,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.inputs.tag || github.ref }}

- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y jq curl git
Expand All @@ -44,9 +53,15 @@ jobs:
curl --silent -L --output ~/.docker/cli-plugins/docker-buildx $BUILDX_URL
chmod a+x ~/.docker/cli-plugins/docker-buildx
- name: Get version from git tags
- name: Get version from git tags or input
id: get_version
run: echo "VERSION=v$(git describe --tags --abbrev=0 | sed 's/^v//')" >> $GITHUB_ENV
run: |
if [ -n "${{ github.event.inputs.tag }}" ]; then
VERSION=${{ github.event.inputs.tag }}
else
VERSION=$(git describe --tags --abbrev=0)
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Log in to Docker Hub
run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login --username ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
Expand All @@ -60,16 +75,6 @@ jobs:
endpoint: "neutronorg/neutron"
install: true

# - name: Build and push
# uses: docker/build-push-action@v5
# with:
# context: .
# file: Dockerfile.builder
# tags: "${{ env.VERSION }}"
# # For pull requests, export results to the build cache.
# # Otherwise, push to a registry.
# outputs: ${{ github.event_name == 'pull_request' && 'type=cacheonly' || 'type=registry,push=true' }}

- name: Build and push Docker image
env:
VERSION: ${{ env.VERSION }}
Expand All @@ -82,4 +87,3 @@ jobs:
- name: Cleanup temporary container
run: docker rm -f neutronbinary || true

2 changes: 1 addition & 1 deletion contrib/statesync.bash
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ NEUTROND_P2P_SEEDS=$(curl -s https://raw.githubusercontent.com/cosmos/chain-regi
export NEUTROND_P2P_SEEDS

# Start chain.
neutrond start --x-crisis-skip-assert-invariants --iavl-disable-fastnode false
neutrond start --x-crisis-skip-assert-invariants --iavl-disable-fastnode false --minimum-gas-prices 0untrn
3 changes: 2 additions & 1 deletion testutil/tokenfactory/keeper/tokenfactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require"

"github.com/neutron-org/neutron/v4/testutil"
"github.com/neutron-org/neutron/v4/x/tokenfactory/keeper"
"github.com/neutron-org/neutron/v4/x/tokenfactory/types"
)
Expand Down Expand Up @@ -43,7 +44,7 @@ func TokenFactoryKeeper(
accountKeeper,
bankKeeper,
contractKeeper,
"authority",
testutil.TestOwnerAddress,
)

ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger())
Expand Down
85 changes: 82 additions & 3 deletions x/tokenfactory/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -869,24 +869,36 @@ func TestMsgUpdateParamsValidate(t *testing.T) {
"authority is invalid",
},
{
"empty fee_collector_address",
"empty fee_collector_address with denom_creation_fee",
types.MsgUpdateParams{
Authority: testutil.TestOwnerAddress,
Params: types.Params{
FeeCollectorAddress: "",
DenomCreationFee: sdktypes.NewCoins(sdktypes.NewCoin("untrn", math.OneInt())),
},
},
"fee_collector_address is invalid",
"DenomCreationFee and FeeCollectorAddr must be both set or both unset",
},
{
"fee_collector_address empty denom_creation_fee",
types.MsgUpdateParams{
Authority: testutil.TestOwnerAddress,
Params: types.Params{
FeeCollectorAddress: testAddress,
},
},
"DenomCreationFee and FeeCollectorAddr must be both set or both unset",
},
{
"invalid fee_collector_address",
types.MsgUpdateParams{
Authority: testutil.TestOwnerAddress,
Params: types.Params{
DenomCreationFee: sdktypes.NewCoins(sdktypes.NewCoin("untrn", math.OneInt())),
FeeCollectorAddress: "invalid fee_collector_address",
},
},
"fee_collector_address is invalid",
"failed to validate FeeCollectorAddress",
},
}

Expand All @@ -899,3 +911,70 @@ func TestMsgUpdateParamsValidate(t *testing.T) {
})
}
}

func TestMsgUpdateParamsWhitelistedHooks(t *testing.T) {
k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil)

tests := []struct {
name string
params types.Params
error string
}{
{
"success",
types.Params{
WhitelistedHooks: []*types.WhitelistedHook{{DenomCreator: testAddress, CodeID: 1}},
},
"",
},
{
"success multiple ",
types.Params{
WhitelistedHooks: []*types.WhitelistedHook{
{DenomCreator: testAddress, CodeID: 1},
{DenomCreator: testAddress, CodeID: 2},
},
},
"",
},
{
"invalid denom creator",
types.Params{
WhitelistedHooks: []*types.WhitelistedHook{
{DenomCreator: "bad_address", CodeID: 1},
},
},
"invalid denom creator",
},
{
"duplicate hooks",
types.Params{
WhitelistedHooks: []*types.WhitelistedHook{
{DenomCreator: testAddress, CodeID: 1},
{DenomCreator: testAddress, CodeID: 1},
},
},
"duplicate whitelisted hook",
},
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
msg := &types.MsgUpdateParams{
Authority: testutil.TestOwnerAddress,
Params: tt.params,
}
resp, err := k.UpdateParams(ctx, msg)
if len(tt.error) > 0 {
require.ErrorContains(t, err, tt.error)
require.Nil(t, resp)

} else {
require.NoError(t, err)
newParams := k.GetParams(ctx)
require.Equal(t, tt.params, newParams)
}
})
}
}
6 changes: 0 additions & 6 deletions x/tokenfactory/types/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,5 @@ func (msg *MsgUpdateParams) Validate() error {
return errorsmod.Wrap(err, "authority is invalid")
}

// TODO: This is inconsistent. Per Params.Validate() an empty creator address is valid as long as
// DenomCreationFee is nil. But This check fails if FeeCollectorAddress is unset.
if _, err := sdk.AccAddressFromBech32(msg.Params.FeeCollectorAddress); err != nil {
return errorsmod.Wrap(err, "fee_collector_address is invalid")
}

return msg.Params.Validate()
}

0 comments on commit 18a09c8

Please sign in to comment.