Skip to content

Commit

Permalink
fix(tests): TestAuthorModule_HasSessionKeys_Integration (#2932)
Browse files Browse the repository at this point in the history
- Fix test occasionally failing due to data race
  • Loading branch information
qdm12 authored Nov 15, 2022
1 parent ec2549a commit 8d809aa
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions dot/rpc/modules/author_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,6 @@ func TestAuthorModule_HasKey_Integration(t *testing.T) {

func TestAuthorModule_HasSessionKeys_Integration(t *testing.T) {
t.Parallel()
integrationTestController := setupStateAndRuntime(t, t.TempDir(), useInstanceFromGenesis)
auth := newAuthorModule(t, integrationTestController)

const granSeed = "0xf25586ceb64a043d887631fa08c2ed790ef7ae3c7f28de5172005f8b9469e529"
const granPubK = "0x6b802349d948444d41397da09ec597fbd8ae8fdd3dfa153b2bb2bddcf020457c"
Expand All @@ -474,17 +472,6 @@ func TestAuthorModule_HasSessionKeys_Integration(t *testing.T) {
},
}

for _, toInsert := range insertSessionKeys {
for _, keytype := range toInsert.ktype {
err := auth.InsertKey(nil, &KeyInsertRequest{
Type: keytype,
Seed: toInsert.seed,
PublicKey: toInsert.pubk,
}, nil)
require.NoError(t, err)
}
}

testcases := map[string]struct {
pubSessionKeys string
expect bool
Expand Down Expand Up @@ -527,6 +514,20 @@ func TestAuthorModule_HasSessionKeys_Integration(t *testing.T) {
tt := tt
t.Run(tname, func(t *testing.T) {
t.Parallel()

integrationTestController := setupStateAndRuntime(t, t.TempDir(), useInstanceFromGenesis)
auth := newAuthorModule(t, integrationTestController)
for _, toInsert := range insertSessionKeys {
for _, keytype := range toInsert.ktype {
err := auth.InsertKey(nil, &KeyInsertRequest{
Type: keytype,
Seed: toInsert.seed,
PublicKey: toInsert.pubk,
}, nil)
require.NoError(t, err)
}
}

req := HasSessionKeyRequest{
PublicKeys: tt.pubSessionKeys,
}
Expand Down

0 comments on commit 8d809aa

Please sign in to comment.