github.com/koko1123/flow-go-1@v0.29.6/admin/commands/storage/read_transactions_test.go (about)

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