github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/admin/commands/storage/read_transactions_test.go (about) 1 package storage 2 3 import ( 4 "context" 5 "fmt" 6 "testing" 7 8 "github.com/stretchr/testify/require" 9 10 "github.com/onflow/flow-go/admin" 11 ) 12 13 func TestReadTransactionsRangeTooWide(t *testing.T) { 14 c := GetTransactionsCommand{} 15 16 data := map[string]interface{}{ 17 "start-height": float64(1), 18 "end-height": float64(10002), 19 } 20 21 req := &admin.CommandRequest{ 22 Data: data, 23 } 24 err := c.Validator(req) 25 require.NoError(t, err) 26 27 _, err = c.Handler(context.Background(), req) 28 require.Error(t, err) 29 require.Contains(t, fmt.Sprintf("%v", err), "more than 10001 blocks") 30 } 31 32 func TestReadTransactionsRangeInvalid(t *testing.T) { 33 c := GetTransactionsCommand{} 34 35 data := map[string]interface{}{ 36 "start-height": float64(1001), 37 "end-height": float64(1000), 38 } 39 err := c.Validator(&admin.CommandRequest{ 40 Data: data, 41 }) 42 require.Error(t, err) 43 require.Contains(t, fmt.Sprintf("%v", err), "should not be smaller") 44 } 45 46 func TestReadTransactionsMissingStart(t *testing.T) { 47 c := GetTransactionsCommand{} 48 49 data := map[string]interface{}{ 50 "start-height": float64(1001), 51 } 52 err := c.Validator(&admin.CommandRequest{ 53 Data: data, 54 }) 55 require.Error(t, err) 56 require.True(t, admin.IsInvalidAdminParameterError(err)) 57 } 58 59 func TestReadTransactionsMissingEnd(t *testing.T) { 60 c := GetTransactionsCommand{} 61 62 data := map[string]interface{}{ 63 "end-height": float64(1001), 64 } 65 err := c.Validator(&admin.CommandRequest{ 66 Data: data, 67 }) 68 require.Error(t, err) 69 require.True(t, admin.IsInvalidAdminParameterError(err)) 70 }