e2e: wait and get message before asserting empty list (#610)

* e2e: wait and get message before asserting empty list

* Added comments

* remove redundant checks

* remove redundant check

* address review comments
This commit is contained in:
Federico Gimenez 2018-02-05 14:40:27 +01:00 committed by Dmitry Shulyak
parent 607954bfc3
commit 13454e827b
1 changed files with 6 additions and 5 deletions

View File

@ -83,16 +83,17 @@ func (s *WhisperMailboxSuite) TestRequestMessageFromMailboxAsync() {
messages := s.getMessagesByMessageFilterID(rpcClient, messageFilterID)
s.Require().Equal(0, len(messages))
//Post message
//Post message matching with filter (key and token)
s.postMessageToPrivate(rpcClient, pubkey.String(), topic.String(), hexutil.Encode([]byte("Hello world!")))
//There are no messages, because it's a sender filter
//Get message to make sure that it will come from the mailbox later
time.Sleep(1 * time.Second)
messages = s.getMessagesByMessageFilterID(rpcClient, messageFilterID)
s.Require().Equal(0, len(messages))
s.Require().Equal(1, len(messages))
//act
//Request messages from mailbox
//Request messages (including the previous one, expired) from mailbox
reqMessagesBody := `{
"jsonrpc": "2.0",
"id": 1,
@ -113,7 +114,7 @@ func (s *WhisperMailboxSuite) TestRequestMessageFromMailboxAsync() {
//wait to receive message
time.Sleep(time.Second)
//And we receive message
//And we receive message, it comes from mailbox
messages = s.getMessagesByMessageFilterID(rpcClient, messageFilterID)
s.Require().Equal(1, len(messages))