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
d0b3e953
Unverified
Commit
d0b3e953
authored
4 years ago
by
Oleh Nikolaiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-2844 add test for deleting bls key
parent
53b3e091
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
10 deletions
+22
-10
LevelDB.cpp
LevelDB.cpp
+4
-3
SGXWalletServer.cpp
SGXWalletServer.cpp
+7
-3
TestUtils.cpp
TestUtils.cpp
+1
-1
testw.cpp
testw.cpp
+9
-3
testw.py
testw.py
+1
-0
No files found.
LevelDB.cpp
View file @
d0b3e953
...
...
@@ -53,14 +53,15 @@ std::shared_ptr<string> LevelDB::readString(const string &_key) {
throw
SGXException
(
NULL_DATABASE
,
"Null db"
);
}
auto
status
=
db
->
Get
(
readOptions
,
_key
,
&*
result
);
spdlog
::
info
(
"key to read from db: {}"
,
_key
);
spdlog
::
debug
(
"key to read from db: {}"
,
_key
);
auto
status
=
db
->
Get
(
readOptions
,
_key
,
&*
result
);
throwExceptionOnError
(
status
);
if
(
status
.
IsNotFound
())
if
(
status
.
IsNotFound
())
{
return
nullptr
;
}
return
result
;
}
...
...
This diff is collapsed.
Click to expand it.
SGXWalletServer.cpp
View file @
d0b3e953
...
...
@@ -667,14 +667,18 @@ Json::Value SGXWalletServer::deleteBlsKeyImpl(const std::string& name) {
result
[
"deleted"
]
=
false
;
try
{
if
(
!
checkName
(
name
,
"BLS_KEY"
))
{
throw
SGXException
(
INVALID_BLS_NAME
,
"Invalid BLSKey name"
);
throw
SGXException
(
INVALID_BLS_NAME
,
"Invalid BLSKey name
format
"
);
}
std
::
shared_ptr
<
std
::
string
>
bls_ptr
=
LevelDB
::
getLevelDb
()
->
readString
(
name
);
std
::
string
key
=
"BLSKEYSHARE:"
+
name
;
std
::
shared_ptr
<
std
::
string
>
bls_ptr
=
LevelDB
::
getLevelDb
()
->
readString
(
key
);
if
(
bls_ptr
!=
nullptr
)
{
result
[
"deleted"
]
=
true
;
return
result
;
}
}
else
{
std
::
string
error_msg
=
"BLS key with such name not found: "
+
name
;
throw
SGXException
(
INVALID_BLS_NAME
,
error_msg
.
c_str
());
}
LevelDB
::
getLevelDb
()
->
deleteKey
(
name
);
}
HANDLE_SGX_EXCEPTION
(
result
)
return
result
;
...
...
This diff is collapsed.
Click to expand it.
TestUtils.cpp
View file @
d0b3e953
...
...
@@ -424,4 +424,4 @@ void TestUtils::doDKG(StubClient &c, int n, int t,
cerr
<<
i
<<
endl
;
}
\ No newline at end of file
}
This diff is collapsed.
Click to expand it.
testw.cpp
View file @
d0b3e953
...
...
@@ -573,11 +573,17 @@ TEST_CASE_METHOD(TestFixture, "DKG_BLS test", "[dkg-bls]") {
dkgID
=
TestUtils
::
randGen
();
TestUtils
::
doDKG
(
c
,
16
,
5
,
ecdsaKeyNames
,
blsKeyNames
,
schainID
,
dkgID
);
}
for
(
const
auto
&
name
:
blsKeyNames
)
{
REQUIRE
(
c
.
deleteBlsKey
(
name
)[
"deleted"
]
==
true
);
}
TEST_CASE_METHOD
(
TestFixture
,
"Delete Bls Key"
,
"[delete-bls-key]"
)
{
HttpClient
client
(
RPC_ENDPOINT
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
std
::
string
name
=
"BLS_KEY:SCHAIN_ID:123456789:NODE_ID:0:DKG_ID:0"
;
libff
::
alt_bn128_Fr
key
=
libff
::
alt_bn128_Fr
(
"6507625568967977077291849236396320012317305261598035438182864059942098934847"
);
std
::
string
key_str
=
TestUtils
::
stringFromFr
(
key
);
c
.
importBLSKeyShare
(
key_str
,
name
,
1
,
2
,
1
);
REQUIRE
(
c
.
deleteBlsKey
(
name
)[
"deleted"
]
==
true
);
}
TEST_CASE_METHOD
(
TestFixture
,
"Backup Key"
,
"[backup-key]"
)
{
...
...
This diff is collapsed.
Click to expand it.
testw.py
View file @
d0b3e953
...
...
@@ -33,6 +33,7 @@ testList = [ "[cert-sign]",
"[get-server-status]"
,
"[get-server-version]"
,
"[backup-key]"
,
"[delete-bls-key]"
,
"[ecdsa-key-gen]"
,
"[ecdsa-aes-key-gen]"
,
"[ecdsa-key-sig-gen]"
,
...
...
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