Main password encrypted in memory

This commit is contained in:
ycc
2026-02-02 18:15:57 +01:00
parent bb56b8dd9c
commit 7cf212fc76
13 changed files with 145 additions and 110 deletions

View File

@@ -12,17 +12,21 @@ import (
func TestStoreMessage(t *testing.T) {
id := createId(t)
password, err := GetConfig().GetMemPass()
if err != nil {
log.Fatal(err)
}
var um meowlib.UserMessage
um.Data = []byte("blabla")
peers, err := id.Peers.GetPeers()
if err != nil {
log.Fatal(err)
}
err = StoreMessage(peers[0], &um, []string{}, GetConfig().memoryPassword)
err = StoreMessage(peers[0], &um, []string{}, password)
if err != nil {
log.Fatal(err)
}
messages, err := GetMessagesHistory(peers[0], 0, 0, 10, GetConfig().memoryPassword)
messages, err := GetMessagesHistory(peers[0], 0, 0, 10, password)
if err != nil {
log.Fatal(err)
}
@@ -46,9 +50,13 @@ func TestStoreMessage(t *testing.T) {
func TestManyStoreMessage(t *testing.T) {
id := createId(t)
password, err := GetConfig().GetMemPass()
if err != nil {
log.Fatal(err)
}
peers, err := id.Peers.GetPeers()
// test with zero messages
messages, err := GetMessagesHistory(peers[0], 0, 0, 10, GetConfig().memoryPassword)
messages, err := GetMessagesHistory(peers[0], 0, 0, 10, password)
if err != nil {
log.Fatal(err)
}
@@ -56,12 +64,12 @@ func TestManyStoreMessage(t *testing.T) {
for i := 1; i < 100; i++ {
var um meowlib.UserMessage
um.Data = []byte(randomLenString(20, 200))
err := StoreMessage(peers[0], &um, []string{}, GetConfig().memoryPassword)
err := StoreMessage(peers[0], &um, []string{}, password)
if err != nil {
log.Fatal(err)
}
}
messages, err = GetMessagesHistory(peers[0], 0, 0, 10, GetConfig().memoryPassword)
messages, err = GetMessagesHistory(peers[0], 0, 0, 10, password)
if err != nil {
log.Fatal(err)
}