2018-03-02 09:25:30 +00:00
|
|
|
package node
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2019-08-20 15:38:40 +00:00
|
|
|
"github.com/ethereum/go-ethereum/accounts"
|
2018-03-02 09:25:30 +00:00
|
|
|
|
2020-01-02 09:10:19 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
2018-06-08 11:29:50 +00:00
|
|
|
"github.com/status-im/status-go/params"
|
2019-12-09 10:36:14 +00:00
|
|
|
"github.com/status-im/status-go/whisper/v6"
|
2018-03-02 09:25:30 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestWhisperLightModeEnabledSetsEmptyBloomFilter(t *testing.T) {
|
2018-04-16 12:36:09 +00:00
|
|
|
config := params.NodeConfig{
|
2020-01-08 11:12:23 +00:00
|
|
|
EnableNTPSync: true,
|
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-20 15:38:40 +00:00
|
|
|
require.NoError(t, node.Start(&config, &accounts.Manager{}))
|
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{
|
2020-01-08 11:12:23 +00:00
|
|
|
EnableNTPSync: true,
|
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-20 15:38:40 +00:00
|
|
|
require.NoError(t, node.Start(&config, &accounts.Manager{}))
|
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())
|
|
|
|
}
|