Skip to content

Commit

Permalink
Test fixes, removed upgrade module
Browse files Browse the repository at this point in the history
  • Loading branch information
Satchitananda committed Dec 15, 2023
1 parent 61f099c commit 2d35cc3
Show file tree
Hide file tree
Showing 48 changed files with 36 additions and 10,421 deletions.
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ COPY ./ /core
RUN apt-get update && apt-get install -y ca-certificates && update-ca-certificates
RUN apt-get update && apt-get install -y wget

RUN wget https://github.com/WebAssembly/wabt/releases/download/1.0.17/wabt-1.0.17-ubuntu.tar.gz
RUN tar -zxf wabt-1.0.17-ubuntu.tar.gz
RUN cp wabt-1.0.17/bin/wat2wasm /usr/local/bin

RUN make install && make faucet

COPY ./docker-config/validator1/ validator1/
Expand Down
4 changes: 4 additions & 0 deletions Dockerfile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ COPY ./ /core
RUN apt-get update && apt-get install -y ca-certificates && update-ca-certificates
RUN apt-get update && apt-get install -y wget

RUN wget https://github.com/WebAssembly/wabt/releases/download/1.0.17/wabt-1.0.17-ubuntu.tar.gz
RUN tar -zxf wabt-1.0.17-ubuntu.tar.gz
RUN cp wabt-1.0.17/bin/wat2wasm /usr/local/bin

RUN make install && make faucet

COPY ./docker-config/validator1/ validator1/
Expand Down
33 changes: 21 additions & 12 deletions cmd/odind/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,16 +214,7 @@ func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts serverty
// }

homeDir := cast.ToString(appOpts.Get(flags.FlagHome))
chainID := cast.ToString(appOpts.Get(flags.FlagChainID))
if chainID == "" {
// fallback to genesis chain-id
appGenesis, err := tmtypes.GenesisDocFromFile(filepath.Join(homeDir, "config", "genesis.json"))
if err != nil {
panic(err)
}

chainID = appGenesis.ChainID
}
chainID := getChainId(appOpts)

snapshotDir := filepath.Join(homeDir, "data", "snapshots")
if err = os.MkdirAll(snapshotDir, os.ModePerm); err != nil {
Expand Down Expand Up @@ -280,21 +271,39 @@ func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts serverty
return odinApp
}

func getChainId(appOpts servertypes.AppOptions) string {
homeDir := cast.ToString(appOpts.Get(flags.FlagHome))
chainID := cast.ToString(appOpts.Get(flags.FlagChainID))
if chainID == "" {
// fallback to genesis chain-id
appGenesis, err := tmtypes.GenesisDocFromFile(filepath.Join(homeDir, "config", "genesis.json"))
if err != nil {
panic(err)
}

chainID = appGenesis.ChainID
}
return chainID
}

func createSimappAndExport(
logger log.Logger, db dbm.DB, traceStore io.Writer, height int64, forZeroHeight bool, jailAllowedAddrs []string,
appOpts servertypes.AppOptions, modulesToExport []string,
) (servertypes.ExportedApp, error) {
encCfg := odin.MakeEncodingConfig() // Ideally, we would reuse the one created by NewRootCmd.
encCfg.Marshaler = codec.NewProtoCodec(encCfg.InterfaceRegistry)
var odinConsumerApp *odin.OdinApp

chainID := getChainId(appOpts)

if height != -1 {
odinConsumerApp = odin.NewOdinApp(logger, db, traceStore, false, map[int64]bool{}, "", uint(1), encCfg, appOpts, false, cast.ToUint32(appOpts.Get(flagWithOwasmCacheSize)))
odinConsumerApp = odin.NewOdinApp(logger, db, traceStore, false, map[int64]bool{}, "", uint(1), encCfg, appOpts, false, cast.ToUint32(appOpts.Get(flagWithOwasmCacheSize)), baseapp.SetChainID(chainID))

if err := odinConsumerApp.LoadHeight(height); err != nil {
return servertypes.ExportedApp{}, err
}
} else {
odinConsumerApp = odin.NewOdinApp(logger, db, traceStore, true, map[int64]bool{}, "", uint(1), encCfg, appOpts, false, cast.ToUint32(appOpts.Get(flagWithOwasmCacheSize)))
odinConsumerApp = odin.NewOdinApp(logger, db, traceStore, true, map[int64]bool{}, "", uint(1), encCfg, appOpts, false, cast.ToUint32(appOpts.Get(flagWithOwasmCacheSize)), baseapp.SetChainID(chainID))
}

return odinConsumerApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs, modulesToExport)
Expand Down
3 changes: 2 additions & 1 deletion x/common/testapp/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
odinapp "github.com/ODIN-PROTOCOL/odin-core/app"
me "github.com/ODIN-PROTOCOL/odin-core/x/oracle/keeper"
oracletypes "github.com/ODIN-PROTOCOL/odin-core/x/oracle/types"
"github.com/cosmos/cosmos-sdk/baseapp"
)

const (
Expand Down Expand Up @@ -92,7 +93,7 @@ func NewSimApp(chainID string, logger log.Logger) *odinapp.OdinApp {

db := dbm.NewMemDB()
encCdc := odinapp.MakeEncodingConfig()
app := odinapp.NewOdinApp(logger, db, nil, true, map[int64]bool{}, dir, 0, encCdc, EmptyAppOptions{}, false, 0)
app := odinapp.NewOdinApp(logger, db, nil, true, map[int64]bool{}, dir, 0, encCdc, EmptyAppOptions{}, false, 0, baseapp.SetChainID("ODINCHAIN"))

genesis := odinapp.NewDefaultGenesisState()
acc := []authtypes.GenesisAccount{
Expand Down
4 changes: 3 additions & 1 deletion x/common/testapp/testapp_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package testapp
import (
"encoding/json"

"github.com/cosmos/cosmos-sdk/baseapp"

dbm "github.com/cometbft/cometbft-db"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/log"
Expand Down Expand Up @@ -76,7 +78,7 @@ func NewTestAppBuilder(dir string, logger log.Logger) TestAppBuilder {

db := dbm.NewMemDB()
encCdc := odinapp.MakeEncodingConfig()
builder.app = odinapp.NewOdinApp(logger, db, nil, true, map[int64]bool{}, dir, 0, encCdc, EmptyAppOptions{}, false, 0)
builder.app = odinapp.NewOdinApp(logger, db, nil, true, map[int64]bool{}, dir, 0, encCdc, EmptyAppOptions{}, false, 0, baseapp.SetChainID("ODINCHAIN"))
return &builder
}

Expand Down
4 changes: 2 additions & 2 deletions x/oracle/keeper/owasm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func TestPrepareRequestSuccessBasicNotEnoughFund(t *testing.T) {
// OracleScript#1: Prepare asks for DS#1,2,3 with ExtID#1,2,3 and calldata "beeb"
m := oracletypes.NewMsgRequestData(1, BasicCalldata, 1, 1, BasicClientID, testapp.Coins100000000loki, oracletypes.DefaultPrepareGas, oracletypes.DefaultExecuteGas, testapp.Alice.Address)
_, err := k.PrepareRequest(ctx, m, testapp.Alice.Address, nil)
require.EqualError(t, err, "0loki is smaller than 1000000loki: insufficient funds")
require.EqualError(t, err, "spendable balance is smaller than 1000000loki: insufficient funds")
}

func TestPrepareRequestNotEnoughPrepareGas(t *testing.T) {
Expand Down Expand Up @@ -733,7 +733,7 @@ func TestCollectFeeWithEnoughFeeButInsufficientBalance(t *testing.T) {
require.Nil(t, coins)
// MAX is 100m but have only 1m in account
// First ds collect 1m so there no balance enough for next ds but it doesn't touch limit
require.EqualError(t, err, "1000000loki is smaller than 100000000loki: insufficient funds")
require.EqualError(t, err, "spendable balance 1000000loki is smaller than 100000000loki: insufficient funds")
}

func TestCollectFeeWithWithManyUnitSuccess(t *testing.T) {
Expand Down
Loading

0 comments on commit 2d35cc3

Please sign in to comment.