* Enable gometalinter on tests and fix static analysis issues * Remove unneeded change * Fix additional lint errors * Add nolint directives and error checks * Add error assertions instead of nolint directives * Go back to using lint directive for loop.Run goroutine * Add error check to loop.Run
This commit is contained in:
parent
a4c36fe96a
commit
365bc662a2
|
@ -5,6 +5,7 @@
|
||||||
],
|
],
|
||||||
"Skip": ["helpers", "static"],
|
"Skip": ["helpers", "static"],
|
||||||
"Vendor": true,
|
"Vendor": true,
|
||||||
|
"Test": true,
|
||||||
"Enable": [
|
"Enable": [
|
||||||
"deadcode",
|
"deadcode",
|
||||||
"errcheck",
|
"errcheck",
|
||||||
|
|
|
@ -151,7 +151,10 @@ func (s *CellTestSuite) TestCellFetchErrorRace() {
|
||||||
// Find a free port in localhost
|
// Find a free port in localhost
|
||||||
freeportListener, err := net.Listen("tcp", "127.0.0.1:0")
|
freeportListener, err := net.Listen("tcp", "127.0.0.1:0")
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
defer freeportListener.Close()
|
defer func() {
|
||||||
|
err := freeportListener.Close()
|
||||||
|
s.NoError(err)
|
||||||
|
}()
|
||||||
|
|
||||||
// Send an HTTP request to the free port that we found above
|
// Send an HTTP request to the free port that we found above
|
||||||
_, err = cell.Run(fmt.Sprintf(`fetch('%s').then(function(r) {
|
_, err = cell.Run(fmt.Sprintf(`fetch('%s').then(function(r) {
|
||||||
|
@ -237,7 +240,8 @@ func (s *CellTestSuite) TestCellCallAsync() {
|
||||||
fn, err := s.cell.Get("testCallAsync")
|
fn, err := s.cell.Get("testCallAsync")
|
||||||
s.NoError(err)
|
s.NoError(err)
|
||||||
|
|
||||||
s.cell.CallAsync(fn, "success")
|
err = s.cell.CallAsync(fn, "success")
|
||||||
|
s.NoError(err)
|
||||||
s.Equal("success", <-datac)
|
s.Equal("success", <-datac)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,10 @@ func (s *LoopSuite) SetupTest() {
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
s.cancel = cancel
|
s.cancel = cancel
|
||||||
go s.loop.Run(ctx)
|
go func() {
|
||||||
|
err := s.loop.Run(ctx)
|
||||||
|
s.Equal(context.Canceled, err)
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *LoopSuite) TestAddAndReady() {
|
func (s *LoopSuite) TestAddAndReady() {
|
||||||
|
|
|
@ -27,7 +27,10 @@ func TestRequestMessagesFailures(t *testing.T) {
|
||||||
nodeA, nodeErr := node.New(&node.Config{NoUSB: true})
|
nodeA, nodeErr := node.New(&node.Config{NoUSB: true})
|
||||||
require.NoError(t, nodeErr)
|
require.NoError(t, nodeErr)
|
||||||
require.NoError(t, nodeA.Start())
|
require.NoError(t, nodeA.Start())
|
||||||
defer nodeA.Stop()
|
defer func() {
|
||||||
|
err := nodeA.Stop()
|
||||||
|
require.NoError(t, err)
|
||||||
|
}()
|
||||||
|
|
||||||
const (
|
const (
|
||||||
mailServerPeer = "enode://b7e65e1bedc2499ee6cbd806945af5e7df0e59e4070c96821570bd581473eade24a489f5ec95d060c0db118c879403ab88d827d3766978f28708989d35474f87@[::]:51920"
|
mailServerPeer = "enode://b7e65e1bedc2499ee6cbd806945af5e7df0e59e4070c96821570bd581473eade24a489f5ec95d060c0db118c879403ab88d827d3766978f28708989d35474f87@[::]:51920"
|
||||||
|
|
|
@ -19,7 +19,10 @@ func TestSubscribeServerEvents(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
err = node.Start()
|
err = node.Start()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer node.Stop()
|
defer func() {
|
||||||
|
err := node.Stop()
|
||||||
|
require.NoError(t, err)
|
||||||
|
}()
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
|
|
|
@ -26,7 +26,10 @@ func TestProfilingCPU(t *testing.T) {
|
||||||
// Verify that the file has some content.
|
// Verify that the file has some content.
|
||||||
file, err := os.Open(filepath.Join(dir, CPUFilename))
|
file, err := os.Open(filepath.Join(dir, CPUFilename))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer file.Close()
|
defer func() {
|
||||||
|
err := file.Close()
|
||||||
|
require.NoError(t, err)
|
||||||
|
}()
|
||||||
|
|
||||||
t.Logf("CPU profile saved in %s for %s", filepath.Join(dir, CPUFilename), os.Args[0])
|
t.Logf("CPU profile saved in %s for %s", filepath.Join(dir, CPUFilename), os.Args[0])
|
||||||
|
|
||||||
|
@ -45,7 +48,10 @@ func TestProfilingMem(t *testing.T) {
|
||||||
// Verify that the file has some content.
|
// Verify that the file has some content.
|
||||||
file, err := os.Open(filepath.Join(dir, MemFilename))
|
file, err := os.Open(filepath.Join(dir, MemFilename))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer file.Close()
|
defer func() {
|
||||||
|
err := file.Close()
|
||||||
|
require.NoError(t, err)
|
||||||
|
}()
|
||||||
|
|
||||||
t.Logf("Memory profile saved in %s for %s", filepath.Join(dir, MemFilename), os.Args[0])
|
t.Logf("Memory profile saved in %s for %s", filepath.Join(dir, MemFilename), os.Args[0])
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,10 @@ func (s *MailServiceSuite) TestShhRequestMessagesRPCMethodAvailability() {
|
||||||
r.NoError(err)
|
r.NoError(err)
|
||||||
resp, err := http.DefaultClient.Do(req)
|
resp, err := http.DefaultClient.Do(req)
|
||||||
r.NoError(err)
|
r.NoError(err)
|
||||||
defer resp.Body.Close()
|
defer func() {
|
||||||
|
err := resp.Body.Close()
|
||||||
|
r.NoError(err)
|
||||||
|
}()
|
||||||
r.Equal(200, resp.StatusCode)
|
r.Equal(200, resp.StatusCode)
|
||||||
data, err := ioutil.ReadAll(resp.Body)
|
data, err := ioutil.ReadAll(resp.Body)
|
||||||
r.NoError(err)
|
r.NoError(err)
|
||||||
|
|
|
@ -213,7 +213,8 @@ func (s *WhisperMailboxSuite) TestRequestMessagesInGroupChat() {
|
||||||
messages := s.getMessagesByMessageFilterID(bobRPCClient, bobMessageFilterID)
|
messages := s.getMessagesByMessageFilterID(bobRPCClient, bobMessageFilterID)
|
||||||
s.Require().Equal(1, len(messages))
|
s.Require().Equal(1, len(messages))
|
||||||
bobGroupChatData := groupChatParams{}
|
bobGroupChatData := groupChatParams{}
|
||||||
bobGroupChatData.Decode(messages[0]["payload"].(string))
|
err = bobGroupChatData.Decode(messages[0]["payload"].(string))
|
||||||
|
s.Require().NoError(err)
|
||||||
s.EqualValues(groupChatPayload, bobGroupChatData)
|
s.EqualValues(groupChatPayload, bobGroupChatData)
|
||||||
|
|
||||||
//2. bob add symkey to his node
|
//2. bob add symkey to his node
|
||||||
|
@ -228,7 +229,8 @@ func (s *WhisperMailboxSuite) TestRequestMessagesInGroupChat() {
|
||||||
messages = s.getMessagesByMessageFilterID(charlieRPCClient, charlieMessageFilterID)
|
messages = s.getMessagesByMessageFilterID(charlieRPCClient, charlieMessageFilterID)
|
||||||
s.Require().Equal(1, len(messages))
|
s.Require().Equal(1, len(messages))
|
||||||
charlieGroupChatData := groupChatParams{}
|
charlieGroupChatData := groupChatParams{}
|
||||||
charlieGroupChatData.Decode(messages[0]["payload"].(string))
|
err = charlieGroupChatData.Decode(messages[0]["payload"].(string))
|
||||||
|
s.Require().NoError(err)
|
||||||
s.EqualValues(groupChatPayload, charlieGroupChatData)
|
s.EqualValues(groupChatPayload, charlieGroupChatData)
|
||||||
|
|
||||||
//2. charlie add symkey to his node
|
//2. charlie add symkey to his node
|
||||||
|
@ -319,7 +321,8 @@ func (s *WhisperMailboxSuite) startBackend(name string) (*api.StatusBackend, fun
|
||||||
s.True(backend.IsNodeRunning())
|
s.True(backend.IsNodeRunning())
|
||||||
s.NoError(backend.StopNode())
|
s.NoError(backend.StopNode())
|
||||||
s.False(backend.IsNodeRunning())
|
s.False(backend.IsNodeRunning())
|
||||||
os.RemoveAll(datadir)
|
err = os.RemoveAll(datadir)
|
||||||
|
s.Require().NoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -346,7 +349,8 @@ func (s *WhisperMailboxSuite) startMailboxBackend() (*api.StatusBackend, func())
|
||||||
s.True(mailboxBackend.IsNodeRunning())
|
s.True(mailboxBackend.IsNodeRunning())
|
||||||
s.NoError(mailboxBackend.StopNode())
|
s.NoError(mailboxBackend.StopNode())
|
||||||
s.False(mailboxBackend.IsNodeRunning())
|
s.False(mailboxBackend.IsNodeRunning())
|
||||||
os.RemoveAll(datadir)
|
err = os.RemoveAll(datadir)
|
||||||
|
s.Require().NoError(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue