forked from cerc-io/plugeth
ethclient, accounts/keystore: fix flaky tests (#23599)
* ethclient/gethclient: fix flaky test (due to map key ordering) * accounts/keystore: fix test failing due to rand collision due to low time resolution on windows
This commit is contained in:
parent
401354976b
commit
1b34283810
@ -96,7 +96,7 @@ func TestWatchNoDir(t *testing.T) {
|
|||||||
|
|
||||||
// Create ks but not the directory that it watches.
|
// Create ks but not the directory that it watches.
|
||||||
rand.Seed(time.Now().UnixNano())
|
rand.Seed(time.Now().UnixNano())
|
||||||
dir := filepath.Join(os.TempDir(), fmt.Sprintf("eth-keystore-watch-test-%d-%d", os.Getpid(), rand.Int()))
|
dir := filepath.Join(os.TempDir(), fmt.Sprintf("eth-keystore-watchnodir-test-%d-%d", os.Getpid(), rand.Int()))
|
||||||
ks := NewKeyStore(dir, LightScryptN, LightScryptP)
|
ks := NewKeyStore(dir, LightScryptN, LightScryptP)
|
||||||
|
|
||||||
list := ks.Accounts()
|
list := ks.Accounts()
|
||||||
@ -322,7 +322,7 @@ func TestUpdatedKeyfileContents(t *testing.T) {
|
|||||||
|
|
||||||
// Create a temporary kesytore to test with
|
// Create a temporary kesytore to test with
|
||||||
rand.Seed(time.Now().UnixNano())
|
rand.Seed(time.Now().UnixNano())
|
||||||
dir := filepath.Join(os.TempDir(), fmt.Sprintf("eth-keystore-watch-test-%d-%d", os.Getpid(), rand.Int()))
|
dir := filepath.Join(os.TempDir(), fmt.Sprintf("eth-keystore-updatedkeyfilecontents-test-%d-%d", os.Getpid(), rand.Int()))
|
||||||
ks := NewKeyStore(dir, LightScryptN, LightScryptP)
|
ks := NewKeyStore(dir, LightScryptN, LightScryptP)
|
||||||
|
|
||||||
list := ks.Accounts()
|
list := ks.Accounts()
|
||||||
|
@ -97,37 +97,40 @@ func TestGethClient(t *testing.T) {
|
|||||||
defer backend.Close()
|
defer backend.Close()
|
||||||
defer client.Close()
|
defer client.Close()
|
||||||
|
|
||||||
tests := map[string]struct {
|
tests := []struct {
|
||||||
|
name string
|
||||||
test func(t *testing.T)
|
test func(t *testing.T)
|
||||||
}{
|
}{
|
||||||
"TestAccessList": {
|
{
|
||||||
|
"TestAccessList",
|
||||||
func(t *testing.T) { testAccessList(t, client) },
|
func(t *testing.T) { testAccessList(t, client) },
|
||||||
},
|
},
|
||||||
"TestGetProof": {
|
{
|
||||||
|
"TestGetProof",
|
||||||
func(t *testing.T) { testGetProof(t, client) },
|
func(t *testing.T) { testGetProof(t, client) },
|
||||||
},
|
}, {
|
||||||
"TestGCStats": {
|
"TestGCStats",
|
||||||
func(t *testing.T) { testGCStats(t, client) },
|
func(t *testing.T) { testGCStats(t, client) },
|
||||||
},
|
}, {
|
||||||
"TestMemStats": {
|
"TestMemStats",
|
||||||
func(t *testing.T) { testMemStats(t, client) },
|
func(t *testing.T) { testMemStats(t, client) },
|
||||||
},
|
}, {
|
||||||
"TestGetNodeInfo": {
|
"TestGetNodeInfo",
|
||||||
func(t *testing.T) { testGetNodeInfo(t, client) },
|
func(t *testing.T) { testGetNodeInfo(t, client) },
|
||||||
},
|
}, {
|
||||||
"TestSetHead": {
|
"TestSetHead",
|
||||||
func(t *testing.T) { testSetHead(t, client) },
|
func(t *testing.T) { testSetHead(t, client) },
|
||||||
},
|
}, {
|
||||||
"TestSubscribePendingTxs": {
|
"TestSubscribePendingTxs",
|
||||||
func(t *testing.T) { testSubscribePendingTransactions(t, client) },
|
func(t *testing.T) { testSubscribePendingTransactions(t, client) },
|
||||||
},
|
}, {
|
||||||
"TestCallContract": {
|
"TestCallContract",
|
||||||
func(t *testing.T) { testCallContract(t, client) },
|
func(t *testing.T) { testCallContract(t, client) },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
for name, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(name, tt.test)
|
t.Run(tt.name, tt.test)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user