test: Add test for free tx lane (#305)
This commit is contained in:
parent
25ac0bd7c2
commit
8d514000cf
@ -5,6 +5,15 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/skip-mev/chaintestutil/network"
|
||||
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
|
||||
"cosmossdk.io/math"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
|
||||
tmcli "github.com/cometbft/cometbft/libs/cli"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/stretchr/testify/suite"
|
||||
@ -114,3 +123,52 @@ func (s *NetworkTestSuite) QueryBlockSDKLanes() (*blocksdktypes.QueryLanesRespon
|
||||
client := blocksdktypes.NewQueryClient(cc)
|
||||
return client.Lanes(context.Background(), &blocksdktypes.QueryLanesRequest{})
|
||||
}
|
||||
|
||||
func (s *NetworkTestSuite) TestFreeTxNoFees() {
|
||||
val := s.NetworkSuite.Network.Validators[0]
|
||||
acc := *s.Accounts[0]
|
||||
|
||||
cc, closeConn, err := s.NetworkSuite.GetGRPC()
|
||||
s.Require().NoError(err)
|
||||
defer closeConn()
|
||||
|
||||
// Get original acc balance
|
||||
bankClient := banktypes.NewQueryClient(cc)
|
||||
resp, err := bankClient.Balance(context.Background(), &banktypes.QueryBalanceRequest{
|
||||
Address: acc.Address().String(),
|
||||
Denom: s.NetworkSuite.Network.Config.BondDenom,
|
||||
})
|
||||
require.NoError(s.T(), err)
|
||||
originalBalance := resp.Balance.Amount
|
||||
|
||||
// Send a free tx (delegation)
|
||||
coin := sdk.NewCoin(s.NetworkSuite.Network.Config.BondDenom, math.NewInt(10))
|
||||
txBz, err := s.NetworkSuite.CreateTxBytes(
|
||||
context.Background(),
|
||||
network.TxGenInfo{
|
||||
Account: acc,
|
||||
GasLimit: 999999999,
|
||||
TimeoutHeight: 999999999,
|
||||
Fee: sdk.NewCoins(coin),
|
||||
},
|
||||
&stakingtypes.MsgDelegate{
|
||||
DelegatorAddress: acc.Address().String(),
|
||||
ValidatorAddress: val.ValAddress.String(),
|
||||
Amount: coin,
|
||||
},
|
||||
)
|
||||
require.NoError(s.T(), err)
|
||||
bcastResp, err := val.RPCClient.BroadcastTxCommit(context.Background(), txBz)
|
||||
require.NoError(s.T(), err)
|
||||
require.Equal(s.T(), uint32(0), bcastResp.CheckTx.Code)
|
||||
require.Equal(s.T(), uint32(0), bcastResp.TxResult.Code)
|
||||
|
||||
// Get updated acc balance
|
||||
resp, err = bankClient.Balance(context.Background(), &banktypes.QueryBalanceRequest{
|
||||
Address: acc.Address().String(),
|
||||
Denom: s.NetworkSuite.Network.Config.BondDenom,
|
||||
})
|
||||
require.NoError(s.T(), err)
|
||||
// Assert update acc balance is equal to original balance less the delegation
|
||||
require.Equal(s.T(), originalBalance.Sub(coin.Amount), resp.Balance.Amount)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user