prysm-pulse/sharding/p2p/service_test.go
Preston Van Loon 6caef73f7b Add inequality tests
Former-commit-id: d04fa104faa112ae600e2115022e0d240bbf6bb7 [formerly d9c71078256ba3c96dc977f2078e16c561f79436]
Former-commit-id: d403c1c30c3fc6d76fb70c499ec7bca7c0877ade
2018-06-12 08:48:05 -04:00

41 lines
980 B
Go

package p2p
import (
"testing"
"github.com/ethereum/go-ethereum/sharding"
)
// Verifies that Server implements the ShardP2P interface.
var _ = sharding.ShardP2P(&Server{})
func TestFeed_ReturnsSameFeed(t *testing.T) {
tests := []struct {
a interface{}
b interface{}
want bool
}{
// Equalality tests
{a: 1, b: 2, want: true},
{a: 'a', b: 'b', want: true},
{a: struct{ c int }{c: 1}, b: struct{ c int }{c: 2}, want: true},
{a: struct{ c string }{c: "a"}, b: struct{ c string }{c: "b"}, want: true},
// Inequality tests
{a: 1, b: '2', want: false},
{a: 'a', b: 1, want: false},
{a: struct{ c int }{c: 1}, b: struct{ c int64 }{c: 2}, want: false},
{a: struct{ c string }{c: "a"}, b: struct{ c float64 }{c: 3.4}, want: false},
}
s, _ := NewServer()
for _, tt := range tests {
feed1, _ := s.Feed(tt.a)
feed2, _ := s.Feed(tt.b)
if (feed1 == feed2) != tt.want {
t.Errorf("Expected %v == %v to be %t", feed1, feed2, tt.want)
}
}
}