Skip to content

Commit 8359657

Browse files
committed
Refactor test functions
1 parent e19e280 commit 8359657

File tree

6 files changed

+225
-211
lines changed

6 files changed

+225
-211
lines changed

crates/kilt-dip-primitives/src/merkle/v0/dip_subject_state/mod.rs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -120,40 +120,6 @@ impl<
120120
}
121121
}
122122

123-
#[cfg(test)]
124-
impl<
125-
KiltDidKeyId,
126-
KiltAccountId,
127-
KiltBlockNumber,
128-
KiltWeb3Name,
129-
KiltLinkableAccountId,
130-
ConsumerBlockNumber,
131-
const MAX_REVEALED_LEAVES_COUNT: u32,
132-
>
133-
DipRevealedDetailsAndUnverifiedDidSignature<
134-
KiltDidKeyId,
135-
KiltAccountId,
136-
KiltBlockNumber,
137-
KiltWeb3Name,
138-
KiltLinkableAccountId,
139-
ConsumerBlockNumber,
140-
MAX_REVEALED_LEAVES_COUNT,
141-
> where
142-
KiltDidKeyId: Default,
143-
KiltBlockNumber: Default,
144-
ConsumerBlockNumber: Default,
145-
{
146-
pub(crate) fn with_signature_time(valid_until: ConsumerBlockNumber) -> Self {
147-
Self {
148-
signature: TimeBoundDidSignature {
149-
valid_until,
150-
..Default::default()
151-
},
152-
revealed_leaves: Default::default(),
153-
}
154-
}
155-
}
156-
157123
/// A DIP proof whose information has been verified and whose signature has been
158124
/// verified not to be expired, but that yet does not contain information as to
159125
/// which of the revealed keys has generated the signature.

crates/kilt-dip-primitives/src/merkle/v0/dip_subject_state/tests.rs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,40 @@
1919
mod dip_revealed_details_and_unverified_did_signature {
2020
use frame_support::{assert_err, assert_ok};
2121

22-
use crate::{DipRevealedDetailsAndUnverifiedDidSignature, Error};
22+
use crate::{DipRevealedDetailsAndUnverifiedDidSignature, Error, TimeBoundDidSignature};
23+
24+
impl<
25+
KiltDidKeyId,
26+
KiltAccountId,
27+
KiltBlockNumber,
28+
KiltWeb3Name,
29+
KiltLinkableAccountId,
30+
ConsumerBlockNumber,
31+
const MAX_REVEALED_LEAVES_COUNT: u32,
32+
>
33+
DipRevealedDetailsAndUnverifiedDidSignature<
34+
KiltDidKeyId,
35+
KiltAccountId,
36+
KiltBlockNumber,
37+
KiltWeb3Name,
38+
KiltLinkableAccountId,
39+
ConsumerBlockNumber,
40+
MAX_REVEALED_LEAVES_COUNT,
41+
> where
42+
KiltDidKeyId: Default,
43+
KiltBlockNumber: Default,
44+
ConsumerBlockNumber: Default,
45+
{
46+
fn with_signature_time(valid_until: ConsumerBlockNumber) -> Self {
47+
Self {
48+
signature: TimeBoundDidSignature {
49+
valid_until,
50+
..Default::default()
51+
},
52+
revealed_leaves: Default::default(),
53+
}
54+
}
55+
}
2356

2457
#[test]
2558
fn verify_signature_time_successful() {

crates/kilt-dip-primitives/src/merkle/v0/provider_state/mod.rs

Lines changed: 0 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -115,39 +115,6 @@ impl<
115115
}
116116
}
117117

118-
#[cfg(test)]
119-
impl<
120-
RelayBlockNumber,
121-
KiltDidKeyId,
122-
KiltAccountId,
123-
KiltBlockNumber,
124-
KiltWeb3Name,
125-
KiltLinkableAccountId,
126-
ConsumerBlockNumber,
127-
>
128-
ParachainDipDidProof<
129-
RelayBlockNumber,
130-
KiltDidKeyId,
131-
KiltAccountId,
132-
KiltBlockNumber,
133-
KiltWeb3Name,
134-
KiltLinkableAccountId,
135-
ConsumerBlockNumber,
136-
> where
137-
KiltDidKeyId: Default,
138-
KiltBlockNumber: Default,
139-
ConsumerBlockNumber: Default,
140-
{
141-
pub(crate) fn with_provider_head_proof(provider_head_proof: ProviderHeadStateProof<RelayBlockNumber>) -> Self {
142-
Self {
143-
provider_head_proof,
144-
dip_commitment_proof: Default::default(),
145-
dip_proof: Default::default(),
146-
signature: Default::default(),
147-
}
148-
}
149-
}
150-
151118
impl<
152119
RelayBlockNumber,
153120
KiltDidKeyId,
@@ -378,42 +345,6 @@ impl<
378345
}
379346
}
380347

381-
#[cfg(test)]
382-
impl<
383-
StateRoot,
384-
KiltDidKeyId,
385-
KiltAccountId,
386-
KiltBlockNumber,
387-
KiltWeb3Name,
388-
KiltLinkableAccountId,
389-
ConsumerBlockNumber,
390-
>
391-
DipDidProofWithVerifiedStateRoot<
392-
StateRoot,
393-
KiltDidKeyId,
394-
KiltAccountId,
395-
KiltBlockNumber,
396-
KiltWeb3Name,
397-
KiltLinkableAccountId,
398-
ConsumerBlockNumber,
399-
> where
400-
KiltDidKeyId: Default,
401-
KiltBlockNumber: Default,
402-
ConsumerBlockNumber: Default,
403-
{
404-
pub(crate) fn with_state_root_and_dip_commitment_proof(
405-
provider_state_root: StateRoot,
406-
dip_commitment_proof: DipCommitmentStateProof,
407-
) -> Self {
408-
Self {
409-
state_root: provider_state_root,
410-
dip_commitment_proof,
411-
dip_proof: Default::default(),
412-
signature: Default::default(),
413-
}
414-
}
415-
}
416-
417348
/// A DIP proof that has had the relaychain state and the DIP commitment
418349
/// verified for the provided relaychain block number.
419350
///
@@ -562,36 +493,3 @@ impl<
562493
})
563494
}
564495
}
565-
566-
#[cfg(test)]
567-
impl<
568-
Commitment,
569-
KiltDidKeyId,
570-
KiltAccountId,
571-
KiltBlockNumber,
572-
KiltWeb3Name,
573-
KiltLinkableAccountId,
574-
ConsumerBlockNumber,
575-
>
576-
DipDidProofWithVerifiedSubjectCommitment<
577-
Commitment,
578-
KiltDidKeyId,
579-
KiltAccountId,
580-
KiltBlockNumber,
581-
KiltWeb3Name,
582-
KiltLinkableAccountId,
583-
ConsumerBlockNumber,
584-
> where
585-
ConsumerBlockNumber: Default,
586-
{
587-
pub(crate) fn with_commitment_and_dip_proof(
588-
commitment: Commitment,
589-
dip_proof: DidMerkleProof<KiltDidKeyId, KiltAccountId, KiltBlockNumber, KiltWeb3Name, KiltLinkableAccountId>,
590-
) -> Self {
591-
Self {
592-
dip_commitment: commitment,
593-
dip_proof,
594-
signature: TimeBoundDidSignature::default(),
595-
}
596-
}
597-
}

crates/kilt-dip-primitives/src/merkle/v0/provider_state/tests.rs

Lines changed: 108 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,38 @@ mod parachain_dip_did_proof {
3030

3131
use crate::{state_proofs::MerkleProofError, Error, ParachainDipDidProof, ProviderHeadStateProof};
3232

33+
impl<
34+
RelayBlockNumber,
35+
KiltDidKeyId,
36+
KiltAccountId,
37+
KiltBlockNumber,
38+
KiltWeb3Name,
39+
KiltLinkableAccountId,
40+
ConsumerBlockNumber,
41+
>
42+
ParachainDipDidProof<
43+
RelayBlockNumber,
44+
KiltDidKeyId,
45+
KiltAccountId,
46+
KiltBlockNumber,
47+
KiltWeb3Name,
48+
KiltLinkableAccountId,
49+
ConsumerBlockNumber,
50+
> where
51+
KiltDidKeyId: Default,
52+
KiltBlockNumber: Default,
53+
ConsumerBlockNumber: Default,
54+
{
55+
fn with_provider_head_proof(provider_head_proof: ProviderHeadStateProof<RelayBlockNumber>) -> Self {
56+
Self {
57+
provider_head_proof,
58+
dip_commitment_proof: Default::default(),
59+
dip_proof: Default::default(),
60+
signature: Default::default(),
61+
}
62+
}
63+
}
64+
3365
// Storage proof generated at Polkadot block `19_663_508` with hash
3466
// `0x6e87866fb4f412e1e691e25d294019a7695d5a756ee7bc8d012c25177b5e1e13` for
3567
// storage key
@@ -164,6 +196,41 @@ mod dip_did_proof_with_verified_relay_state_root {
164196

165197
use crate::{state_proofs::MerkleProofError, DipCommitmentStateProof, DipDidProofWithVerifiedStateRoot, Error};
166198

199+
impl<
200+
StateRoot,
201+
KiltDidKeyId,
202+
KiltAccountId,
203+
KiltBlockNumber,
204+
KiltWeb3Name,
205+
KiltLinkableAccountId,
206+
ConsumerBlockNumber,
207+
>
208+
DipDidProofWithVerifiedStateRoot<
209+
StateRoot,
210+
KiltDidKeyId,
211+
KiltAccountId,
212+
KiltBlockNumber,
213+
KiltWeb3Name,
214+
KiltLinkableAccountId,
215+
ConsumerBlockNumber,
216+
> where
217+
KiltDidKeyId: Default,
218+
KiltBlockNumber: Default,
219+
ConsumerBlockNumber: Default,
220+
{
221+
fn with_state_root_and_dip_commitment_proof(
222+
provider_state_root: StateRoot,
223+
dip_commitment_proof: DipCommitmentStateProof,
224+
) -> Self {
225+
Self {
226+
state_root: provider_state_root,
227+
dip_commitment_proof,
228+
dip_proof: Default::default(),
229+
signature: Default::default(),
230+
}
231+
}
232+
}
233+
167234
construct_runtime!(
168235
pub enum TestProviderRuntime {
169236
System: frame_system,
@@ -346,7 +413,47 @@ mod dip_did_proof_with_verified_subject_commitment {
346413
AccountId32, BoundedVec,
347414
};
348415

349-
use crate::{DidMerkleProof, DipDidProofWithVerifiedSubjectCommitment, Error, RevealedDidKey};
416+
use crate::{
417+
DidMerkleProof, DipDidProofWithVerifiedSubjectCommitment, Error, RevealedDidKey, TimeBoundDidSignature,
418+
};
419+
420+
impl<
421+
Commitment,
422+
KiltDidKeyId,
423+
KiltAccountId,
424+
KiltBlockNumber,
425+
KiltWeb3Name,
426+
KiltLinkableAccountId,
427+
ConsumerBlockNumber,
428+
>
429+
DipDidProofWithVerifiedSubjectCommitment<
430+
Commitment,
431+
KiltDidKeyId,
432+
KiltAccountId,
433+
KiltBlockNumber,
434+
KiltWeb3Name,
435+
KiltLinkableAccountId,
436+
ConsumerBlockNumber,
437+
> where
438+
ConsumerBlockNumber: Default,
439+
{
440+
fn with_commitment_and_dip_proof(
441+
commitment: Commitment,
442+
dip_proof: DidMerkleProof<
443+
KiltDidKeyId,
444+
KiltAccountId,
445+
KiltBlockNumber,
446+
KiltWeb3Name,
447+
KiltLinkableAccountId,
448+
>,
449+
) -> Self {
450+
Self {
451+
dip_commitment: commitment,
452+
dip_proof,
453+
signature: TimeBoundDidSignature::default(),
454+
}
455+
}
456+
}
350457

351458
// DIP proof generated on Peregrine via the `dipProvider::generateProof` runtime
352459
// API.

0 commit comments

Comments
 (0)