util: drop Endpoint structure, fix #321
I think it's useless, buggy and hides parsing errors for no good reason.
This commit is contained in:
parent
a039ae6cdb
commit
8d9bc83214
9 changed files with 50 additions and 85 deletions
|
@ -3,23 +3,26 @@ package payload
|
|||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"net"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/CityOfZion/neo-go/pkg/util"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestEncodeDecodeAddress(t *testing.T) {
|
||||
var (
|
||||
e = util.NewEndpoint("127.0.0.1:2000")
|
||||
e, _ = net.ResolveTCPAddr("tcp", "127.0.0.1:2000")
|
||||
ts = time.Now()
|
||||
addr = NewAddressAndTime(e, ts)
|
||||
buf = new(bytes.Buffer)
|
||||
)
|
||||
|
||||
assert.Equal(t, ts.UTC().Unix(), int64(addr.Timestamp))
|
||||
assert.Equal(t, e, addr.Endpoint)
|
||||
aatip := make(net.IP, 16)
|
||||
copy(aatip, addr.IP[:])
|
||||
assert.Equal(t, e.IP, aatip)
|
||||
assert.Equal(t, e.Port, int(addr.Port))
|
||||
err := addr.EncodeBinary(buf)
|
||||
assert.Nil(t, err)
|
||||
|
||||
|
@ -34,7 +37,7 @@ func TestEncodeDecodeAddressList(t *testing.T) {
|
|||
var lenList uint8 = 4
|
||||
addrList := &AddressList{make([]*AddressAndTime, lenList)}
|
||||
for i := 0; i < int(lenList); i++ {
|
||||
e := util.NewEndpoint(fmt.Sprintf("127.0.0.1:200%d", i))
|
||||
e, _ := net.ResolveTCPAddr("tcp", fmt.Sprintf("127.0.0.1:200%d", i))
|
||||
addrList.Addrs[i] = NewAddressAndTime(e, time.Now())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue