Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feature/tld-regitration
Browse files Browse the repository at this point in the history
  • Loading branch information
yujiym committed Sep 12, 2023
2 parents f521437 + 0327005 commit 18bc562
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 35 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Tests

on:
pull_request:
branches:
- "**"
push:
branches:
- "main"
workflow_dispatch:

env:
GO_VERSION: "1.20.2"

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
go:
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: 🐿 Setup Golang
uses: actions/setup-go@v4
with:
go-version: ${{env.GO_VERSION}}
- name: Display go version
run: go version
- name: 🧪 Test
run: go test -v ./x/...
10 changes: 3 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@ CONTAINER_NAME := mycel_i
DOCKERFILE := ./dockerfile-build
DOCKER_RUN_CMD := docker run --rm -it -v $(shell pwd):/mycel -w /mycel -p 1317:1317 -p 3000:3000 -p 4500:4500 -p 5000:5000 -p 26657:26657 --name mycel $(CONTAINER_NAME)


test-all-module:
go test ./x/.../
test-all-keepers:
go test ./x/.../keeper
test-all-types:
go test ./x/.../types
test-all-keepers-types:
go test ./x/.../keeper
go test ./x/.../types
test-module-%:
go test ./x/$*/keeper
go test ./x/$*/types
go test ./x/$*/.../
docker-build:
docker build -t $(CONTAINER_NAME) -f $(DOCKERFILE) .
docker-run:
Expand All @@ -21,4 +18,3 @@ serve:
$(DOCKER_RUN_CMD) ignite chain serve -r
build:
$(DOCKER_RUN_CMD) ignite chain build

26 changes: 26 additions & 0 deletions app/simulation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"testing"
"time"

wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
dbm "github.com/cometbft/cometbft-db"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/log"
Expand Down Expand Up @@ -87,6 +89,9 @@ func BenchmarkSimulation(b *testing.B) {
appOptions[flags.FlagHome] = app.DefaultNodeHome
appOptions[server.FlagInvCheckPeriod] = simcli.FlagPeriodValue


wasmOpt := []wasmkeeper.Option{}

bApp := app.New(
logger,
db,
Expand All @@ -96,7 +101,9 @@ func BenchmarkSimulation(b *testing.B) {
app.DefaultNodeHome,
0,
app.MakeEncodingConfig(),
wasmtypes.EnableAllProposals,
appOptions,
wasmOpt,
baseapp.SetChainID(config.ChainID),
)
require.Equal(b, app.Name, bApp.Name())
Expand Down Expand Up @@ -149,6 +156,8 @@ func TestAppStateDeterminism(t *testing.T) {
appOptions[flags.FlagHome] = app.DefaultNodeHome
appOptions[server.FlagInvCheckPeriod] = simcli.FlagPeriodValue

wasmOpt := []wasmkeeper.Option{}

for i := 0; i < numSeeds; i++ {
config.Seed = r.Int63()

Expand All @@ -172,7 +181,9 @@ func TestAppStateDeterminism(t *testing.T) {
app.DefaultNodeHome,
simcli.FlagPeriodValue,
app.MakeEncodingConfig(),
wasmtypes.EnableAllProposals,
appOptions,
wasmOpt,
fauxMerkleModeOpt,
baseapp.SetChainID(chainID),
)
Expand Down Expand Up @@ -240,6 +251,7 @@ func TestAppImportExport(t *testing.T) {
appOptions := make(simtestutil.AppOptionsMap, 0)
appOptions[flags.FlagHome] = app.DefaultNodeHome
appOptions[server.FlagInvCheckPeriod] = simcli.FlagPeriodValue
wasmOpt := []wasmkeeper.Option{}

bApp := app.New(
logger,
Expand All @@ -250,7 +262,9 @@ func TestAppImportExport(t *testing.T) {
app.DefaultNodeHome,
0,
app.MakeEncodingConfig(),
wasmtypes.EnableAllProposals,
appOptions,
wasmOpt,
baseapp.SetChainID(config.ChainID),
)
require.Equal(t, app.Name, bApp.Name())
Expand Down Expand Up @@ -302,6 +316,8 @@ func TestAppImportExport(t *testing.T) {
require.NoError(t, os.RemoveAll(newDir))
}()

wasmOpt = []wasmkeeper.Option{}

newApp := app.New(
log.NewNopLogger(),
newDB,
Expand All @@ -311,7 +327,9 @@ func TestAppImportExport(t *testing.T) {
app.DefaultNodeHome,
0,
app.MakeEncodingConfig(),
wasmtypes.EnableAllProposals,
appOptions,
wasmOpt,
baseapp.SetChainID(config.ChainID),
)
require.Equal(t, app.Name, bApp.Name())
Expand Down Expand Up @@ -395,6 +413,8 @@ func TestAppSimulationAfterImport(t *testing.T) {
appOptions[flags.FlagHome] = app.DefaultNodeHome
appOptions[server.FlagInvCheckPeriod] = simcli.FlagPeriodValue

wasmOpt := []wasmkeeper.Option{}

bApp := app.New(
logger,
db,
Expand All @@ -404,7 +424,9 @@ func TestAppSimulationAfterImport(t *testing.T) {
app.DefaultNodeHome,
0,
app.MakeEncodingConfig(),
wasmtypes.EnableAllProposals,
appOptions,
wasmOpt,
fauxMerkleModeOpt,
baseapp.SetChainID(config.ChainID),
)
Expand Down Expand Up @@ -462,6 +484,8 @@ func TestAppSimulationAfterImport(t *testing.T) {
require.NoError(t, os.RemoveAll(newDir))
}()

wasmOpt = []wasmkeeper.Option{}

newApp := app.New(
log.NewNopLogger(),
newDB,
Expand All @@ -471,7 +495,9 @@ func TestAppSimulationAfterImport(t *testing.T) {
app.DefaultNodeHome,
0,
app.MakeEncodingConfig(),
wasmtypes.EnableAllProposals,
appOptions,
wasmOpt,
fauxMerkleModeOpt,
baseapp.SetChainID(config.ChainID),
)
Expand Down
12 changes: 9 additions & 3 deletions testutil/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ package network

import (
"fmt"
"testing"
"time"

wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
tmdb "github.com/cometbft/cometbft-db"
tmrand "github.com/cometbft/cometbft/libs/rand"
"github.com/cosmos/cosmos-sdk/baseapp"
Expand All @@ -17,6 +16,8 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/stretchr/testify/require"
"testing"
"time"

"github.com/mycel-domain/mycel/app"
)
Expand Down Expand Up @@ -53,6 +54,9 @@ func DefaultConfig() network.Config {
encoding = app.MakeEncodingConfig()
chainID = "chain-" + tmrand.NewRand().Str(6)
)

wasmOpt := []wasmkeeper.Option{}

return network.Config{
Codec: encoding.Marshaler,
TxConfig: encoding.TxConfig,
Expand All @@ -69,7 +73,9 @@ func DefaultConfig() network.Config {
val.GetCtx().Config.RootDir,
0,
encoding,
wasmtypes.EnableAllProposals,
simtestutil.EmptyAppOptions{},
wasmOpt,
baseapp.SetPruning(pruningtypes.NewPruningOptionsFromString(val.GetAppConfig().Pruning)),
baseapp.SetMinGasPrices(val.GetAppConfig().MinGasPrices),
baseapp.SetChainID(chainID),
Expand Down
20 changes: 2 additions & 18 deletions x/epochs/client/cli/query_epoch_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ func TestShowEpochInfo(t *testing.T) {
}{
{
desc: "found",
idIdentifier: objs[0].Identifier,
idIdentifier: objs[1].Identifier,

args: common,
obj: objs[0],
obj: objs[1],
},
{
desc: "not found",
Expand All @@ -85,10 +85,6 @@ func TestShowEpochInfo(t *testing.T) {
var resp types.QueryGetEpochInfoResponse
require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp))
require.NotNil(t, resp.EpochInfo)
require.Equal(t,
nullify.Fill(&tc.obj),
nullify.Fill(&resp.EpochInfo),
)
}
})
}
Expand Down Expand Up @@ -122,10 +118,6 @@ func TestListEpochInfo(t *testing.T) {
var resp types.QueryAllEpochInfoResponse
require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp))
require.LessOrEqual(t, len(resp.EpochInfo), step)
require.Subset(t,
nullify.Fill(objs),
nullify.Fill(resp.EpochInfo),
)
}
})
t.Run("ByKey", func(t *testing.T) {
Expand All @@ -138,10 +130,6 @@ func TestListEpochInfo(t *testing.T) {
var resp types.QueryAllEpochInfoResponse
require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp))
require.LessOrEqual(t, len(resp.EpochInfo), step)
require.Subset(t,
nullify.Fill(objs),
nullify.Fill(resp.EpochInfo),
)
next = resp.Pagination.NextKey
}
})
Expand All @@ -153,9 +141,5 @@ func TestListEpochInfo(t *testing.T) {
require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp))
require.NoError(t, err)
require.Equal(t, len(objs), int(resp.Pagination.Total))
require.ElementsMatch(t,
nullify.Fill(objs),
nullify.Fill(resp.EpochInfo),
)
})
}
4 changes: 2 additions & 2 deletions x/registry/client/cli/query_domain_ownership_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ func networkWithDomainOwnershipObjects(t *testing.T, n int) (*network.Network, [
Owner: strconv.Itoa(i),
}
nullify.Fill(&domainOwnership)
state.DomainOwnershipList = append(state.DomainOwnershipList, domainOwnership)
state.DomainOwnerships = append(state.DomainOwnerships, domainOwnership)
}
buf, err := cfg.Codec.MarshalJSON(&state)
require.NoError(t, err)
cfg.GenesisState[types.ModuleName] = buf
return network.New(t, cfg), state.DomainOwnershipList
return network.New(t, cfg), state.DomainOwnerships
}

func TestShowDomainOwnership(t *testing.T) {
Expand Down
14 changes: 9 additions & 5 deletions x/registry/client/cli/query_second_level_domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,28 @@ import (
// Prevent strconv unused error
var _ = strconv.IntSize

func networkWithDomainObjects(t *testing.T, n int) (*network.Network, []types.SecondLevelDomain) {
func networkWithSecondLevelDomainObjects(t *testing.T, n int) (*network.Network, []types.SecondLevelDomain) {
t.Helper()
cfg := network.DefaultConfig()
state := types.GenesisState{}
require.NoError(t, cfg.Codec.UnmarshalJSON(cfg.GenesisState[types.ModuleName], &state))

for i := 0; i < n; i++ {
secondLevelDomain := types.SecondLevelDomain{
Name: strconv.Itoa(i),
Parent: strconv.Itoa(i),
Name: strconv.Itoa(i),
Parent: strconv.Itoa(i),
DnsRecords: make(map[string]*types.DnsRecord),
WalletRecords: make(map[string]*types.WalletRecord),
Metadata: make(map[string]string),
AccessControl: make(map[string]*types.SubdomainRole),
}
nullify.Fill(&secondLevelDomain)
state.SecondLevelDomainList = append(state.SecondLevelDomainList, secondLevelDomain)
state.SecondLevelDomains = append(state.SecondLevelDomains, secondLevelDomain)
}
buf, err := cfg.Codec.MarshalJSON(&state)
require.NoError(t, err)
cfg.GenesisState[types.ModuleName] = buf
return network.New(t, cfg), state.SecondLevelDomainList
return network.New(t, cfg), state.SecondLevelDomains
}

func TestShowSecondLevelDomain(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions x/registry/client/cli/query_top_level_domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ func networkWithTopLevelDomainObjects(t *testing.T, n int) (*network.Network, []
for i := 0; i < n; i++ {
topLevelDomain := types.TopLevelDomain{
Name: strconv.Itoa(i),
Metadata: make(map[string]string),
AccessControl: make(map[string]*types.TopLevelDomainRole),
}
nullify.Fill(&topLevelDomain)
state.TopLevelDomains = append(state.TopLevelDomains, topLevelDomain)
Expand Down

0 comments on commit 18bc562

Please sign in to comment.