2021-06-16 20:19:45 +00:00
|
|
|
// Copyright 2019 The Waku Library Authors.
|
|
|
|
//
|
|
|
|
// The Waku library is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// The Waku library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty off
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with the Waku library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
//
|
|
|
|
// This software uses the go-ethereum library, which is licensed
|
|
|
|
// under the GNU Lesser General Public Library, version 3 or any later.
|
|
|
|
|
|
|
|
package wakuv2
|
|
|
|
|
2024-08-27 13:14:36 +00:00
|
|
|
/* TODO-nwaku
|
2021-06-16 20:19:45 +00:00
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
2023-09-13 10:50:23 +00:00
|
|
|
"golang.org/x/exp/maps"
|
2023-05-22 21:38:02 +00:00
|
|
|
|
2021-06-16 20:19:45 +00:00
|
|
|
"github.com/status-im/status-go/wakuv2/common"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestMultipleTopicCopyInNewMessageFilter(t *testing.T) {
|
2024-05-15 23:15:22 +00:00
|
|
|
w, err := New(nil, "", nil, nil, nil, nil, nil, nil)
|
2021-06-16 20:19:45 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Error creating WakuV2 client: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
keyID, err := w.GenerateSymKey()
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Error generating symmetric key: %v", err)
|
|
|
|
}
|
|
|
|
api := PublicWakuAPI{
|
|
|
|
w: w,
|
|
|
|
lastUsed: make(map[string]time.Time),
|
|
|
|
}
|
|
|
|
|
2023-09-13 10:50:23 +00:00
|
|
|
t1 := common.TopicType([4]byte{0xde, 0xea, 0xbe, 0xef})
|
|
|
|
t2 := common.TopicType([4]byte{0xca, 0xfe, 0xde, 0xca})
|
2021-06-16 20:19:45 +00:00
|
|
|
|
|
|
|
crit := Criteria{
|
2023-05-22 21:38:02 +00:00
|
|
|
SymKeyID: keyID,
|
2023-09-13 10:50:23 +00:00
|
|
|
ContentTopics: []common.TopicType{t1, t2},
|
2021-06-16 20:19:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_, err = api.NewMessageFilter(crit)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Error creating the filter: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
found := false
|
2024-08-27 13:14:36 +00:00
|
|
|
candidates := w.filters.GetWatchersByTopic(DefaultShardPubsubTopic(), t1)
|
2021-06-16 20:19:45 +00:00
|
|
|
for _, f := range candidates {
|
2023-09-13 10:50:23 +00:00
|
|
|
if maps.Equal(f.ContentTopics, common.NewTopicSet(crit.ContentTopics)) {
|
|
|
|
found = true
|
|
|
|
break
|
2021-06-16 20:19:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if !found {
|
|
|
|
t.Fatalf("Could not find filter with both topics")
|
|
|
|
}
|
2024-10-24 14:35:01 +00:00
|
|
|
}
|
|
|
|
*/
|