2018-04-11 15:41:51 +00:00
|
|
|
package whisper
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
2020-01-02 09:10:19 +00:00
|
|
|
"github.com/stretchr/testify/suite"
|
|
|
|
|
2018-06-08 11:29:50 +00:00
|
|
|
"github.com/status-im/status-go/node"
|
2018-07-21 15:32:53 +00:00
|
|
|
"github.com/status-im/status-go/t/utils"
|
2018-04-11 15:41:51 +00:00
|
|
|
)
|
|
|
|
|
2018-04-13 05:52:22 +00:00
|
|
|
func TestWhisperExtensionSuite(t *testing.T) {
|
|
|
|
suite.Run(t, new(WhisperExtensionSuite))
|
2018-04-11 15:41:51 +00:00
|
|
|
}
|
|
|
|
|
2018-04-13 05:52:22 +00:00
|
|
|
type WhisperExtensionSuite struct {
|
2018-04-11 15:41:51 +00:00
|
|
|
suite.Suite
|
|
|
|
|
|
|
|
nodes []*node.StatusNode
|
|
|
|
}
|
|
|
|
|
2018-04-13 05:52:22 +00:00
|
|
|
func (s *WhisperExtensionSuite) SetupTest() {
|
2018-04-11 15:41:51 +00:00
|
|
|
s.nodes = make([]*node.StatusNode, 2)
|
|
|
|
for i := range s.nodes {
|
|
|
|
dir, err := ioutil.TempDir("", "test-shhext-")
|
|
|
|
s.NoError(err)
|
|
|
|
// network id is irrelevant
|
2018-09-21 14:09:31 +00:00
|
|
|
cfg, err := utils.MakeTestNodeConfigWithDataDir(fmt.Sprintf("test-shhext-%d", i), dir, 777)
|
2018-07-25 14:03:35 +00:00
|
|
|
s.Require().NoError(err)
|
2018-04-11 15:41:51 +00:00
|
|
|
s.nodes[i] = node.New()
|
2019-08-20 15:38:40 +00:00
|
|
|
s.Require().NoError(s.nodes[i].Start(cfg, nil))
|
2018-04-11 15:41:51 +00:00
|
|
|
}
|
2018-04-13 05:52:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *WhisperExtensionSuite) TearDown() {
|
2018-04-11 15:41:51 +00:00
|
|
|
for _, n := range s.nodes {
|
2018-04-16 12:36:09 +00:00
|
|
|
cfg := n.Config()
|
|
|
|
s.NotNil(cfg)
|
2018-04-11 15:41:51 +00:00
|
|
|
s.NoError(n.Stop())
|
|
|
|
s.NoError(os.Remove(cfg.DataDir))
|
|
|
|
}
|
|
|
|
}
|