Skip to content

Commit

Permalink
Merge branch 'main' into wasm-governance
Browse files Browse the repository at this point in the history
  • Loading branch information
fish-sammy authored Jan 2, 2024
2 parents fcb4ce7 + 6deaf92 commit f0f7a57
Show file tree
Hide file tree
Showing 9 changed files with 1,113 additions and 61 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ execute `make docker-image-debug`. This creates the image axelar/core-debug:late

In order to run/build the project locally we need to import the bytecode from gateway smart contracts.

1. Find the specific version of the bytecode here `contract-version.json`
2. Download the right version from the [gateway workflow](https://github.com/axelarnetwork/solidity-cgp-gateway/actions/workflows/publish-bytecode.yaml).
1. Find the required version of the bytecode here [`contract-version.json`](contract-version.json)
2. Download that version from the [axelar-cgp-solidity releases](https://github.com/axelarnetwork/axelar-cgp-solidity/releases).
Example: `Bytecode-v4.3.0`
3. Unzip the json files under `contract-artifacts/gateway/`
3. Unzip the json files under `contract-artifacts/`
4. Run `make generate` to generate `x/evm/types/contracts.go`

## Interacting with a local node
Expand Down
Empty file.
9 changes: 9 additions & 0 deletions config/seeds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ func TestReadSeeds(t *testing.T) {
}
})

t.Run("file exists but is empty", func(t *testing.T) {
v := viper.New()
v.AddConfigPath("./empty_test_files")

seeds, err := config.ReadSeeds(v)
assert.NoError(t, err)
assert.Len(t, seeds, 0)
})

t.Run("file does not exist", func(t *testing.T) {
v := viper.New()
v.AddConfigPath("some other path")
Expand Down
20 changes: 10 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ require (
golang.org/x/text v0.14.0
golang.org/x/tools v0.16.1
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2
google.golang.org/genproto/googleapis/api v0.0.0-20230525234020-1aefcd67740a
google.golang.org/grpc v1.55.0
google.golang.org/protobuf v1.30.0
google.golang.org/genproto/googleapis/api v0.0.0-20230629202037-9506855d4529
google.golang.org/grpc v1.58.3
google.golang.org/protobuf v1.31.0
)

require (
Expand All @@ -54,7 +54,7 @@ require (
filippo.io/edwards25519 v1.0.0-rc.1 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.1 // indirect
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect
github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect
github.com/DataDog/zstd v1.5.2 // indirect
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect
github.com/Workiva/go-datastructures v1.0.53 // indirect
Expand Down Expand Up @@ -104,11 +104,11 @@ require (
github.com/go-stack/stack v1.8.1 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/gogo/gateway v1.1.0 // indirect
github.com/golang/glog v1.0.0 // indirect
github.com/golang/glog v1.1.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/flatbuffers v1.12.1 // indirect
github.com/google/flatbuffers v2.0.8+incompatible // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/orderedcode v0.0.1 // indirect
Expand Down Expand Up @@ -174,16 +174,16 @@ require (
golang.org/x/net v0.19.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/term v0.15.0 // indirect
google.golang.org/genproto v0.0.0-20230526015343-6ee61e4f9d5f // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234015-3fc162c6f38a // indirect
google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
nhooyr.io/websocket v1.8.6 // indirect
)

replace google.golang.org/grpc => google.golang.org/grpc v1.33.2
replace google.golang.org/grpc => google.golang.org/grpc v1.56.3

replace github.com/opencontainers/image-spec v1.0.1 => github.com/opencontainers/image-spec v1.0.2

Expand All @@ -206,7 +206,7 @@ replace github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2
replace github.com/rjeczalik/notify => github.com/rjeczalik/notify v0.9.3

// use cometbft
replace github.com/tendermint/tendermint => github.com/cometbft/cometbft v0.34.27
replace github.com/tendermint/tendermint => github.com/cometbft/cometbft v0.34.30

// Temporary replacement for rosetta support
replace github.com/cosmos/cosmos-sdk => github.com/axelarnetwork/cosmos-sdk v0.45.17-0.20230904150332-37fb903a6c62
1,017 changes: 971 additions & 46 deletions go.sum

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions testutils/rand/rand_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ func TestRandBoolGen(t *testing.T) {
t.Run("correct ratio", ratioConvergesToOneEigth)
}

func TestUintGen(t *testing.T) {
t.Run("limit range", uintbetween0And10)
}

func intTake10(t *testing.T) {
g := PInt64Gen()

Expand Down Expand Up @@ -64,6 +68,14 @@ func between0And50GreaterThan25LesserThan30OrExactly45Take20(t *testing.T) {
}
}

func uintbetween0And10(t *testing.T) {
for i := 0; i < 10; i++ {
g := UintBetween(sdk.ZeroUint(), sdk.NewUint(10))
assert.True(t, g.GTE(sdk.ZeroUint()))
assert.True(t, g.LT(sdk.NewUint(10)))
}
}

func boolTake13(t *testing.T) {
g := Bools(0.5)

Expand Down
24 changes: 24 additions & 0 deletions utils/encoding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,30 @@ func TestHexDecode(t *testing.T) {
expected: nil,
expectedErr: true,
},
{
name: "valid input with uppercase hex characters",
input: "0x48656C6C6F",
expected: []byte("Hello"),
expectedErr: false,
},
{
name: "valid input with mixed case hex characters",
input: "0x48656c6C6F",
expected: []byte("Hello"),
expectedErr: false,
},
{
name: "input with leading zeros",
input: "0x00000068656c6c6f",
expected: append([]byte{0, 0, 0}, []byte("hello")...),
expectedErr: false,
},
{
name: "input with trailing zeros",
input: "0x68656c6c6f000000",
expected: append([]byte("hello"), 0, 0, 0),
expectedErr: false,
},
}

for _, test := range tests {
Expand Down
5 changes: 3 additions & 2 deletions vald/tss/tss_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/stretchr/testify/assert"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/test/bufconn"
)

Expand All @@ -27,7 +28,7 @@ func TestGRPCTimeout(t *testing.T) {
ctx,
"",
grpc.WithContextDialer(func(context.Context, string) (net.Conn, error) { return listener.Dial() }),
grpc.WithInsecure(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithBlock(),
)
assert.NoError(t, err)
Expand All @@ -36,7 +37,7 @@ func TestGRPCTimeout(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Millisecond)
defer cancel()

_, err := grpc.DialContext(ctx, "", grpc.WithInsecure(), grpc.WithBlock())
_, err := grpc.DialContext(ctx, "target", grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock())
assert.Equal(t, context.DeadlineExceeded, err)
})
}
81 changes: 81 additions & 0 deletions x/permission/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package keeper_test

import (
"testing"

"github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
sdk "github.com/cosmos/cosmos-sdk/types"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/stretchr/testify/assert"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

"github.com/axelarnetwork/axelar-core/app"
"github.com/axelarnetwork/axelar-core/testutils/fake"
"github.com/axelarnetwork/axelar-core/x/permission/keeper"
"github.com/axelarnetwork/axelar-core/x/permission/types"
. "github.com/axelarnetwork/utils/test"
)

func TestGrpcQuery(t *testing.T) {
cfg := app.MakeEncodingConfig()
var (
k keeper.Keeper
ctx sdk.Context
initialGenesis *types.GenesisState
governanceKey multisig.LegacyAminoPubKey
params types.Params
)

Given("a keeper",
func() {
subspace := paramstypes.NewSubspace(cfg.Codec, cfg.Amino, sdk.NewKVStoreKey("paramsKey"), sdk.NewKVStoreKey("tparamsKey"), "permission")
k = keeper.NewKeeper(cfg.Codec, sdk.NewKVStoreKey(types.StoreKey), subspace)
}).
Given("a state that is initialized",
func() {
initialGenesis = types.NewGenesisState(types.Params{}, randomMultisigGovernanceKey(), randomGovAccounts())
assert.NoError(t, initialGenesis.Validate())

ctx = sdk.NewContext(fake.NewMultiStore(), tmproto.Header{}, false, log.TestingLogger())
k.InitGenesis(ctx, initialGenesis)
}).
When("querying the governance key",
func() {
req := &types.QueryGovernanceKeyRequest{}
resp, err := k.GovernanceKey(sdk.WrapSDKContext(ctx), req)
assert.NotNil(t, resp)
assert.Nil(t, err)
governanceKey = resp.GovernanceKey
}).
Then("return the expected key",
func(t *testing.T) {
assert.Equal(t, *initialGenesis.GovernanceKey, governanceKey)
}).Run(t, 10)

Given("a keeper",
func() {
subspace := paramstypes.NewSubspace(cfg.Codec, cfg.Amino, sdk.NewKVStoreKey("paramsKey"), sdk.NewKVStoreKey("tparamsKey"), "permission")
k = keeper.NewKeeper(cfg.Codec, sdk.NewKVStoreKey(types.StoreKey), subspace)
}).
Given("a state that is initialized",
func() {
initialGenesis = types.NewGenesisState(types.Params{}, randomMultisigGovernanceKey(), randomGovAccounts())
assert.NoError(t, initialGenesis.Validate())

ctx = sdk.NewContext(fake.NewMultiStore(), tmproto.Header{}, false, log.TestingLogger())
k.InitGenesis(ctx, initialGenesis)
}).
When("querying params",
func() {
req := &types.ParamsRequest{}
resp, err := k.Params(sdk.WrapSDKContext(ctx), req)
assert.NotNil(t, resp)
assert.Nil(t, err)
params = resp.Params
}).
Then("return the expected params",
func(t *testing.T) {
assert.Equal(t, initialGenesis.Params, params)
}).Run(t, 10)
}

0 comments on commit f0f7a57

Please sign in to comment.