github.com/ari-anchor/sei-tendermint@v0.0.0-20230519144642-dc826b7b56bb/internal/state/tx_filter_test.go (about) 1 package state_test 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 "github.com/stretchr/testify/require" 8 9 sm "github.com/ari-anchor/sei-tendermint/internal/state" 10 tmrand "github.com/ari-anchor/sei-tendermint/libs/rand" 11 "github.com/ari-anchor/sei-tendermint/types" 12 ) 13 14 func TestTxFilter(t *testing.T) { 15 genDoc := randomGenesisDoc() 16 genDoc.ConsensusParams.Block.MaxBytes = 3000 17 genDoc.ConsensusParams.Evidence.MaxBytes = 1500 18 19 // Max size of Txs is much smaller than size of block, 20 // since we need to account for commits and evidence. 21 testCases := []struct { 22 tx types.Tx 23 isErr bool 24 }{ 25 {types.Tx(tmrand.Bytes(2155)), false}, 26 {types.Tx(tmrand.Bytes(2156)), true}, 27 {types.Tx(tmrand.Bytes(3000)), true}, 28 } 29 30 for i, tc := range testCases { 31 state, err := sm.MakeGenesisState(genDoc) 32 require.NoError(t, err) 33 34 f := sm.TxPreCheckForState(state) 35 if tc.isErr { 36 assert.NotNil(t, f(tc.tx), "#%v", i) 37 } else { 38 assert.Nil(t, f(tc.tx), "#%v", i) 39 } 40 } 41 }