github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/engine/access/rest/request/get_account_test.go (about)

     1  package request
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/assert"
     8  
     9  	"github.com/onflow/flow-go/model/flow"
    10  )
    11  
    12  func Test_GetAccount_InvalidParse(t *testing.T) {
    13  	var getAccount GetAccount
    14  
    15  	tests := []struct {
    16  		address string
    17  		height  string
    18  		err     string
    19  	}{
    20  		{"", "", "invalid address"},
    21  		{"f8d6e0586b0a20c7", "-1", "invalid height format"},
    22  	}
    23  
    24  	chain := flow.Localnet.Chain()
    25  	for i, test := range tests {
    26  		err := getAccount.Parse(test.address, test.height, chain)
    27  		assert.EqualError(t, err, test.err, fmt.Sprintf("test #%d failed", i))
    28  	}
    29  }
    30  
    31  func Test_GetAccount_ValidParse(t *testing.T) {
    32  	var getAccount GetAccount
    33  
    34  	addr := "f8d6e0586b0a20c7"
    35  	chain := flow.Localnet.Chain()
    36  	err := getAccount.Parse(addr, "", chain)
    37  	assert.NoError(t, err)
    38  	assert.Equal(t, getAccount.Address.String(), addr)
    39  	assert.Equal(t, getAccount.Height, SealedHeight)
    40  
    41  	err = getAccount.Parse(addr, "100", chain)
    42  	assert.NoError(t, err)
    43  	assert.Equal(t, getAccount.Height, uint64(100))
    44  }