Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Duniter v2S
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
rust
Duniter v2S
Commits
40533983
Commit
40533983
authored
2 years ago
by
Hugo Trentesaux
Browse files
Options
Downloads
Patches
Plain Diff
wip fix tests
parent
2a46c45b
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
pallets/duniter-wot/src/lib.rs
+17
-10
17 additions, 10 deletions
pallets/duniter-wot/src/lib.rs
pallets/duniter-wot/src/tests.rs
+7
-5
7 additions, 5 deletions
pallets/duniter-wot/src/tests.rs
with
24 additions
and
15 deletions
pallets/duniter-wot/src/lib.rs
+
17
−
10
View file @
40533983
...
@@ -117,6 +117,10 @@ pub mod pallet {
...
@@ -117,6 +117,10 @@ pub mod pallet {
IssuerCanNotEmitCert
,
IssuerCanNotEmitCert
,
/// Can not issue cert to unconfirmed identity
/// Can not issue cert to unconfirmed identity
CertToUnconfirmedIdty
,
CertToUnconfirmedIdty
,
/// Issuer not found
IssuerNotFound
,
/// Receiver not found
ReceiverNotFound
,
}
}
}
}
...
@@ -206,16 +210,19 @@ impl<T: Config<I>, I: 'static> pallet_certification::traits::CheckCertAllowed<Id
...
@@ -206,16 +210,19 @@ impl<T: Config<I>, I: 'static> pallet_certification::traits::CheckCertAllowed<Id
for
Pallet
<
T
,
I
>
for
Pallet
<
T
,
I
>
{
{
fn
check_cert_allowed
(
issuer
:
IdtyIndex
,
receiver
:
IdtyIndex
)
->
Result
<
(),
DispatchError
>
{
fn
check_cert_allowed
(
issuer
:
IdtyIndex
,
receiver
:
IdtyIndex
)
->
Result
<
(),
DispatchError
>
{
if
let
Some
(
issuer_data
)
=
pallet_identity
::
Pallet
::
<
T
>
::
identity
(
issuer
)
{
match
pallet_identity
::
Pallet
::
<
T
>
::
identity
(
issuer
)
{
if
issuer_data
.status
!=
IdtyStatus
::
Validated
{
Some
(
issuer_data
)
=>
ensure!
(
return
Err
(
Error
::
<
T
,
I
>
::
IssuerCanNotEmitCert
.into
());
issuer_data
.status
==
IdtyStatus
::
Validated
,
}
Error
::
<
T
,
I
>
::
IssuerCanNotEmitCert
if
let
Some
(
receiver_data
)
=
pallet_identity
::
Pallet
::
<
T
>
::
identity
(
receiver
)
{
),
match
receiver_data
.status
{
None
=>
return
Err
(
Error
::
<
T
,
I
>
::
IssuerNotFound
.into
()),
IdtyStatus
::
ConfirmedByOwner
|
IdtyStatus
::
Validated
=>
(),
IdtyStatus
::
Created
=>
return
Err
(
Error
::
<
T
,
I
>
::
CertToUnconfirmedIdty
.into
()),
}
};
};
match
pallet_identity
::
Pallet
::
<
T
>
::
identity
(
receiver
)
{
Some
(
receiver_data
)
=>
ensure!
(
receiver_data
.status
!=
IdtyStatus
::
Created
,
Error
::
<
T
,
I
>
::
CertToUnconfirmedIdty
),
None
=>
return
Err
(
Error
::
<
T
,
I
>
::
ReceiverNotFound
.into
()),
};
};
Ok
(())
Ok
(())
}
}
...
...
This diff is collapsed.
Click to expand it.
pallets/duniter-wot/src/tests.rs
+
7
−
5
View file @
40533983
...
@@ -16,8 +16,9 @@
...
@@ -16,8 +16,9 @@
use
crate
::
mock
::
*
;
use
crate
::
mock
::
*
;
use
crate
::
mock
::{
Identity
,
System
};
use
crate
::
mock
::{
Identity
,
System
};
use
crate
::
pallet
as
pallet_duniter_wot
;
use
codec
::
Encode
;
use
codec
::
Encode
;
use
frame_support
::
instances
::
Instance1
;
use
frame_support
::
instances
::
{
Instance1
,
Instance2
}
;
use
frame_support
::{
assert_noop
,
assert_ok
};
use
frame_support
::{
assert_noop
,
assert_ok
};
use
pallet_identity
::{
use
pallet_identity
::{
IdtyName
,
IdtyStatus
,
NewOwnerKeyPayload
,
RevocationPayload
,
NEW_OWNER_KEY_PAYLOAD_PREFIX
,
IdtyName
,
IdtyStatus
,
NewOwnerKeyPayload
,
RevocationPayload
,
NEW_OWNER_KEY_PAYLOAD_PREFIX
,
...
@@ -46,9 +47,10 @@ fn test_creator_not_allowed_to_create_idty() {
...
@@ -46,9 +47,10 @@ fn test_creator_not_allowed_to_create_idty() {
// Alice should not be able to create an identity before block #2
// Alice should not be able to create an identity before block #2
// because Alice.next_issuable_on = 2
// because Alice.next_issuable_on = 2
// but the true reason is that alice did not receive enough certs
assert_noop!
(
assert_noop!
(
Identity
::
create_identity
(
Origin
::
signed
(
1
),
4
),
Identity
::
create_identity
(
Origin
::
signed
(
1
),
4
),
pallet_
identity
::
Error
::
<
Test
>
::
IdtyCreationPeriodNotRespected
pallet_
duniter_wot
::
Error
::
<
Test
,
Instance1
>
::
NotEnoughReceivedCertsToCreateIdty
);
);
});
});
}
}
...
@@ -114,7 +116,7 @@ fn test_smith_member_cant_change_its_idty_address() {
...
@@ -114,7 +116,7 @@ fn test_smith_member_cant_change_its_idty_address() {
13
,
13
,
TestSignature
(
13
,
(
NEW_OWNER_KEY_PAYLOAD_PREFIX
,
new_key_payload
)
.encode
())
TestSignature
(
13
,
(
NEW_OWNER_KEY_PAYLOAD_PREFIX
,
new_key_payload
)
.encode
())
),
),
pallet_
identity
::
Error
::
<
Test
>
::
NotAllowedToChangeIdtyAddress
pallet_
duniter_wot
::
Error
::
<
Test
,
Instance2
>
::
NotAllowedToChangeIdtyAddress
);
);
});
});
}
}
...
@@ -137,7 +139,7 @@ fn test_smith_member_cant_revoke_its_idty() {
...
@@ -137,7 +139,7 @@ fn test_smith_member_cant_revoke_its_idty() {
3
,
3
,
TestSignature
(
3
,
(
REVOCATION_PAYLOAD_PREFIX
,
revocation_payload
)
.encode
())
TestSignature
(
3
,
(
REVOCATION_PAYLOAD_PREFIX
,
revocation_payload
)
.encode
())
),
),
pallet_
identity
::
Error
::
<
Test
>
::
NotAllowedToRemoveIdty
pallet_
duniter_wot
::
Error
::
<
Test
,
Instance2
>
::
NotAllowedToRemoveIdty
);
);
});
});
}
}
...
@@ -269,7 +271,7 @@ fn test_idty_membership_expire_them_requested() {
...
@@ -269,7 +271,7 @@ fn test_idty_membership_expire_them_requested() {
// Alice can't renew her cert to Charlie
// Alice can't renew her cert to Charlie
assert_noop!
(
assert_noop!
(
Cert
::
add_cert
(
Origin
::
signed
(
1
),
1
,
3
),
Cert
::
add_cert
(
Origin
::
signed
(
1
),
1
,
3
),
pallet_
certification
::
Error
::
<
Test
,
Instance1
>
::
C
er
t
Not
Allowe
d
pallet_
duniter_wot
::
Error
::
<
Test
,
Instance1
>
::
Receiv
erNot
Foun
d
);
);
});
});
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment