Skip to content

Commit

Permalink
Fix UT deadlock when testing with > 1 GPU
Browse files Browse the repository at this point in the history
  • Loading branch information
poszu committed Mar 12, 2024
1 parent adb52d6 commit 2540b19
Showing 1 changed file with 29 additions and 27 deletions.
56 changes: 29 additions & 27 deletions internal/postrs/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,34 +49,36 @@ func TestScryptPositions(t *testing.T) {
var prevOutput []byte
var nonce *uint64
for _, p := range providers {
scrypt, err := NewScrypt(
WithProviderID(p.ID),
WithCommitment(commitment),
WithVRFDifficulty(vrfDifficulty),
WithScryptN(32),
WithLogger(zaptest.NewLogger(t, zaptest.Level(zap.DebugLevel))),
)
require.NoError(t, err)
require.NotNil(t, scrypt)
defer scrypt.Close()

res, err := scrypt.Positions(start, end)
require.NoError(t, err)
require.NotNil(t, res)
require.NotNil(t, res.Output)

// assert that output content is equal between different providers.
if prevOutput == nil {
prevOutput = res.Output
} else {
require.Equal(t, prevOutput, res.Output, fmt.Sprintf("not equal: provider: %+v", p))
}
t.Run(p.Model, func(t *testing.T) {
scrypt, err := NewScrypt(
WithProviderID(p.ID),
WithCommitment(commitment),
WithVRFDifficulty(vrfDifficulty),
WithScryptN(32),
WithLogger(zaptest.NewLogger(t, zaptest.Level(zap.DebugLevel))),
)
require.NoError(t, err)
require.NotNil(t, scrypt)
defer scrypt.Close()

if nonce == nil {
nonce = res.IdxSolution
} else {
require.Equal(t, *nonce, *res.IdxSolution)
}
res, err := scrypt.Positions(start, end)
require.NoError(t, err)
require.NotNil(t, res)
require.NotNil(t, res.Output)

// assert that output content is equal between different providers.
if prevOutput == nil {
prevOutput = res.Output
} else {
require.Equal(t, prevOutput, res.Output, fmt.Sprintf("not equal: provider: %+v", p))
}

if nonce == nil {
nonce = res.IdxSolution
} else {
require.Equal(t, *nonce, *res.IdxSolution)
}
})
}

require.NotNil(t, prevOutput)
Expand Down

0 comments on commit 2540b19

Please sign in to comment.