Skip to content

Commit 776a2ff

Browse files
committed
fix unit-tests pipeline
1 parent 880d7cf commit 776a2ff

File tree

3 files changed

+2
-136
lines changed

3 files changed

+2
-136
lines changed

pkg/raptorq/helper.go

Lines changed: 0 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,9 @@ package raptorq
33
import (
44
"bytes"
55
"context"
6-
"encoding/json"
76
"github.com/LumeraProtocol/supernode/pkg/errors"
8-
"github.com/LumeraProtocol/supernode/pkg/logtrace"
9-
"github.com/LumeraProtocol/supernode/pkg/lumera"
107
"github.com/LumeraProtocol/supernode/pkg/utils"
118
"github.com/cosmos/btcutil/base58"
12-
"math/rand/v2"
13-
"os"
149
"strconv"
1510
)
1611

@@ -19,135 +14,6 @@ const (
1914
SeparatorByte byte = 46 // separator in dd_and_fingerprints.signature i.e. '.'
2015
)
2116

22-
// EncoderParameters represents the encoding params used by raptorq services
23-
type EncoderParameters struct {
24-
Oti []byte
25-
}
26-
27-
// EncodeInfo represents the response returns by encodeInfo method
28-
type EncodeInfo struct {
29-
SymbolIDFiles map[string]RawSymbolIDFile
30-
EncoderParam EncoderParameters
31-
}
32-
33-
// Encode represents the response returns by Encode method
34-
type Encode struct {
35-
Symbols map[string][]byte
36-
EncoderParam EncoderParameters
37-
}
38-
39-
// Decode represents the response returns by Decode method
40-
type Decode struct {
41-
File []byte
42-
}
43-
44-
func (s *raptorQServerClient) encodeInfo(ctx context.Context, taskID string, data []byte, copies uint32, blockHash string, pastelID string) (*EncodeInfo, error) {
45-
s.semaphore <- struct{}{} // Acquire slot
46-
defer func() {
47-
<-s.semaphore // Release the semaphore slot
48-
}()
49-
50-
if data == nil {
51-
return nil, errors.Errorf("invalid data")
52-
}
53-
54-
_, inputPath, err := createInputEncodeFile(s.config.RqFilesDir, data)
55-
if err != nil {
56-
return nil, errors.Errorf("create input file: %w", err)
57-
}
58-
res, err := s.EncodeMetaData(ctx, EncodeMetadataRequest{
59-
FilesNumber: copies,
60-
BlockHash: blockHash,
61-
PastelId: pastelID,
62-
Path: inputPath,
63-
})
64-
if err != nil {
65-
return nil, errors.Errorf("encode metadata %s: %w", res.Path, err)
66-
}
67-
68-
filesMap, err := scanSymbolIDFiles(res.Path)
69-
if err != nil {
70-
return nil, errors.Errorf("scan symbol id files folder %s: %w", res.Path, err)
71-
}
72-
73-
if len(filesMap) != int(copies) {
74-
return nil, errors.Errorf("symbol id files count not match: expect %d, output %d", copies, len(filesMap))
75-
}
76-
77-
if err := s.store.StoreSymbolDirectory(taskID, res.Path); err != nil {
78-
return nil, errors.Errorf("store symbol directory: %w", err)
79-
}
80-
81-
output := &EncodeInfo{
82-
SymbolIDFiles: filesMap,
83-
EncoderParam: EncoderParameters{
84-
Oti: res.EncoderParameters,
85-
},
86-
}
87-
88-
if err := os.Remove(inputPath); err != nil {
89-
logtrace.Error(ctx, "encode info: error removing input file", logtrace.Fields{"Path": inputPath})
90-
}
91-
92-
return output, nil
93-
}
94-
95-
type generateRQIDsRequest struct {
96-
lc lumera.Client
97-
signedData string
98-
rawFile RawSymbolIDFile
99-
creatorAddress string
100-
maxFiles uint32
101-
}
102-
103-
type generateRQIDsResponse struct {
104-
RQIDsIc uint32
105-
RQIDs []string
106-
RQIDsFile []byte
107-
RQIDsFiles [][]byte
108-
signature []byte
109-
}
110-
111-
func (s *raptorQServerClient) generateRQIDs(ctx context.Context, req generateRQIDsRequest) (generateRQIDsResponse, error) {
112-
// RQID file generated by supernode
113-
rqIDsfile, err := json.Marshal(req.rawFile)
114-
if err != nil {
115-
return generateRQIDsResponse{}, errors.Errorf("marshal rqID file")
116-
}
117-
encRqIDsfile := utils.B64Encode(rqIDsfile)
118-
119-
creatorSignature, err := ValidateRQIDs(req.lc, req.signedData, encRqIDsfile, req.rawFile.SymbolIdentifiers, req.creatorAddress)
120-
if err != nil {
121-
return generateRQIDsResponse{}, errors.Errorf("error validating RQIDs")
122-
}
123-
124-
var buffer bytes.Buffer
125-
buffer.Write(encRqIDsfile)
126-
buffer.WriteString(".")
127-
buffer.Write(creatorSignature)
128-
rqIDFile := buffer.Bytes()
129-
130-
RQIDsIc := rand.Uint32()
131-
RQIDs, RQIDsFiles, err := GetIDFiles(ctx, rqIDFile, RQIDsIc, req.maxFiles)
132-
if err != nil {
133-
return generateRQIDsResponse{}, errors.Errorf("get ID Files: %w", err)
134-
}
135-
136-
comp, err := utils.HighCompress(ctx, rqIDFile)
137-
if err != nil {
138-
return generateRQIDsResponse{}, errors.Errorf("compress: %w", err)
139-
}
140-
RQIDsFile := utils.B64Encode(comp)
141-
142-
return generateRQIDsResponse{
143-
RQIDsIc: RQIDsIc,
144-
RQIDs: RQIDs,
145-
RQIDsFile: RQIDsFile,
146-
RQIDsFiles: RQIDsFiles,
147-
signature: creatorSignature,
148-
}, nil
149-
}
150-
15117
// GetIDFiles generates ID Files for dd_and_fingerprints files and rq_id files
15218
// file is b64 encoded file appended with signatures and compressed, ic is the initial counter
15319
// and max is the number of ids to generate

sdk/task/manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func (m *ManagerImpl) handleEvent(ctx context.Context, e event.Event) {
188188
case event.TaskFailed:
189189
var err error
190190
if errMsg, ok := e.Data["error"].(string); ok {
191-
err = fmt.Errorf(errMsg)
191+
err = fmt.Errorf("%s", errMsg)
192192
m.logger.Error(ctx, "Task failed", "taskID", e.TaskID, "taskType", e.TaskType, "error", errMsg)
193193
} else {
194194
m.logger.Error(ctx, "Task failed with unknown error", "taskID", e.TaskID, "taskType", e.TaskType)

supernode/services/cascade/helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func (task *CascadeRegistrationTask) wrapErr(ctx context.Context, msg string, er
134134
}
135135
logtrace.Error(ctx, msg, f)
136136

137-
return status.Errorf(codes.Internal, msg)
137+
return status.Errorf(codes.Internal, "%s", msg)
138138
}
139139

140140
// extractSignatureAndFirstPart extracts the signature and first part from the encoded data

0 commit comments

Comments
 (0)