Files
gocryptotrader/exchanges/stream/stream_match_test.go
Adrian Gallagher f0d45aa1d2 golangci-lint/CI: Bump versions and introduce new linters (#798)
* golangci-lint/CI: Bump versions

Fix remaining linter issues

* Specifically set AppVeyor version

* Fix the infamous typos 👀

* Add go env cmd to AppVeyor

* Add go version cmd to AppVeyor

* Specify AppVeyor image, adjust linters

* Update go get to go install due to deprecation

* Bump golangci-lint timeout time for AppVeyor

* Change NW contract to NQ

* Address nitters

* GetRandomPair -> Pair{}

* Address nits

* Address time nitterinos plus additional tweaks

* More time inception upgrades!

* Bending time and space
2021-10-14 16:38:53 +11:00

51 lines
847 B
Go

package stream
import (
"fmt"
"testing"
)
func TestMatch(t *testing.T) {
t.Parallel()
bm := &Match{}
if bm.Incoming("wow") {
t.Fatal("Should not have matched")
}
nm := NewMatch()
// try to match with unset signature
if nm.Incoming("hello") {
t.Fatal("should not be able to match")
}
m, err := nm.set("hello")
if err != nil {
t.Fatal(err)
}
_, err = nm.set("hello")
if err == nil {
t.Fatal("error cannot be nil as this collision cannot occur")
}
if m.sig != "hello" {
t.Fatal(err)
}
// try and match with initial payload
if !nm.Incoming("hello") {
t.Fatal("should of matched")
}
// put in secondary payload with conflicting signature
if nm.Incoming("hello") {
fmt.Println("should not have been able to match")
}
if data := <-m.C; data != nil {
t.Fatal("data chan should be nil")
}
m.Cleanup()
}