This repository has been archived by the owner on Jul 30, 2024. It is now read-only.
forked from b-harvest/Canto
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from b-harvest/abci1.0/patch/2-add-ommitted-gen…
…state-govshuttle fix!: add omitted port conatract address on govshuttle genesis state
- Loading branch information
Showing
6 changed files
with
162 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
package govshuttle_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"github.com/stretchr/testify/suite" | ||
|
||
"github.com/cosmos/cosmos-sdk/simapp" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
"github.com/tendermint/tendermint/libs/log" | ||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types" | ||
dbm "github.com/tendermint/tm-db" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/evmos/ethermint/encoding" | ||
|
||
"github.com/Canto-Network/Canto/v7/app" | ||
"github.com/Canto-Network/Canto/v7/x/govshuttle" | ||
) | ||
|
||
type GenesisTestSuite struct { | ||
suite.Suite //top level testing suite | ||
|
||
appA *app.Canto | ||
ctxA sdk.Context | ||
|
||
appB *app.Canto | ||
ctxB sdk.Context | ||
} | ||
|
||
var s *GenesisTestSuite | ||
|
||
func TestGenesisTestSuite(t *testing.T) { | ||
s = new(GenesisTestSuite) | ||
suite.Run(t, s) | ||
} | ||
|
||
func (suite *GenesisTestSuite) DoSetupTest(t require.TestingT) { | ||
|
||
encCfg := encoding.MakeConfig(app.ModuleBasics) | ||
|
||
suite.appA = app.NewCanto( | ||
log.NewNopLogger(), | ||
dbm.NewMemDB(), | ||
nil, | ||
true, | ||
make(map[int64]bool), | ||
app.DefaultNodeHome, | ||
0, | ||
false, | ||
encCfg, | ||
simapp.EmptyAppOptions{}, | ||
) | ||
suite.ctxA = suite.appA.NewContext(true, tmproto.Header{}) | ||
|
||
suite.appB = app.NewCanto( | ||
log.NewNopLogger(), | ||
dbm.NewMemDB(), | ||
nil, | ||
true, | ||
make(map[int64]bool), | ||
app.DefaultNodeHome, | ||
0, | ||
false, | ||
encCfg, | ||
simapp.EmptyAppOptions{}, | ||
) | ||
suite.ctxB = suite.appB.NewContext(true, tmproto.Header{}) | ||
} | ||
|
||
func (suite *GenesisTestSuite) SetupTest() { | ||
suite.DoSetupTest(suite.T()) | ||
} | ||
|
||
func (suite *GenesisTestSuite) TestGenesis() { | ||
testCases := []struct { | ||
name string | ||
portAddr common.Address | ||
malleate func(portAddr common.Address) | ||
}{ | ||
{ | ||
"empty port contract address", | ||
common.Address{}, | ||
func(_ common.Address) {}, | ||
}, | ||
{ | ||
"non-empty port contract address", | ||
common.HexToAddress("0x648a5Aa0C4FbF2C1CF5a3B432c2766EeaF8E402d"), | ||
func(portAddr common.Address) { | ||
suite.appA.GovshuttleKeeper.SetPort(suite.ctxA, portAddr) | ||
}, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
suite.Run(tc.name, func() { | ||
suite.SetupTest() | ||
|
||
tc.malleate(tc.portAddr) | ||
|
||
portAddr, _ := suite.appA.GovshuttleKeeper.GetPort(suite.ctxA) | ||
suite.Require().Equal(tc.portAddr, portAddr) | ||
|
||
genesisState := govshuttle.ExportGenesis(suite.ctxA, suite.appA.GovshuttleKeeper) | ||
|
||
govshuttle.InitGenesis(suite.ctxB, suite.appB.GovshuttleKeeper, suite.appB.AccountKeeper, *genesisState) | ||
portAddr, _ = suite.appB.GovshuttleKeeper.GetPort(suite.ctxB) | ||
suite.Require().Equal(tc.portAddr, portAddr) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.