mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
* 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
51 lines
847 B
Go
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()
|
|
}
|