105 lines
2.2 KiB
Go
Raw Permalink Normal View History

package main
import (
2024-05-29 09:55:04 -04:00
"bufio"
"context"
2024-05-24 13:44:53 -04:00
"fmt"
2024-05-29 09:55:04 -04:00
"os"
2024-05-24 13:44:53 -04:00
"strconv"
2024-05-29 09:55:04 -04:00
"strings"
"time"
)
var nodeList = []string{
2024-05-29 09:55:04 -04:00
"/dns4/store-01.do-ams3.shards.test.status.im/tcp/30303/p2p/16Uiu2HAmAUdrQ3uwzuE4Gy4D56hX6uLKEeerJAnhKEHZ3DxF1EfT",
}
// If using vscode, go to Preferences > Settings, and edit Go: Test Timeout to at least 60s
2024-05-24 13:44:53 -04:00
func parseTime(s string) time.Time {
i, err := strconv.ParseInt(s, 10, 64)
2024-05-24 13:44:53 -04:00
if err != nil {
panic(err)
}
return time.Unix(i, 0)
}
2024-05-29 09:55:04 -04:00
func getValue(param string) string {
x := strings.Split(param, "=")
return x[1]
}
2024-05-29 09:55:04 -04:00
func getIntValue(param string) int64 {
x := strings.Split(param, "=")
2024-05-29 09:55:04 -04:00
num, err := strconv.ParseInt(x[1], 10, 64)
if err != nil {
panic(err)
}
2024-05-29 09:55:04 -04:00
return num
}
2024-05-29 09:55:04 -04:00
func getArrValue(param string) []string {
x := strings.ReplaceAll(param, "\"", "")
x = strings.ReplaceAll(x, "[", "")
x = strings.ReplaceAll(x, "]", "")
2024-05-29 09:55:04 -04:00
x2 := strings.Split(x, " ")
return x2
}
func (s *StoreSuite) TestBasic() {
ctx := context.Background()
// Connecting to nodes
// ================================================================
log.Info("Connecting to nodes...")
connectToNodes(ctx, s.node)
time.Sleep(2 * time.Second) // Required so Identify protocol is executed
2024-05-29 09:55:04 -04:00
// Open the file
file, err := os.Open("missing_messages.txt")
if err != nil {
panic(err)
}
defer file.Close()
scanner := bufio.NewScanner(file)
// Store
// ================================================================
2024-05-29 09:55:04 -04:00
// Read each line and process it
2024-05-29 09:55:04 -04:00
contentTopc := make(map[string]struct{})
for scanner.Scan() {
line := scanner.Text()
2024-05-29 09:55:04 -04:00
params := strings.Split(line, ";")
startTime := time.Unix(0, getIntValue(params[1]))
endTime := time.Unix(0, getIntValue(params[2]))
contentTopics := getArrValue(getValue(params[3]))
pubsubTopic := getValue(params[4])
for _, x := range contentTopics {
contentTopc[x] = struct{}{}
}
2024-05-29 09:55:04 -04:00
cnt, err := queryNode(ctx, s.node, nodeList[0], pubsubTopic, contentTopics, startTime, endTime)
if err != nil {
fmt.Println("COULD NOT QUERY STORENODE: ", err)
} else {
fmt.Println(cnt, "MESSAGES FOUND FOR - ", startTime, endTime, (contentTopics), pubsubTopic)
if cnt != 0 {
fmt.Println("!!!!!!!!!!!!!!!!")
}
}
2024-05-29 09:55:04 -04:00
}
}