Skip to content
This repository was archived by the owner on Jul 4, 2022. It is now read-only.

Commit 189007b

Browse files
author
Alex Sed
authored
Fix Attestation tests (#145)
1 parent 3780398 commit 189007b

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

prml/attestation/src/lib.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,14 @@ mod tests {
182182
use crate::mock::{Attestation, ExtBuilder, Origin, System, Test, TestEvent};
183183
use frame_support::{assert_noop, assert_ok};
184184

185+
type AccountId = <Test as frame_system::Trait>::AccountId;
186+
185187
#[test]
186188
fn initialize_holder_has_no_claims() {
187189
let holder = 0xbaa;
188190
ExtBuilder::build().execute_with(|| {
189191
// Note: without any valid issuers, there is no valid input for topics or value
190-
assert_eq!(Attestation::issuers(holder), []);
192+
assert_eq!(Attestation::issuers(holder), <Vec<AccountId>>::new());
191193
})
192194
}
193195

@@ -304,7 +306,7 @@ mod tests {
304306
assert_ok!(result_add);
305307
assert_ok!(result_remove);
306308

307-
assert_eq!(Attestation::issuers(holder), []);
309+
assert_eq!(Attestation::issuers(holder), <Vec<AccountId>>::new());
308310
assert_eq!(Attestation::topics((holder, issuer)), []);
309311
assert_eq!(Attestation::value((holder, issuer, topic)), invalid_value);
310312
})
@@ -384,7 +386,7 @@ mod tests {
384386
assert_ok!(result_remove_food);
385387
assert_ok!(result_remove_loot);
386388

387-
assert_eq!(Attestation::issuers(holder), []);
389+
assert_eq!(Attestation::issuers(holder), <Vec<AccountId>>::new());
388390
assert_eq!(Attestation::topics((holder, issuer)), []);
389391
assert_eq!(Attestation::value((holder, issuer, topic_food)), invalid_value);
390392
assert_eq!(Attestation::value((holder, issuer, topic_loot)), invalid_value);
@@ -411,6 +413,7 @@ mod tests {
411413
let topic = AttestationTopic::from(0xf00d);
412414
let value = AttestationValue::from(0xb33f);
413415
ExtBuilder::build().execute_with(|| {
416+
System::set_block_number(1);
414417
assert_ok!(Attestation::set_claim(Origin::signed(issuer), holder, topic, value));
415418

416419
let expected_event = TestEvent::attestation(RawEvent::ClaimCreated(holder, issuer, topic, value));
@@ -426,6 +429,7 @@ mod tests {
426429
let topic = AttestationTopic::from(0xf00d);
427430
let value = AttestationValue::from(0xb33f);
428431
ExtBuilder::build().execute_with(|| {
432+
System::set_block_number(1);
429433
assert_ok!(Attestation::set_claim(Origin::signed(issuer), holder, topic, value));
430434
assert_ok!(Attestation::remove_claim(Origin::signed(issuer), holder, topic));
431435

@@ -443,6 +447,7 @@ mod tests {
443447
let value_old = AttestationValue::from(0xb33f);
444448
let value_new = AttestationValue::from(0xcabba93);
445449
ExtBuilder::build().execute_with(|| {
450+
System::set_block_number(1);
446451
assert_ok!(Attestation::set_claim(Origin::signed(issuer), holder, topic, value_old));
447452
assert_ok!(Attestation::set_claim(Origin::signed(issuer), holder, topic, value_new));
448453

prml/attestation/src/mock.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,28 +46,36 @@ parameter_types! {
4646
pub const AvailableBlockRatio: Perbill = Perbill::one();
4747
}
4848
impl frame_system::Trait for Test {
49+
type BaseCallFilter = ();
4950
type Origin = Origin;
5051
type Index = u64;
51-
type BlockNumber = u64;
5252
type Call = ();
53+
type BlockNumber = u64;
5354
type Hash = H256;
5455
type Hashing = BlakeTwo256;
5556
type AccountId = u64;
56-
type Lookup = IdentityLookup<u64>;
57+
type Lookup = IdentityLookup<Self::AccountId>;
5758
type Header = Header;
5859
type Event = TestEvent;
60+
type BlockHashCount = BlockHashCount;
5961
type MaximumBlockWeight = MaximumBlockWeight;
60-
type MaximumBlockLength = MaximumBlockLength;
62+
type DbWeight = ();
63+
type BlockExecutionWeight = ();
64+
type ExtrinsicBaseWeight = ();
65+
type MaximumExtrinsicWeight = MaximumBlockWeight;
6166
type AvailableBlockRatio = AvailableBlockRatio;
62-
type BlockHashCount = BlockHashCount;
67+
type MaximumBlockLength = MaximumBlockLength;
6368
type Version = ();
64-
type ModuleToIndex = ();
65-
type Doughnut = ();
66-
type DelegatedDispatchVerifier = ();
69+
type PalletInfo = ();
70+
type AccountData = ();
71+
type OnNewAccount = ();
72+
type OnKilledAccount = ();
73+
type SystemWeightInfo = ();
6774
}
6875

6976
impl Trait for Test {
7077
type Event = TestEvent;
78+
type WeightInfo = ();
7179
}
7280

7381
mod attestation {
@@ -77,7 +85,7 @@ mod attestation {
7785
use frame_system as system;
7886
impl_outer_event! {
7987
pub enum TestEvent for Test {
80-
system,
88+
system<T>,
8189
attestation<T>,
8290
}
8391
}

0 commit comments

Comments
 (0)