github.com/koko1123/flow-go-1@v0.29.6/engine/access/rest/request/address_test.go (about) 1 package request 2 3 import ( 4 "strings" 5 "testing" 6 7 "github.com/stretchr/testify/assert" 8 ) 9 10 func TestAddress_InvalidParse(t *testing.T) { 11 var address Address 12 inputs := []string{ 13 "0x1", 14 "", 15 "foo", 16 "1", 17 "@", 18 "ead892083b3e2c61222", 19 } 20 21 for _, input := range inputs { 22 err := address.Parse(input) 23 assert.EqualError(t, err, "invalid address") 24 } 25 } 26 27 func TestAddress_ValidParse(t *testing.T) { 28 var address Address 29 inputs := []string{ 30 "f8d6e0586b0a20c7", 31 "f3ad66eea58c97d2", 32 "0xead892083b3e2c6c", 33 } 34 35 for _, input := range inputs { 36 err := address.Parse(input) 37 assert.NoError(t, err) 38 assert.Equal(t, strings.ReplaceAll(input, "0x", ""), address.Flow().String()) 39 } 40 }