From 61023f9fed0602040a104eba09702a4ceea9f29c Mon Sep 17 00:00:00 2001 From: Adrian Gallagher Date: Wed, 4 Oct 2017 17:22:44 +1100 Subject: [PATCH] Update nonce func and test coverage --- exchanges/nonce/nonce_test.go | 15 +++++++++++++++ testdata/configtest.dat | 8 ++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/exchanges/nonce/nonce_test.go b/exchanges/nonce/nonce_test.go index 74996d2c..e93968a8 100644 --- a/exchanges/nonce/nonce_test.go +++ b/exchanges/nonce/nonce_test.go @@ -60,11 +60,26 @@ func TestString(t *testing.T) { func TestGetValue(t *testing.T) { var nonce Nonce timeNowNano := strconv.FormatInt(time.Now().UnixNano(), 10) + time.Sleep(time.Millisecond * 100) nValue := nonce.GetValue("dingdong", true).String() if timeNowNano == nValue { t.Error("Test failed - GetValue() error, incorrect values") } + + if len(nValue) != 19 { + t.Error("Test failed - GetValue() error, incorrect values") + } + + timeNowUnix := nonce.GetValue("dongding", false) + if len(timeNowUnix.String()) != 10 { + t.Error("Test failed - GetValue() error, incorrect values") + } + + n := nonce.GetValue("dongding", false) + if n != timeNowUnix+1 { + t.Error("Test failed - GetValue() error, incorrect values") + } } func TestNonceConcurrency(t *testing.T) { diff --git a/testdata/configtest.dat b/testdata/configtest.dat index 2b8118b6..ca7b90f1 100644 --- a/testdata/configtest.dat +++ b/testdata/configtest.dat @@ -42,9 +42,9 @@ "Password": "12334", "Contacts": [ { - "Name": "StyleGherkin", - "Number": "1231424", - "Enabled": true + "name": "StyleGherkin", + "number": "1231424", + "enabled": true } ] }, @@ -436,4 +436,4 @@ } } ] -} +} \ No newline at end of file