Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cashu/nuts/nut13/nut13.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,16 @@ func CheckCollidingKeysets(currentKeysetIds []string, newMintKeysetIds []string)

for j := range newMintKeysetIds {
if currentKeysetIds[i] == newMintKeysetIds[j] {
return fmt.Errorf("%w. KeysetId: %+v", ErrCollidingKeysetId, currentKeysetIds[i])
return fmt.Errorf("%w. KeysetId: %+v. New KeysetId: %+v", ErrCollidingKeysetId, currentKeysetIds[i], newMintKeysetIds[j])
}

keysetIdIntToCompare, err := keysetIdToBigInt(newMintKeysetIds[j])
if err != nil {
return err
}

if keysetIdInt == keysetIdIntToCompare {
return fmt.Errorf("%w. KeysetId: %+v", ErrCollidingKeysetId, currentKeysetIds[i])
if keysetIdInt.Cmp(keysetIdIntToCompare) == 0 {
return fmt.Errorf("%w. KeysetId: %+v. New KeysetId: %+v", ErrCollidingKeysetId, currentKeysetIds[i], newMintKeysetIds[j])
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions cashu/nuts/nut13/nut13_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func TestCollisionOfIdNoCollision(t *testing.T) {
t.Errorf("There should not have been any keyset collision")
}
}

func TestCollisionOfIdWithCollision(t *testing.T) {
keysetId := []string{"009a1f293253e41e", "009a1f293253e41d"}

Expand All @@ -96,3 +97,14 @@ func TestCollisionOfIdWithCollision(t *testing.T) {
t.Errorf("there should have been a keyset collition error")
}
}

func TestCollitionForIntegerValues(t *testing.T) {
currentKeysetIds := []string{"00682d5c11e19b7c"}
newKeysetIds := []string{"0059051691ffec07"}

err := CheckCollidingKeysets(currentKeysetIds, newKeysetIds)

if !errors.Is(err, ErrCollidingKeysetId) {
t.Errorf("there should have been a keyset collition error based on the big int value")
}
}