Skip to content

Commit

Permalink
Fix failing utils unit test
Browse files Browse the repository at this point in the history
This commit fixes a test:
- fixes function names (no UUID but TxID)
- a SHA256 hash is 256 long, not 36 like the old
  UUID was
- fixes datatype in function that generates ID
  using custom algorithm

Change-Id: I63e096c41034278be5aa8651de3b4352ee7b378c
Signed-off-by: Gabor Hosszu <gabor@digitalasset.com>
  • Loading branch information
gaborh-da committed Aug 12, 2016
1 parent acac0e9 commit d9596b4
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions core/util/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,16 @@ func TestGenerateHashFromSignature(t *testing.T) {
}
}

func TestGenerateUUIDfromTxSHAHash(t *testing.T) {
uuid := GenerateUUIDfromTxSHAHash([]byte("foobar"))
if len(uuid) != 36 {
t.Fatalf("UUID length is not correct. Expected = 36, Got = %d", len(uuid))
}
uuid2 := GenerateUUIDfromTxSHAHash([]byte("foobar1"))
if uuid == uuid2 {
t.Fatalf("Two UUIDs are equal. This should never occur")
func TestGeneratIDfromTxSHAHash(t *testing.T) {
txid := GenerateIDfromTxSHAHash([]byte("foobar"))
txid2 := GenerateIDfromTxSHAHash([]byte("foobar1"))
if txid == txid2 {
t.Fatalf("Two TxIDs are equal. This should never occur")
}
}

func TestGenerateIDWithAlg(t *testing.T) {
_, err := GenerateIDWithAlg("sha256base64", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
_, err := GenerateIDWithAlg("sha256", []byte{1, 1, 1, 1})
if err != nil {
t.Fatalf("Decoder failure: %v", err)
}
Expand Down

0 comments on commit d9596b4

Please sign in to comment.