github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/ibc-go/modules/apps/29-fee/fee_test.go (about) 1 package fee_test 2 3 import ( 4 "testing" 5 6 types2 "github.com/fibonacci-chain/fbc/libs/tendermint/types" 7 8 clienttypes "github.com/fibonacci-chain/fbc/libs/ibc-go/modules/core/02-client/types" 9 channeltypes "github.com/fibonacci-chain/fbc/libs/ibc-go/modules/core/04-channel/types" 10 ibctesting "github.com/fibonacci-chain/fbc/libs/ibc-go/testing" 11 ibcmock "github.com/fibonacci-chain/fbc/libs/ibc-go/testing/mock" 12 13 "github.com/fibonacci-chain/fbc/libs/ibc-go/modules/apps/29-fee/types" 14 "github.com/stretchr/testify/suite" 15 ) 16 17 type FeeTestSuite struct { 18 suite.Suite 19 20 coordinator *ibctesting.Coordinator 21 22 chainA ibctesting.TestChainI 23 chainB ibctesting.TestChainI 24 chainC ibctesting.TestChainI 25 26 path *ibctesting.Path 27 pathAToC *ibctesting.Path 28 } 29 30 func (suite *FeeTestSuite) SetupTest() { 31 suite.coordinator = ibctesting.NewCoordinator(suite.T(), 3) 32 types2.UnittestOnlySetMilestoneVenus1Height(-1) 33 types2.UnittestOnlySetMilestoneVenus4Height(-1) 34 35 suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(0)) 36 suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(1)) 37 suite.chainC = suite.coordinator.GetChain(ibctesting.GetChainID(2)) 38 39 path := ibctesting.NewPath(suite.chainA, suite.chainB) 40 mockFeeVersion := string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: ibcmock.Version})) 41 path.EndpointA.ChannelConfig.Version = mockFeeVersion 42 path.EndpointB.ChannelConfig.Version = mockFeeVersion 43 path.EndpointA.ChannelConfig.PortID = ibctesting.MockFeePort 44 path.EndpointB.ChannelConfig.PortID = ibctesting.MockFeePort 45 suite.path = path 46 47 path = ibctesting.NewPath(suite.chainA, suite.chainC) 48 path.EndpointA.ChannelConfig.Version = mockFeeVersion 49 path.EndpointB.ChannelConfig.Version = mockFeeVersion 50 path.EndpointA.ChannelConfig.PortID = ibctesting.MockFeePort 51 path.EndpointB.ChannelConfig.PortID = ibctesting.MockFeePort 52 suite.pathAToC = path 53 } 54 55 func TestIBCFeeTestSuite(t *testing.T) { 56 suite.Run(t, new(FeeTestSuite)) 57 } 58 59 func (suite *FeeTestSuite) CreateMockPacket() channeltypes.Packet { 60 return channeltypes.NewPacket( 61 ibcmock.MockPacketData, 62 suite.chainA.SenderAccount().GetSequence(), 63 suite.path.EndpointA.ChannelConfig.PortID, 64 suite.path.EndpointA.ChannelID, 65 suite.path.EndpointB.ChannelConfig.PortID, 66 suite.path.EndpointB.ChannelID, 67 clienttypes.NewHeight(0, 100), 68 0, 69 ) 70 } 71 72 // helper function 73 func lockFeeModule(chain ibctesting.TestChainI) { 74 ctx := chain.GetContext() 75 storeKey := chain.GetSimApp().GetKey(types.ModuleName) 76 store := ctx.KVStore(storeKey) 77 store.Set(types.KeyLocked(), []byte{1}) 78 }