github.com/Finschia/ostracon@v1.1.5/mempool/mempool_test.go (about) 1 package mempool 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/require" 7 8 abci "github.com/Finschia/ostracon/abci/types" 9 ) 10 11 func TestPostCheckMaxGas(t *testing.T) { 12 tests := []struct { 13 res *abci.ResponseCheckTx 14 postCheck PostCheckFunc 15 ok bool 16 }{ 17 {&abci.ResponseCheckTx{GasWanted: 10}, PostCheckMaxGas(10), true}, 18 {&abci.ResponseCheckTx{GasWanted: 10}, PostCheckMaxGas(-1), true}, 19 {&abci.ResponseCheckTx{GasWanted: -1}, PostCheckMaxGas(10), false}, 20 {&abci.ResponseCheckTx{GasWanted: 11}, PostCheckMaxGas(10), false}, 21 } 22 for tcIndex, tt := range tests { 23 err := tt.postCheck(nil, tt.res) 24 if tt.ok { 25 require.NoError(t, err, "postCheck should not return error, on test case %d", tcIndex) 26 } else { 27 require.Error(t, err, "postCheck should return error, on test case %d", tcIndex) 28 } 29 } 30 }