Files
gocryptotrader/ntpclient/ntpclient_test.go
Andrew a727beeb15 (BTC Markets): Wrapper SubmitOrder parameter order fix & IsOrderPlaced condition correction (#394)
* corrected param order Side -> Type, also corrected condition check for IsOrderPlaced

* send open status for GetActiveOrders

* GetActiveOrder() changes to include OrderID and status matching

* BTC Markets batch order limit fixes & SplitStringSliceByLimit  method

BTC markets batch end points have limits (20 for cancel 50 for query) adds new method SplitStringSliceByLimit in common to split a slice by limit and return slice of slice

* rm line :D

* Added test for SplitStringSliceByLimit and moved to const

* ntp client reworked to not return error if no valid time servers are found but default to system

* clean up

* new line added

* use TimeMgr sublogger and wording correction on output

* Moved to DialTimeout() & Removed SetDeadline call

* removed line

* added setdeadline fix

* goimport file

* removed unused error from NTPClient as we now default to system time if no server can be reached

* Added checks for number overflows

* converted to uint as you should not be passing a negative number in

* Increased test cases for NTPClient

* Removed Helper call as no longer outputting any data from function

* removed unused param
2019-12-16 14:47:54 +11:00

27 lines
586 B
Go

package ntpclient
import (
"reflect"
"testing"
"time"
)
func TestNTPClient(t *testing.T) {
pool := []string{"pool.ntp.org:123", "0.pool.ntp.org:123"}
v := NTPClient(pool)
if reflect.TypeOf(v) != reflect.TypeOf(time.Time{}) {
t.Errorf("NTPClient should return time.Time{}")
}
if v.IsZero() {
t.Error("NTPClient should return valid time received zero value")
}
const timeFormat = "2006-01-02T15:04:05"
if v.UTC().Format(timeFormat) != time.Now().UTC().Format(timeFormat) {
t.Errorf("NTPClient returned incorrect time received: %v", v.UTC().Format(timeFormat))
}
}