Skip to content
Snippets Groups Projects
Commit ff5a0cc1 authored by Jonah Husson's avatar Jonah Husson
Browse files

Fix tests for xx-4558

parent 67c2f97e
No related branches found
No related tags found
7 merge requests!622Add notifications system with sync,!620Account Sychronization First Pass,!617Project/haven beta,!595Draft: Notifications Project,!592Xx 4558 tests,!591Draft: XX-4558,!523Draft: Account Synchronization Over Remote Storage
...@@ -958,7 +958,7 @@ func ValidForever() int { ...@@ -958,7 +958,7 @@ func ValidForever() int {
// Returns: // Returns:
// - []byte - JSON of [ChannelSendReport]. // - []byte - JSON of [ChannelSendReport].
func (cm *ChannelsManager) SendGeneric(channelIdBytes []byte, messageType int, func (cm *ChannelsManager) SendGeneric(channelIdBytes []byte, messageType int,
message []byte, validUntilMS int64, tracked bool, cmixParamsJSON []byte) ( message []byte, validUntilMS int64, tracked bool, cmixParamsJSON []byte, pingBytes [][]byte) (
[]byte, error) { []byte, error) {
// Unmarshal channel ID and parameters // Unmarshal channel ID and parameters
...@@ -976,9 +976,14 @@ func (cm *ChannelsManager) SendGeneric(channelIdBytes []byte, messageType int, ...@@ -976,9 +976,14 @@ func (cm *ChannelsManager) SendGeneric(channelIdBytes []byte, messageType int,
lease = channels.ValidForever lease = channels.ValidForever
} }
pings := make([]ed25519.PublicKey, len(pingBytes))
for i := range pingBytes {
pings[i] = pingBytes[i][:]
}
// Send message // Send message
messageID, rnd, ephID, err := cm.api.SendGeneric( messageID, rnd, ephID, err := cm.api.SendGeneric(
channelID, msgType, message, lease, tracked, params.CMIX) channelID, msgType, message, lease, tracked, params.CMIX, pings)
if err != nil { if err != nil {
return nil, err return nil, err
} }
...@@ -1013,7 +1018,7 @@ func (cm *ChannelsManager) SendGeneric(channelIdBytes []byte, messageType int, ...@@ -1013,7 +1018,7 @@ func (cm *ChannelsManager) SendGeneric(channelIdBytes []byte, messageType int,
// Returns: // Returns:
// - []byte - JSON of [ChannelSendReport]. // - []byte - JSON of [ChannelSendReport].
func (cm *ChannelsManager) SendMessage(channelIdBytes []byte, message string, func (cm *ChannelsManager) SendMessage(channelIdBytes []byte, message string,
validUntilMS int64, cmixParamsJSON []byte) ([]byte, error) { validUntilMS int64, cmixParamsJSON []byte, pingBytes [][]byte) ([]byte, error) {
// Unmarshal channel ID and parameters // Unmarshal channel ID and parameters
channelID, params, err := channelID, params, err :=
...@@ -1028,9 +1033,14 @@ func (cm *ChannelsManager) SendMessage(channelIdBytes []byte, message string, ...@@ -1028,9 +1033,14 @@ func (cm *ChannelsManager) SendMessage(channelIdBytes []byte, message string,
lease = channels.ValidForever lease = channels.ValidForever
} }
pings := make([]ed25519.PublicKey, len(pingBytes))
for i := range pingBytes {
pings[i] = pingBytes[i][:]
}
// Send message // Send message
messageID, rnd, ephID, err := messageID, rnd, ephID, err :=
cm.api.SendMessage(channelID, message, lease, params.CMIX) cm.api.SendMessage(channelID, message, lease, params.CMIX, pings)
if err != nil { if err != nil {
return nil, err return nil, err
} }
...@@ -1070,7 +1080,7 @@ func (cm *ChannelsManager) SendMessage(channelIdBytes []byte, message string, ...@@ -1070,7 +1080,7 @@ func (cm *ChannelsManager) SendMessage(channelIdBytes []byte, message string,
// Returns: // Returns:
// - []byte - JSON of [ChannelSendReport]. // - []byte - JSON of [ChannelSendReport].
func (cm *ChannelsManager) SendReply(channelIdBytes []byte, message string, func (cm *ChannelsManager) SendReply(channelIdBytes []byte, message string,
messageToReactTo []byte, validUntilMS int64, cmixParamsJSON []byte) ( messageToReactTo []byte, validUntilMS int64, cmixParamsJSON []byte, pingBytes [][]byte) (
[]byte, error) { []byte, error) {
// Unmarshal channel ID and parameters // Unmarshal channel ID and parameters
...@@ -1090,9 +1100,14 @@ func (cm *ChannelsManager) SendReply(channelIdBytes []byte, message string, ...@@ -1090,9 +1100,14 @@ func (cm *ChannelsManager) SendReply(channelIdBytes []byte, message string,
lease = channels.ValidForever lease = channels.ValidForever
} }
pings := make([]ed25519.PublicKey, len(pingBytes))
for i := range pingBytes {
pings[i] = pingBytes[i][:]
}
// Send Reply // Send Reply
messageID, rnd, ephID, err := messageID, rnd, ephID, err :=
cm.api.SendReply(channelID, message, messageID, lease, params.CMIX) cm.api.SendReply(channelID, message, messageID, lease, params.CMIX, pings)
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
...@@ -9,6 +9,7 @@ package cmd ...@@ -9,6 +9,7 @@ package cmd
import ( import (
"fmt" "fmt"
"math"
"os" "os"
"time" "time"
...@@ -167,7 +168,8 @@ var broadcastCmd = &cobra.Command{ ...@@ -167,7 +168,8 @@ var broadcastCmd = &cobra.Command{
// Create & register symmetric receiver callback // Create & register symmetric receiver callback
receiveChan := make(chan []byte, 100) receiveChan := make(chan []byte, 100)
scb := func(payload, _ []byte, _ []string, scb := func(payload, _ []byte, _ []string,
receptionID receptionID.EphemeralIdentity, round rounds.Round) { _ uint16, receptionID receptionID.EphemeralIdentity,
round rounds.Round) {
jww.INFO.Printf("Received symmetric message from %s over round %d", receptionID, round.ID) jww.INFO.Printf("Received symmetric message from %s over round %d", receptionID, round.ID)
receiveChan <- payload receiveChan <- payload
} }
...@@ -179,7 +181,8 @@ var broadcastCmd = &cobra.Command{ ...@@ -179,7 +181,8 @@ var broadcastCmd = &cobra.Command{
// Create & register asymmetric receiver callback // Create & register asymmetric receiver callback
asymmetricReceiveChan := make(chan []byte, 100) asymmetricReceiveChan := make(chan []byte, 100)
acb := func(payload, _ []byte, _ []string, acb := func(payload, _ []byte, _ []string,
receptionID receptionID.EphemeralIdentity, round rounds.Round) { _ uint16, receptionID receptionID.EphemeralIdentity,
round rounds.Round) {
jww.INFO.Printf("Received asymmetric message from %s over round %d", receptionID, round.ID) jww.INFO.Printf("Received asymmetric message from %s over round %d", receptionID, round.ID)
asymmetricReceiveChan <- payload asymmetricReceiveChan <- payload
} }
...@@ -209,7 +212,7 @@ var broadcastCmd = &cobra.Command{ ...@@ -209,7 +212,7 @@ var broadcastCmd = &cobra.Command{
/* Send symmetric broadcast */ /* Send symmetric broadcast */
if symmetric != "" { if symmetric != "" {
rid, eid, err := bcl.Broadcast([]byte(symmetric), []string{}, cmix.GetDefaultCMIXParams()) rid, eid, err := bcl.Broadcast([]byte(symmetric), []string{}, math.MaxUint16, cmix.GetDefaultCMIXParams())
if err != nil { if err != nil {
jww.ERROR.Printf("Failed to send symmetric broadcast message: %+v", err) jww.ERROR.Printf("Failed to send symmetric broadcast message: %+v", err)
retries++ retries++
...@@ -225,7 +228,7 @@ var broadcastCmd = &cobra.Command{ ...@@ -225,7 +228,7 @@ var broadcastCmd = &cobra.Command{
if pk == nil { if pk == nil {
jww.FATAL.Panicf("CANNOT SEND ASYMMETRIC BROADCAST WITHOUT PRIVATE KEY") jww.FATAL.Panicf("CANNOT SEND ASYMMETRIC BROADCAST WITHOUT PRIVATE KEY")
} }
_, rid, eid, err := bcl.BroadcastRSAtoPublic(pk, []byte(asymmetric), []string{}, cmix.GetDefaultCMIXParams()) _, rid, eid, err := bcl.BroadcastRSAtoPublic(pk, []byte(asymmetric), []string{}, math.MaxUint16, cmix.GetDefaultCMIXParams())
if err != nil { if err != nil {
jww.ERROR.Printf("Failed to send asymmetric broadcast message: %+v", err) jww.ERROR.Printf("Failed to send asymmetric broadcast message: %+v", err)
retries++ retries++
......
...@@ -311,7 +311,7 @@ func sendMessageToChannel(chanManager channels.Manager, ...@@ -311,7 +311,7 @@ func sendMessageToChannel(chanManager channels.Manager,
channelsPrintHeader, msgBody, channel.Name) channelsPrintHeader, msgBody, channel.Name)
chanMsgId, round, _, err := chanManager.SendGeneric( chanMsgId, round, _, err := chanManager.SendGeneric(
channel.ReceptionID, integrationChannelMessage, msgBody, 5*time.Second, channel.ReceptionID, integrationChannelMessage, msgBody, 5*time.Second,
true, cmix.GetDefaultCMIXParams()) true, cmix.GetDefaultCMIXParams(), nil)
if err != nil { if err != nil {
return errors.Errorf("%+v", err) return errors.Errorf("%+v", err)
} }
......
...@@ -32,7 +32,7 @@ type processor struct { ...@@ -32,7 +32,7 @@ type processor struct {
// reception callback. It is the responsibility of the caller to register a // reception callback. It is the responsibility of the caller to register a
// progress callback. // progress callback.
func (p *processor) Process(decryptedMsg groupChat.MessageReceive, func (p *processor) Process(decryptedMsg groupChat.MessageReceive,
_ format.Message, _ receptionID.EphemeralIdentity, _ rounds.Round) { _ format.Message, _ []string, _ []byte, _ receptionID.EphemeralIdentity, _ rounds.Round) {
// Add new transfer to start receiving parts // Add new transfer to start receiving parts
tid, info, err := p.ft.HandleIncomingTransfer(decryptedMsg.Payload, nil, 0) tid, info, err := p.ft.HandleIncomingTransfer(decryptedMsg.Payload, nil, 0)
if err != nil { if err != nil {
......
...@@ -81,7 +81,7 @@ func (p *receptionProcessor) Process(message format.Message, _ []string, _ []byt ...@@ -81,7 +81,7 @@ func (p *receptionProcessor) Process(message format.Message, _ []string, _ []byt
p.g.Name, p.g.ID, result.Timestamp) p.g.Name, p.g.ID, result.Timestamp)
// Send the decrypted message and original message to the processor // Send the decrypted message and original message to the processor
p.p.Process(result, message, receptionID, round) p.p.Process(result, message, nil, nil, receptionID, round)
} }
func (p *receptionProcessor) String() string { func (p *receptionProcessor) String() string {
......
...@@ -53,7 +53,7 @@ func Test_manager_Send(t *testing.T) { ...@@ -53,7 +53,7 @@ func Test_manager_Send(t *testing.T) {
timestamps := make(map[states.Round]time.Time) timestamps := make(map[states.Round]time.Time)
timestamps[states.PRECOMPUTING] = netTime.Now().Round(0) timestamps[states.PRECOMPUTING] = netTime.Now().Round(0)
for _, msg := range messages { for _, msg := range messages {
reception.Process(msg, []string{}, receptionID.EphemeralIdentity{ reception.Process(msg, []string{}, nil, receptionID.EphemeralIdentity{
EphId: ephemeral.Id{1, 2, 3}, Source: &id.ID{4, 5, 6}, EphId: ephemeral.Id{1, 2, 3}, Source: &id.ID{4, 5, 6},
}, },
rounds.Round{ID: roundId.ID, Timestamps: timestamps}) rounds.Round{ID: roundId.ID, Timestamps: timestamps})
...@@ -244,7 +244,7 @@ type testProcessor struct { ...@@ -244,7 +244,7 @@ type testProcessor struct {
msgChan chan MessageReceive msgChan chan MessageReceive
} }
func (tp *testProcessor) Process(decryptedMsg MessageReceive, _ format.Message, func (tp *testProcessor) Process(decryptedMsg MessageReceive, _ format.Message, _ []string, _ []byte,
_ receptionID.EphemeralIdentity, _ rounds.Round) { _ receptionID.EphemeralIdentity, _ rounds.Round) {
tp.msgChan <- decryptedMsg tp.msgChan <- decryptedMsg
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment