From 1d51515945e950f8bbe8b40e8da0b4ff437a7f62 Mon Sep 17 00:00:00 2001 From: Bruce Marriner Date: Wed, 10 Apr 2019 01:02:19 +0000 Subject: [PATCH] An attempt at catching race issues --- snowflake_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/snowflake_test.go b/snowflake_test.go index 2f25f22..a454e5a 100644 --- a/snowflake_test.go +++ b/snowflake_test.go @@ -6,6 +6,25 @@ import ( "testing" ) +// I feel like there's probably a better way +func TestRace(t *testing.T) { + + node, _ := NewNode(1) + + go func() { + for i := 0; i < 1000000000; i++ { + + NewNode(1) + } + }() + + for i := 0; i < 4000; i++ { + + node.Generate() + } + +} + func TestMarshalJSON(t *testing.T) { id := ID(13587) expected := "\"13587\"" @@ -112,6 +131,7 @@ func TestBase58(t *testing.T) { } } } + func BenchmarkParseBase58(b *testing.B) { node, _ := NewNode(1)