Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sgxwallet
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
董子豪
sgxwallet
Commits
f423edba
Unverified
Commit
f423edba
authored
3 years ago
by
Oleh Nikolaiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-3951 add tests
parent
1c5b7a55
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
8 deletions
+50
-8
testw.cpp
testw.cpp
+46
-4
testw.py
testw.py
+1
-1
ZMQClient.cpp
zmq_src/ZMQClient.cpp
+2
-2
ZMQClient.h
zmq_src/ZMQClient.h
+1
-1
No files found.
testw.cpp
View file @
f423edba
...
...
@@ -675,10 +675,6 @@ TEST_CASE_METHOD(TestFixture, "DKG API V2 test", "[dkg-api-v2]") {
Json
::
Value
secretSharesWrong_t
=
c
.
getSecretShareV2
(
polyName
,
publicKeys
,
3
,
3
);
REQUIRE
(
secretSharesWrong_t
[
"status"
].
asInt
()
!=
0
);
// wrong_n
Json
::
Value
verifVectWrong_n
=
c
.
getVerificationVector
(
polyName
,
2
);
REQUIRE
(
verifVectWrong_n
[
"status"
].
asInt
()
!=
0
);
Json
::
Value
publicKeys1
;
publicKeys1
.
append
(
SAMPLE_DKG_PUB_KEY_1
);
Json
::
Value
secretSharesWrong_n
=
c
.
getSecretShareV2
(
polyName
,
publicKeys1
,
2
,
1
);
...
...
@@ -701,6 +697,52 @@ TEST_CASE_METHOD(TestFixture, "DKG API V2 test", "[dkg-api-v2]") {
REQUIRE
(
verificationWrongSkeys
[
"status"
].
asInt
()
!=
0
);
}
TEST_CASE_METHOD
(
TestFixture
,
"DKG API V2 ZMQ test"
,
"[dkg-api-v2-zmq]"
)
{
auto
client
=
make_shared
<
ZMQClient
>
(
ZMQ_IP
,
ZMQ_PORT
,
true
,
"./sgx_data/cert_data/rootCA.pem"
,
"./sgx_data/cert_data/rootCA.key"
);
string
polyName
=
SAMPLE_POLY_NAME
;
PRINT_SRC_LINE
REQUIRE
(
client
->
generateDKGPoly
(
polyName
,
2
));
Json
::
Value
publicKeys
;
publicKeys
.
append
(
SAMPLE_DKG_PUB_KEY_1
);
publicKeys
.
append
(
SAMPLE_DKG_PUB_KEY_2
);
// wrongName
REQUIRE
(
!
client
->
generateDKGPoly
(
"poly"
,
2
));
REQUIRE_THROWS
(
client
->
getVerificationVector
(
"poly"
,
2
));
REQUIRE_THROWS
(
client
->
getSecretShare
(
"poly"
,
publicKeys
,
2
,
2
));
// wrong_t
REQUIRE
(
!
client
->
generateDKGPoly
(
polyName
,
33
));
REQUIRE_THROWS
(
client
->
getVerificationVector
(
polyName
,
0
));
REQUIRE_THROWS
(
client
->
getSecretShare
(
polyName
,
publicKeys
,
3
,
3
));
Json
::
Value
publicKeys1
;
publicKeys1
.
append
(
SAMPLE_DKG_PUB_KEY_1
);
REQUIRE_THROWS
(
client
->
getSecretShare
(
polyName
,
publicKeys1
,
2
,
1
));
//wrong number of publicKeys
REQUIRE_THROWS
(
client
->
getSecretShare
(
polyName
,
publicKeys
,
2
,
3
));
//wrong verif
string
Skeys
=
client
->
getSecretShare
(
polyName
,
publicKeys
,
2
,
2
);
REQUIRE_NOTHROW
(
client
->
getSecretShare
(
polyName
,
publicKeys
,
2
,
2
));
REQUIRE
(
Skeys
==
client
->
getSecretShare
(
polyName
,
publicKeys
,
2
,
2
));
Json
::
Value
verifVect
=
client
->
getVerificationVector
(
polyName
,
2
);
REQUIRE_NOTHROW
(
client
->
getVerificationVector
(
polyName
,
2
));
REQUIRE
(
verifVect
==
client
->
getVerificationVector
(
polyName
,
2
));
REQUIRE_THROWS
(
client
->
dkgVerification
(
""
,
""
,
""
,
2
,
2
,
1
));
}
TEST_CASE_METHOD
(
TestFixture
,
"PolyExists test"
,
"[dkg-poly-exists]"
)
{
HttpClient
client
(
RPC_ENDPOINT
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
...
...
This diff is collapsed.
Click to expand it.
testw.py
View file @
f423edba
...
...
@@ -54,7 +54,7 @@ testList = [ "[zmq-ecdsa]",
"[dkg-aes-encr-sshares]"
,
"[dkg-aes-encr-sshares-v2]"
,
"[dkg-api-v2]"
,
#
"[dkg-api-v2-zmq]",
"[dkg-api-v2-zmq]"
,
"[dkg-bls]"
,
"[dkgzmqbls]"
,
"[dkg-bls-v2]"
,
...
...
This diff is collapsed.
Click to expand it.
zmq_src/ZMQClient.cpp
View file @
f423edba
...
...
@@ -353,14 +353,14 @@ string ZMQClient::getECDSAPublicKey(const string& keyName) {
return
result
->
getECDSAPublicKey
();
}
void
ZMQClient
::
generateDKGPoly
(
const
string
&
polyName
,
int
t
)
{
bool
ZMQClient
::
generateDKGPoly
(
const
string
&
polyName
,
int
t
)
{
Json
::
Value
p
;
p
[
"type"
]
=
ZMQMessage
::
GENERATE_DKG_POLY_REQ
;
p
[
"polyName"
]
=
polyName
;
p
[
"t"
]
=
t
;
auto
result
=
dynamic_pointer_cast
<
generateDKGPolyRspMessage
>
(
doRequestReply
(
p
));
CHECK_STATE
(
result
);
CHECK_STATE
(
result
->
getStatus
()
==
0
)
;
return
result
->
getStatus
()
==
0
;
}
Json
::
Value
ZMQClient
::
getVerificationVector
(
const
string
&
polyName
,
int
t
)
{
...
...
This diff is collapsed.
Click to expand it.
zmq_src/ZMQClient.h
View file @
f423edba
...
...
@@ -95,7 +95,7 @@ public:
string
getECDSAPublicKey
(
const
string
&
keyName
);
void
generateDKGPoly
(
const
string
&
polyName
,
int
t
);
bool
generateDKGPoly
(
const
string
&
polyName
,
int
t
);
Json
::
Value
getVerificationVector
(
const
string
&
polyName
,
int
t
);
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment