Skip to content

Commit

Permalink
fix(ipns): racy parallel tests writing to the same error variable (#371)
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias authored Jun 22, 2023
1 parent 417c5f7 commit 290613a
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions ipns/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,24 +222,22 @@ func TestValidate(t *testing.T) {
func TestValidateWithName(t *testing.T) {
t.Parallel()

sk, _, pid := mustKeyPair(t, ic.Ed25519)
sk, _, name := mustKeyPair(t, ic.Ed25519)
eol := time.Now().Add(time.Hour)

r, err := NewRecord(sk, testPath, 1, eol, 0)
require.NoError(t, err)
r := mustNewRecord(t, sk, testPath, 1, eol, 0)

t.Run("valid peer ID", func(t *testing.T) {
t.Parallel()

err = ValidateWithName(r, pid)
err := ValidateWithName(r, name)
assert.NoError(t, err)
})

t.Run("invalid peer ID", func(t *testing.T) {
t.Parallel()

_, _, pid2 := mustKeyPair(t, ic.Ed25519)
err = ValidateWithName(r, pid2)
_, _, name2 := mustKeyPair(t, ic.Ed25519)
err := ValidateWithName(r, name2)
assert.ErrorIs(t, err, ErrSignature)
})
}

0 comments on commit 290613a

Please sign in to comment.