diff --git a/Makefile b/Makefile
index 73a65a8d..a6eea6e5 100644
--- a/Makefile
+++ b/Makefile
@@ -48,7 +48,7 @@ test-run:
d=$$(date +%s); \
for i in {1..$(N)}; do \
echo $$i; \
- go test -cover -count=1 -shuffle=on `$(_GO_TEST_LIST)`; \
+ go test -race -cover -count=1 -shuffle=on `$(_GO_TEST_LIST)`; \
$(_CHECK_ERROR); \
done; \
echo "Build took $$(($$(date +%s)-d)) seconds";
diff --git a/pkg/anonymity/qb/anonymity.go b/pkg/anonymity/qb/anonymity.go
index c2416a46..550b5538 100644
--- a/pkg/anonymity/qb/anonymity.go
+++ b/pkg/anonymity/qb/anonymity.go
@@ -225,15 +225,6 @@ func (p *sNode) recvResponse(pCtx context.Context, pActionKey string) ([]byte, e
}
}
-func (p *sNode) tryDecryptMessage(pEncMsg []byte) (asymmetric.IPubKey, []byte, error) {
- client := p.fQBProcessor.GetClient()
- pubKey, decMsg, err := client.DecryptMessage(p.fMapPubKeys, pEncMsg)
- if err != nil {
- return nil, nil, ErrDecryptMessage
- }
- return pubKey, decMsg, nil
-}
-
func (p *sNode) consumeMessage(pCtx context.Context, pNetMsg layer1.IMessage) error {
logBuilder := anon_logger.NewLogBuilder(p.fSettings.GetServiceName())
@@ -261,7 +252,7 @@ func (p *sNode) consumeMessage(pCtx context.Context, pNetMsg layer1.IMessage) er
}
// try decrypt consumed message
- pubKey, decMsg, err := p.tryDecryptMessage(encMsg)
+ pubKey, decMsg, err := client.DecryptMessage(p.fMapPubKeys, encMsg)
if err != nil {
p.fLogger.PushInfo(logBuilder.WithType(anon_logger.CLogInfoUndecryptable))
return nil
diff --git a/pkg/anonymity/qb/anonymity_test.go b/pkg/anonymity/qb/anonymity_test.go
index 91959ff1..838a7f57 100644
--- a/pkg/anonymity/qb/anonymity_test.go
+++ b/pkg/anonymity/qb/anonymity_test.go
@@ -194,7 +194,7 @@ func TestFetchPayload(t *testing.T) {
},
)
- largeBodySize := nodes[0].GetQBProcessor().GetClient().GetPayloadSize() - encoding.CSizeUint64 + 1
+ largeBodySize := nodes[0].GetQBProcessor().GetClient().GetPayloadLimit() - encoding.CSizeUint64 + 1
_, err := nodes[0].FetchPayload(
ctx,
nodes[1].GetQBProcessor().GetClient().GetPrivKey().GetPubKey(),
@@ -245,7 +245,7 @@ func TestBroadcastPayload(t *testing.T) {
},
)
- largeBodySize := nodes[0].GetQBProcessor().GetClient().GetPayloadSize() - encoding.CSizeUint64 + 1
+ largeBodySize := nodes[0].GetQBProcessor().GetClient().GetPayloadLimit() - encoding.CSizeUint64 + 1
err := nodes[0].SendPayload(
context.Background(),
nodes[1].GetQBProcessor().GetClient().GetPrivKey().GetPubKey(),
diff --git a/pkg/anonymity/qb/errors.go b/pkg/anonymity/qb/errors.go
index 3b036b85..118e9094 100644
--- a/pkg/anonymity/qb/errors.go
+++ b/pkg/anonymity/qb/errors.go
@@ -30,5 +30,4 @@ var (
ErrRunning = &SAnonymityError{"node running"}
ErrProcessRun = &SAnonymityError{"process run"}
ErrHashAlreadyExist = &SAnonymityError{"hash already exist"}
- ErrDecryptMessage = &SAnonymityError{"decrypt message"}
)
diff --git a/pkg/anonymity/qb/queue/examples/main.go b/pkg/anonymity/qb/queue/examples/queue/main.go
similarity index 100%
rename from pkg/anonymity/qb/queue/examples/main.go
rename to pkg/anonymity/qb/queue/examples/queue/main.go
diff --git a/pkg/anonymity/qb/queue/examples/main_test.go b/pkg/anonymity/qb/queue/examples/queue/main_test.go
similarity index 100%
rename from pkg/anonymity/qb/queue/examples/main_test.go
rename to pkg/anonymity/qb/queue/examples/queue/main_test.go
diff --git a/pkg/crypto/hybrid/client/client.go b/pkg/crypto/hybrid/client/client.go
index 34477fd2..55e3385d 100644
--- a/pkg/crypto/hybrid/client/client.go
+++ b/pkg/crypto/hybrid/client/client.go
@@ -21,9 +21,9 @@ var (
// Basic structure describing the user.
type sClient struct {
- fPrivKey asymmetric.IPrivKey
- fMessageSize uint64
- fPayloadSize uint64
+ fPrivKey asymmetric.IPrivKey
+ fMessageSize uint64
+ fPayloadLimit uint64
}
// Create client by private key as identification.
@@ -45,7 +45,7 @@ func NewClient(pPrivKey asymmetric.IPrivKey, pMessageSize uint64) IClient {
panic("the payload size is lower than struct size")
}
- client.fPayloadSize = pMessageSize - structSize
+ client.fPayloadLimit = pMessageSize - structSize
return client
}
@@ -60,23 +60,23 @@ func (p *sClient) GetMessageSize() uint64 {
}
// Payload is raw bytes of message without structure.
-func (p *sClient) GetPayloadSize() uint64 {
- return p.fPayloadSize
+func (p *sClient) GetPayloadLimit() uint64 {
+ return p.fPayloadLimit
}
// Encrypt message with public key of receiver.
// The message can be decrypted only if private key is known.
func (p *sClient) EncryptMessage(pRecv asymmetric.IPubKey, pMsg []byte) ([]byte, error) {
var (
- payloadSize = p.fPayloadSize
- resultSize = uint64(len(pMsg))
+ payloadLimit = p.fPayloadLimit
+ resultSize = uint64(len(pMsg))
)
- if resultSize > payloadSize {
+ if resultSize > payloadLimit {
return nil, ErrLimitMessageSize
}
- return p.encryptWithPadding(pRecv, pMsg, payloadSize-resultSize)
+ return p.encryptWithPadding(pRecv, pMsg, payloadLimit-resultSize)
}
// Decrypt message with private key of receiver.
diff --git a/pkg/crypto/hybrid/client/client_test.go b/pkg/crypto/hybrid/client/client_test.go
index 68752961..6b2b166f 100644
--- a/pkg/crypto/hybrid/client/client_test.go
+++ b/pkg/crypto/hybrid/client/client_test.go
@@ -90,7 +90,7 @@ func TestInvalidClient(t *testing.T) {
_client := client.(*sClient)
msg1 := []byte("hello")
- pad1 := client.GetPayloadSize() - uint64(len(msg1)) + 2*encoding.CSizeUint32
+ pad1 := client.GetPayloadLimit() - uint64(len(msg1)) + 2*encoding.CSizeUint32
enc1, err := _client.encryptWithPadding(pubKey, msg1, pad1)
if err != nil {
@@ -104,7 +104,7 @@ func TestInvalidClient(t *testing.T) {
return
}
- pad2 := client.GetPayloadSize() - uint64(len(msg1)) + asymmetric.CDSAPubKeySize - 3
+ pad2 := client.GetPayloadLimit() - uint64(len(msg1)) + asymmetric.CDSAPubKeySize - 3
enc2, err := tcEncryptWithParamsInvalidPKID(_client, pubKey, msg1, pad2)
if err != nil {
t.Error(err)
diff --git a/pkg/crypto/hybrid/client/examples/file_encrypt/encrypt.go b/pkg/crypto/hybrid/client/examples/file_encrypt/encrypt.go
index f4227b86..ff3dcc2f 100644
--- a/pkg/crypto/hybrid/client/examples/file_encrypt/encrypt.go
+++ b/pkg/crypto/hybrid/client/examples/file_encrypt/encrypt.go
@@ -9,7 +9,7 @@ import (
)
func encrypt(client client.IClient, outFilename, inFilename string) error {
- pldLimit := client.GetPayloadSize()
+ pldLimit := client.GetPayloadLimit()
infile, err := os.Open(inFilename) //nolint:gosec
if err != nil {
diff --git a/pkg/crypto/hybrid/client/types.go b/pkg/crypto/hybrid/client/types.go
index 17d2b4db..69d825a4 100644
--- a/pkg/crypto/hybrid/client/types.go
+++ b/pkg/crypto/hybrid/client/types.go
@@ -11,7 +11,7 @@ type IClient interface {
GetPrivKey() asymmetric.IPrivKey
GetMessageSize() uint64
- GetPayloadSize() uint64
+ GetPayloadLimit() uint64
}
type IDecryptor interface {
diff --git a/test/result/badge_codelines.svg b/test/result/badge_codelines.svg
index 465d735b..7e5e7821 100644
--- a/test/result/badge_codelines.svg
+++ b/test/result/badge_codelines.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/test/result/badge_coverage.svg b/test/result/badge_coverage.svg
index 09558fd2..9fd7bd14 100644
--- a/test/result/badge_coverage.svg
+++ b/test/result/badge_coverage.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/test/result/coverage.svg b/test/result/coverage.svg
index 002c08ce..f099a669 100644
--- a/test/result/coverage.svg
+++ b/test/result/coverage.svg
@@ -7,7 +7,7 @@
>
-
+
-
+
-
+
-
+
anonymity/qb
-
+
crypto
@@ -65,12 +65,12 @@
-
+
encoding
@@ -78,12 +78,12 @@
-
+
logger
@@ -91,12 +91,12 @@
-
+
message
@@ -104,12 +104,12 @@
-
+
network
@@ -117,12 +117,12 @@
-
+
payload
@@ -130,12 +130,12 @@
-
+
state
@@ -143,12 +143,12 @@
-
+
storage
@@ -156,26 +156,26 @@
-
-
-
-
-
-
-
+
adapters/adapter.go
+ data-math="N">action.go
-
+
+
+
+
+
+
+
-
+
-
+
head.go
@@ -207,12 +207,12 @@
-
+
logger/log_builder.go
@@ -220,31 +220,38 @@
-
+
queue
-
-
-
-
-
-
-
+
settings.go
+
+
+
+
+
+
+
+asymmetric
@@ -252,12 +259,12 @@
-
+
hashing
@@ -265,12 +272,12 @@
-
+
hybrid/client
@@ -278,18 +285,18 @@
-
+
-
+
puzzle/puzzle.go
@@ -297,12 +304,12 @@
-
+
random/random.go
@@ -310,12 +317,12 @@
-
+
symmetric/symmetric.go
@@ -323,12 +330,12 @@
-
+
bytes.go
@@ -336,18 +343,18 @@
-
+
-
+
hex.go
@@ -355,12 +362,12 @@
-
+
serialize_json.go
@@ -368,18 +375,18 @@
-
+
-
+
logger.go
@@ -387,18 +394,18 @@
-
+
-
+
layer1
@@ -406,12 +413,12 @@
-
+
layer2
@@ -419,12 +426,12 @@
-
+
conn
@@ -432,12 +439,12 @@
-
+
connkeeper
@@ -445,12 +452,12 @@
-
+
network.go
@@ -458,12 +465,12 @@
-
+
settings.go
@@ -471,12 +478,12 @@
-
+
joiner
@@ -484,12 +491,12 @@
-
+
payload32.go
@@ -497,12 +504,12 @@
-
+
payload64.go
@@ -510,12 +517,12 @@
-
+
state.go
@@ -523,12 +530,12 @@
-
+
cache/lru.go
@@ -536,12 +543,12 @@
-
+
database
@@ -549,25 +556,18 @@
-
+
-examples/main.go
-
-
+
queue.go
@@ -575,12 +575,12 @@
-
+
settings.go
@@ -588,12 +588,12 @@
-
+
dsa.go
@@ -601,12 +601,12 @@
-
+
kem.go
@@ -614,12 +614,12 @@
-
+
key.go
@@ -627,12 +627,12 @@
-
+
map_pubkeys.go
@@ -640,12 +640,12 @@
-
+
hashing.go
@@ -653,25 +653,18 @@
-
+
-hmac.go
-
-
+
client.go
@@ -679,18 +672,12 @@
-
-
-
-
-
-
-
+
message.go
@@ -698,12 +685,12 @@
-
+
settings.go
@@ -711,12 +698,12 @@
-
+
message.go
@@ -724,12 +711,12 @@
-
+
conn.go
@@ -737,12 +724,12 @@
-
+
settings.go
@@ -750,12 +737,12 @@
-
+
connkeeper.go
@@ -763,31 +750,30 @@
-
-
-settings.go
-
-
-
-
-
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
database.go