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 {
// Returns:
// - []byte - JSON of [ChannelSendReport].
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) {
// Unmarshal channel ID and parameters
......@@ -976,9 +976,14 @@ func (cm *ChannelsManager) SendGeneric(channelIdBytes []byte, messageType int,
lease = channels.ValidForever
}
pings := make([]ed25519.PublicKey, len(pingBytes))
for i := range pingBytes {
pings[i] = pingBytes[i][:]
}
// Send message
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 {
return nil, err
}
......@@ -1013,7 +1018,7 @@ func (cm *ChannelsManager) SendGeneric(channelIdBytes []byte, messageType int,
// Returns:
// - []byte - JSON of [ChannelSendReport].
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
channelID, params, err :=
......@@ -1028,9 +1033,14 @@ func (cm *ChannelsManager) SendMessage(channelIdBytes []byte, message string,
lease = channels.ValidForever
}
pings := make([]ed25519.PublicKey, len(pingBytes))
for i := range pingBytes {
pings[i] = pingBytes[i][:]
}
// Send message
messageID, rnd, ephID, err :=
cm.api.SendMessage(channelID, message, lease, params.CMIX)
cm.api.SendMessage(channelID, message, lease, params.CMIX, pings)
if err != nil {
return nil, err
}
......@@ -1070,7 +1080,7 @@ func (cm *ChannelsManager) SendMessage(channelIdBytes []byte, message string,
// Returns:
// - []byte - JSON of [ChannelSendReport].
func (cm *ChannelsManager) SendReply(channelIdBytes []byte, message string,
messageToReactTo []byte, validUntilMS int64, cmixParamsJSON []byte) (
messageToReactTo []byte, validUntilMS int64, cmixParamsJSON []byte, pingBytes [][]byte) (
[]byte, error) {
// Unmarshal channel ID and parameters
......@@ -1090,9 +1100,14 @@ func (cm *ChannelsManager) SendReply(channelIdBytes []byte, message string,
lease = channels.ValidForever
}
pings := make([]ed25519.PublicKey, len(pingBytes))
for i := range pingBytes {
pings[i] = pingBytes[i][:]
}
// Send Reply
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 {
return nil, err
}
......
......@@ -9,6 +9,7 @@ package cmd
import (
"fmt"
"math"
"os"
"time"
......@@ -167,7 +168,8 @@ var broadcastCmd = &cobra.Command{
// Create & register symmetric receiver callback
receiveChan := make(chan []byte, 100)
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)
receiveChan <- payload
}
......@@ -179,7 +181,8 @@ var broadcastCmd = &cobra.Command{
// Create & register asymmetric receiver callback
asymmetricReceiveChan := make(chan []byte, 100)
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)
asymmetricReceiveChan <- payload
}
......@@ -209,7 +212,7 @@ var broadcastCmd = &cobra.Command{
/* Send symmetric broadcast */
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 {
jww.ERROR.Printf("Failed to send symmetric broadcast message: %+v", err)
retries++
......@@ -225,7 +228,7 @@ var broadcastCmd = &cobra.Command{
if pk == nil {
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 {
jww.ERROR.Printf("Failed to send asymmetric broadcast message: %+v", err)
retries++
......
......@@ -311,7 +311,7 @@ func sendMessageToChannel(chanManager channels.Manager,
channelsPrintHeader, msgBody, channel.Name)
chanMsgId, round, _, err := chanManager.SendGeneric(
channel.ReceptionID, integrationChannelMessage, msgBody, 5*time.Second,
true, cmix.GetDefaultCMIXParams())
true, cmix.GetDefaultCMIXParams(), nil)
if err != nil {
return errors.Errorf("%+v", err)
}
......
......@@ -32,7 +32,7 @@ type processor struct {
// reception callback. It is the responsibility of the caller to register a
// progress callback.
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
tid, info, err := p.ft.HandleIncomingTransfer(decryptedMsg.Payload, nil, 0)
if err != nil {
......
......@@ -81,7 +81,7 @@ func (p *receptionProcessor) Process(message format.Message, _ []string, _ []byt
p.g.Name, p.g.ID, result.Timestamp)
// 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 {
......
......@@ -53,7 +53,7 @@ func Test_manager_Send(t *testing.T) {
timestamps := make(map[states.Round]time.Time)
timestamps[states.PRECOMPUTING] = netTime.Now().Round(0)
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},
},
rounds.Round{ID: roundId.ID, Timestamps: timestamps})
......@@ -244,7 +244,7 @@ type testProcessor struct {
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) {
tp.msgChan <- decryptedMsg
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment