2018-01-31 08:27:08 +00:00
|
|
|
package network
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2018-01-31 19:11:08 +00:00
|
|
|
|
2018-02-01 18:54:23 +00:00
|
|
|
"github.com/CityOfZion/neo-go/pkg/network/payload"
|
2018-01-31 08:27:08 +00:00
|
|
|
)
|
|
|
|
|
2018-02-04 19:54:51 +00:00
|
|
|
// TODO this should be moved to localPeer test.
|
|
|
|
|
2018-02-02 10:02:25 +00:00
|
|
|
func TestHandleVersionFailWrongPort(t *testing.T) {
|
2018-02-09 16:08:50 +00:00
|
|
|
s := NewServer(ModePrivNet)
|
2018-02-02 10:02:25 +00:00
|
|
|
go s.loop()
|
|
|
|
|
|
|
|
p := NewLocalPeer(s)
|
|
|
|
|
|
|
|
version := payload.NewVersion(1337, 1, "/NEO:0.0.0/", 0, true)
|
2018-02-07 14:16:50 +00:00
|
|
|
if err := s.handleVersionCmd(version, p); err == nil {
|
2018-02-02 10:02:25 +00:00
|
|
|
t.Fatal("expected error got nil")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestHandleVersionFailIdenticalNonce(t *testing.T) {
|
2018-02-09 16:08:50 +00:00
|
|
|
s := NewServer(ModePrivNet)
|
2018-02-02 10:02:25 +00:00
|
|
|
go s.loop()
|
|
|
|
|
|
|
|
p := NewLocalPeer(s)
|
|
|
|
|
|
|
|
version := payload.NewVersion(s.id, 1, "/NEO:0.0.0/", 0, true)
|
2018-02-07 14:16:50 +00:00
|
|
|
if err := s.handleVersionCmd(version, p); err == nil {
|
2018-02-02 10:02:25 +00:00
|
|
|
t.Fatal("expected error got nil")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-31 08:27:08 +00:00
|
|
|
func TestHandleVersion(t *testing.T) {
|
2018-02-09 16:08:50 +00:00
|
|
|
s := NewServer(ModePrivNet)
|
2018-01-31 19:11:08 +00:00
|
|
|
go s.loop()
|
|
|
|
|
|
|
|
p := NewLocalPeer(s)
|
|
|
|
|
|
|
|
version := payload.NewVersion(1337, p.addr().Port, "/NEO:0.0.0/", 0, true)
|
2018-02-07 14:16:50 +00:00
|
|
|
if err := s.handleVersionCmd(version, p); err != nil {
|
2018-02-02 10:02:25 +00:00
|
|
|
t.Fatal(err)
|
2018-01-31 19:11:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestHandleAddrCmd(t *testing.T) {
|
|
|
|
// todo
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestHandleGetAddrCmd(t *testing.T) {
|
|
|
|
// todo
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestHandleInv(t *testing.T) {
|
|
|
|
// todo
|
|
|
|
}
|
|
|
|
func TestHandleBlockCmd(t *testing.T) {
|
|
|
|
// todo
|
2018-01-31 08:27:08 +00:00
|
|
|
}
|