Post whisper message asynchronously in tests

I am not 100% percent sure what is happening but it seems that
newMessageFilter is async operation, result of this operation is assumed
to be used in callbacks. All other tests are doing at least 1 io operation
in between creating a filter and posting a message, and it must be enough
for newMessageFilter to complete.

Setting higher GOMAXPROCS allows Otto vm to execute received io requests
immediatly. While lower number of processes may result in events re-ordering.

https://github.com/ethereum/web3.js/blob/develop/lib/web3/methods/shh.js#L39-L41

I tested this change with GOMAXPROCS=1 and it passes consistently.
This commit is contained in:
Dmitry Shulyak 2018-03-02 20:43:08 +02:00 committed by Ivan Daniluk
parent 7aec65b976
commit a5cec358a9
1 changed files with 17 additions and 21 deletions

View File

@ -1,7 +1,6 @@
package whisper
import (
"runtime"
"testing"
"time"
@ -66,11 +65,6 @@ func (s *WhisperJailTestSuite) TestJailWhisper() {
r := s.Require()
// Increase number of OS threads that can run go code simultaneously.
// Some test cases (namely test 3) require a higher number of parallel
// go routines to successfully complete without hanging.
runtime.GOMAXPROCS(3)
keyPairID1, err := s.AddKeyPair(TestConfig.Account1.Address, TestConfig.Account1.Password)
r.NoError(err)
@ -192,7 +186,8 @@ func (s *WhisperJailTestSuite) TestJailWhisper() {
topics: [topic],
symKeyID: keyid
});
// creating a filter is an async operation
setTimeout(function() {
// post message
var message = {
ttl: 10,
@ -207,6 +202,7 @@ func (s *WhisperJailTestSuite) TestJailWhisper() {
if (!sent) {
throw 'message not sent: ' + JSON.stringify(message);
}
}, 0)
`,
true,
},