Skip to content

Commit

Permalink
Expand unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePiachu committed Apr 18, 2017
1 parent 0b5565c commit 2aad277
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions state/factoidstate_test.go
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/FactomProject/factomd/common/constants"
"github.com/FactomProject/factomd/common/interfaces"
"github.com/FactomProject/factomd/common/primitives"
"github.com/FactomProject/factomd/common/primitives/random"
. "github.com/FactomProject/factomd/state"
)

Expand Down Expand Up @@ -173,6 +174,20 @@ func TestGetMapHash(t *testing.T) {
if h2.String() != "fd9b4c42a47115af0bf1878c7de793e28b021415f82ed7151ab0cbb7db941b31" {
t.Errorf("Invalid hash - got %v, expected %v", h2.String(), "fd9b4c42a47115af0bf1878c7de793e28b021415f82ed7151ab0cbb7db941b31")
}

for i := 0; i < 1000; i++ {
bmap = map[[32]byte]int64{}
l := random.RandIntBetween(0, 100)
for j := 0; j < l; j++ {
bmap[primitives.RandomHash().Fixed()] = random.RandInt64()
}
h2 = GetMapHash(uint32(i), bmap)
for j := 0; j < 10; j++ {
if h2.IsSameAs(GetMapHash(uint32(i), bmap)) == false {
t.Errorf("GetMapHash returns inconsistent hashes")
}
}
}
}

/*
Expand Down

0 comments on commit 2aad277

Please sign in to comment.