2018-03-02 09:25:30 +00:00
|
|
|
package node
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
|
|
|
|
|
2018-06-08 11:29:50 +00:00
|
|
|
"github.com/status-im/status-go/params"
|
2018-03-02 09:25:30 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestWhisperLightModeEnabledSetsEmptyBloomFilter(t *testing.T) {
|
2018-04-16 12:36:09 +00:00
|
|
|
config := params.NodeConfig{
|
|
|
|
WhisperConfig: ¶ms.WhisperConfig{
|
|
|
|
Enabled: true,
|
|
|
|
LightClient: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
node := New()
|
|
|
|
require.NoError(t, node.Start(&config))
|
2018-03-02 09:25:30 +00:00
|
|
|
defer func() {
|
2018-04-16 12:36:09 +00:00
|
|
|
require.NoError(t, node.Stop())
|
2018-03-02 09:25:30 +00:00
|
|
|
}()
|
|
|
|
|
|
|
|
var whisper *whisper.Whisper
|
2018-04-16 12:36:09 +00:00
|
|
|
require.NoError(t, node.gethService(&whisper))
|
2018-03-02 09:25:30 +00:00
|
|
|
|
|
|
|
bloomFilter := whisper.BloomFilter()
|
|
|
|
expectedEmptyBloomFilter := make([]byte, 64)
|
|
|
|
require.NotNil(t, bloomFilter)
|
|
|
|
require.Equal(t, expectedEmptyBloomFilter, bloomFilter)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestWhisperLightModeEnabledSetsNilBloomFilter(t *testing.T) {
|
2018-04-16 12:36:09 +00:00
|
|
|
config := params.NodeConfig{
|
|
|
|
WhisperConfig: ¶ms.WhisperConfig{
|
|
|
|
Enabled: true,
|
|
|
|
LightClient: false,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
node := New()
|
|
|
|
require.NoError(t, node.Start(&config))
|
2018-03-02 09:25:30 +00:00
|
|
|
defer func() {
|
2018-04-16 12:36:09 +00:00
|
|
|
require.NoError(t, node.Stop())
|
2018-03-02 09:25:30 +00:00
|
|
|
}()
|
|
|
|
|
|
|
|
var whisper *whisper.Whisper
|
2018-04-16 12:36:09 +00:00
|
|
|
require.NoError(t, node.gethService(&whisper))
|
2018-03-02 09:25:30 +00:00
|
|
|
require.Nil(t, whisper.BloomFilter())
|
|
|
|
}
|