mirror of
https://github.com/status-im/status-go.git
synced 2025-01-13 16:16:18 +00:00
use s.Require() in Whisper tests
This commit is contained in:
parent
24aa1b0f1c
commit
adbc7b5ae6
@ -44,7 +44,7 @@ func (s *WhisperJailTestSuite) StartTestBackend(opts ...e2e.TestNodeOption) {
|
|||||||
s.Timeout = time.Minute * 5
|
s.Timeout = time.Minute * 5
|
||||||
s.WhisperAPI = whisper.NewPublicWhisperAPI(s.WhisperService())
|
s.WhisperAPI = whisper.NewPublicWhisperAPI(s.WhisperService())
|
||||||
s.Jail = s.Backend.JailManager()
|
s.Jail = s.Backend.JailManager()
|
||||||
s.NotNil(s.Jail)
|
s.Require().NotNil(s.Jail)
|
||||||
s.Jail.SetBaseJS(baseStatusJSCode)
|
s.Jail.SetBaseJS(baseStatusJSCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,11 +63,13 @@ func (s *WhisperJailTestSuite) TestJailWhisper() {
|
|||||||
s.StartTestBackend()
|
s.StartTestBackend()
|
||||||
defer s.StopTestBackend()
|
defer s.StopTestBackend()
|
||||||
|
|
||||||
|
r := s.Require()
|
||||||
|
|
||||||
keyPairID1, err := s.AddKeyPair(TestConfig.Account1.Address, TestConfig.Account1.Password)
|
keyPairID1, err := s.AddKeyPair(TestConfig.Account1.Address, TestConfig.Account1.Password)
|
||||||
s.NoError(err)
|
r.NoError(err)
|
||||||
|
|
||||||
keyPairID2, err := s.AddKeyPair(TestConfig.Account2.Address, TestConfig.Account2.Password)
|
keyPairID2, err := s.AddKeyPair(TestConfig.Account2.Address, TestConfig.Account2.Password)
|
||||||
s.NoError(err)
|
r.NoError(err)
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
@ -294,11 +296,11 @@ func (s *WhisperJailTestSuite) TestJailWhisper() {
|
|||||||
s.Jail.CreateAndInitCell(chatID, makeTopicCode)
|
s.Jail.CreateAndInitCell(chatID, makeTopicCode)
|
||||||
|
|
||||||
cell, err := s.Jail.Cell(chatID)
|
cell, err := s.Jail.Cell(chatID)
|
||||||
s.NoError(err, "cannot get VM")
|
r.NoError(err, "cannot get VM")
|
||||||
|
|
||||||
// Run JS code that setups filters and sends messages.
|
// Run JS code that setups filters and sends messages.
|
||||||
_, err = cell.Run(tc.code)
|
_, err = cell.Run(tc.code)
|
||||||
s.NoError(err)
|
r.NoError(err)
|
||||||
|
|
||||||
if !tc.useFilter {
|
if !tc.useFilter {
|
||||||
continue
|
continue
|
||||||
@ -320,15 +322,15 @@ func (s *WhisperJailTestSuite) TestJailWhisper() {
|
|||||||
poll_loop:
|
poll_loop:
|
||||||
for {
|
for {
|
||||||
filter, err := cell.Get("filter")
|
filter, err := cell.Get("filter")
|
||||||
s.NoError(err, "cannot get filter")
|
r.NoError(err, "cannot get filter")
|
||||||
filterID, err := filter.Object().Get("filterId")
|
filterID, err := filter.Object().Get("filterId")
|
||||||
s.NoError(err, "cannot get filterId")
|
r.NoError(err, "cannot get filterId")
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-done:
|
case <-done:
|
||||||
ok, err := s.WhisperAPI.DeleteMessageFilter(filterID.String())
|
ok, err := s.WhisperAPI.DeleteMessageFilter(filterID.String())
|
||||||
s.NoError(err)
|
r.NoError(err)
|
||||||
s.True(ok)
|
r.True(ok)
|
||||||
break poll_loop
|
break poll_loop
|
||||||
case <-timedOut:
|
case <-timedOut:
|
||||||
s.FailNow("polling for messages timed out")
|
s.FailNow("polling for messages timed out")
|
||||||
@ -341,13 +343,13 @@ func (s *WhisperJailTestSuite) TestJailWhisper() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
payload, err := cell.Get("payload")
|
payload, err := cell.Get("payload")
|
||||||
s.NoError(err, "cannot get payload")
|
r.NoError(err, "cannot get payload")
|
||||||
|
|
||||||
messages, err := s.WhisperAPI.GetFilterMessages(filterID.String())
|
messages, err := s.WhisperAPI.GetFilterMessages(filterID.String())
|
||||||
s.NoError(err)
|
r.NoError(err)
|
||||||
|
|
||||||
for _, m := range messages {
|
for _, m := range messages {
|
||||||
s.Equal(payload.String(), string(m.Payload))
|
r.Equal(payload.String(), string(m.Payload))
|
||||||
close(done)
|
close(done)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user