2018-03-02 09:25:30 +00:00
|
|
|
package node
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2018-09-25 07:05:38 +00:00
|
|
|
whisper "github.com/status-im/whisper/whisperv6"
|
2018-03-02 09:25:30 +00:00
|
|
|
|
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{
|
2018-09-13 16:31:29 +00:00
|
|
|
WhisperConfig: params.WhisperConfig{
|
2018-04-16 12:36:09 +00:00
|
|
|
Enabled: true,
|
|
|
|
LightClient: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
node := New()
|
2019-08-01 09:27:06 +00:00
|
|
|
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{
|
2018-09-13 16:31:29 +00:00
|
|
|
WhisperConfig: params.WhisperConfig{
|
2018-04-16 12:36:09 +00:00
|
|
|
Enabled: true,
|
|
|
|
LightClient: false,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
node := New()
|
2019-08-01 09:27:06 +00:00
|
|
|
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())
|
|
|
|
}
|