Files
gocryptotrader/exchanges/stream/stream_match_test.go
Scott 63257ce4ca Improvement: Speeding up slow tests (#707)
* Speeds up tests

* Reduces time.Sleeps, lowers CreateTestBot complexity. Breaks things

* Removal of unecessary config reads. Parallel tests. Lower times

* Speeds up recent trades results

* mini update

* zoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooom

* Removes the dupes

* Lint

* post cherrypick

* Fix rare kraken data race

* Fixes banking global issues. Fixes postgres trades

* rmline for appveyor test

* Expands timeout in event that channel is closed before send

* Fix data race

* No rows, no bows and definitely no shows

* Removes parallel from createsnapshot tests

* Extends timedmutext test a smidge. Exchange fatality

* Shorter end timeframe and bigger candle
2021-07-07 12:42:03 +10:00

52 lines
827 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")
}
data := <-m.C
if data != nil {
t.Fatal("wow")
}
m.Cleanup()
}