Skip to content

Commit

Permalink
Fix tests for rebasing onto master
Browse files Browse the repository at this point in the history
  • Loading branch information
kvinwang committed Oct 12, 2022
1 parent 63e7c14 commit 06ed49a
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
---
source: pallets/phala/src/fat_tokenomic/tests.rs
assertion_line: 99
assertion_line: 98
expression: events
---
[
Event::FatTokenomic(
RuntimeEvent::FatTokenomic(
Event::ContractDepositChanged {
contract: 0x2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a,
deposit: 1000000000000,
},
),
RuntimeEvent::FatTokenomic(
Event::UserStakeChanged {
account: 0101010101010101010101010101010101010101010101010101010101010101 (5C62Ck4U...),
contract: 0x2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a,
stake: 1000000000000,
},
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -4,64 +4,71 @@ assertion_line: 90
expression: events
---
[
Event::System(
RuntimeEvent::System(
Event::NewAccount {
account: 0101010101010101010101010101010101010101010101010101010101010101 (5C62Ck4U...),
},
),
Event::Balances(
RuntimeEvent::Balances(
Event::Endowed {
account: 0101010101010101010101010101010101010101010101010101010101010101 (5C62Ck4U...),
free_balance: 100000000000000,
},
),
Event::Balances(
RuntimeEvent::Balances(
Event::BalanceSet {
who: 0101010101010101010101010101010101010101010101010101010101010101 (5C62Ck4U...),
free: 100000000000000,
reserved: 0,
},
),
Event::System(
RuntimeEvent::System(
Event::NewAccount {
account: 0202020202020202020202020202020202020202020202020202020202020202 (5C7LYpP2...),
},
),
Event::Balances(
RuntimeEvent::Balances(
Event::Endowed {
account: 0202020202020202020202020202020202020202020202020202020202020202 (5C7LYpP2...),
free_balance: 100000000000000,
},
),
Event::Balances(
RuntimeEvent::Balances(
Event::BalanceSet {
who: 0202020202020202020202020202020202020202020202020202020202020202 (5C7LYpP2...),
free: 100000000000000,
reserved: 0,
},
),
Event::System(
RuntimeEvent::System(
Event::NewAccount {
account: 6d6f646c706861742f746f6b0000000000000000000000000000000000000000 (5EYCAe5i...),
},
),
Event::Balances(
RuntimeEvent::Balances(
Event::Endowed {
account: 6d6f646c706861742f746f6b0000000000000000000000000000000000000000 (5EYCAe5i...),
free_balance: 1000000000000,
},
),
Event::Balances(
RuntimeEvent::Balances(
Event::Transfer {
from: 0101010101010101010101010101010101010101010101010101010101010101 (5C62Ck4U...),
to: 6d6f646c706861742f746f6b0000000000000000000000000000000000000000 (5EYCAe5i...),
amount: 1000000000000,
},
),
Event::FatTokenomic(
RuntimeEvent::FatTokenomic(
Event::ContractDepositChanged {
contract: 0x2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a,
deposit: 1000000000000,
},
),
RuntimeEvent::FatTokenomic(
Event::UserStakeChanged {
account: 0101010101010101010101010101010101010101010101010101010101010101 (5C62Ck4U...),
contract: 0x2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a,
stake: 1000000000000,
},
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -4,108 +4,136 @@ assertion_line: 64
expression: events
---
[
Event::System(
RuntimeEvent::System(
Event::NewAccount {
account: 0101010101010101010101010101010101010101010101010101010101010101 (5C62Ck4U...),
},
),
Event::Balances(
RuntimeEvent::Balances(
Event::Endowed {
account: 0101010101010101010101010101010101010101010101010101010101010101 (5C62Ck4U...),
free_balance: 100000000000000,
},
),
Event::Balances(
RuntimeEvent::Balances(
Event::BalanceSet {
who: 0101010101010101010101010101010101010101010101010101010101010101 (5C62Ck4U...),
free: 100000000000000,
reserved: 0,
},
),
Event::System(
RuntimeEvent::System(
Event::NewAccount {
account: 0202020202020202020202020202020202020202020202020202020202020202 (5C7LYpP2...),
},
),
Event::Balances(
RuntimeEvent::Balances(
Event::Endowed {
account: 0202020202020202020202020202020202020202020202020202020202020202 (5C7LYpP2...),
free_balance: 100000000000000,
},
),
Event::Balances(
RuntimeEvent::Balances(
Event::BalanceSet {
who: 0202020202020202020202020202020202020202020202020202020202020202 (5C7LYpP2...),
free: 100000000000000,
reserved: 0,
},
),
Event::System(
RuntimeEvent::System(
Event::NewAccount {
account: 6d6f646c706861742f746f6b0000000000000000000000000000000000000000 (5EYCAe5i...),
},
),
Event::Balances(
RuntimeEvent::Balances(
Event::Endowed {
account: 6d6f646c706861742f746f6b0000000000000000000000000000000000000000 (5EYCAe5i...),
free_balance: 1000000000000,
},
),
Event::Balances(
RuntimeEvent::Balances(
Event::Transfer {
from: 0101010101010101010101010101010101010101010101010101010101010101 (5C62Ck4U...),
to: 6d6f646c706861742f746f6b0000000000000000000000000000000000000000 (5EYCAe5i...),
amount: 1000000000000,
},
),
Event::FatTokenomic(
RuntimeEvent::FatTokenomic(
Event::ContractDepositChanged {
contract: 0x2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a,
deposit: 1000000000000,
},
),
Event::Balances(
RuntimeEvent::FatTokenomic(
Event::UserStakeChanged {
account: 0101010101010101010101010101010101010101010101010101010101010101 (5C62Ck4U...),
contract: 0x2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a,
stake: 1000000000000,
},
),
RuntimeEvent::Balances(
Event::Transfer {
from: 0202020202020202020202020202020202020202020202020202020202020202 (5C7LYpP2...),
to: 6d6f646c706861742f746f6b0000000000000000000000000000000000000000 (5EYCAe5i...),
amount: 2000000000000,
},
),
Event::FatTokenomic(
RuntimeEvent::FatTokenomic(
Event::ContractDepositChanged {
contract: 0x2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a,
deposit: 3000000000000,
},
),
Event::Balances(
RuntimeEvent::FatTokenomic(
Event::UserStakeChanged {
account: 0202020202020202020202020202020202020202020202020202020202020202 (5C7LYpP2...),
contract: 0x2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a,
stake: 2000000000000,
},
),
RuntimeEvent::Balances(
Event::Transfer {
from: 6d6f646c706861742f746f6b0000000000000000000000000000000000000000 (5EYCAe5i...),
to: 0202020202020202020202020202020202020202020202020202020202020202 (5C7LYpP2...),
amount: 2000000000000,
},
),
Event::FatTokenomic(
RuntimeEvent::FatTokenomic(
Event::ContractDepositChanged {
contract: 0x2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a,
deposit: 1000000000000,
},
),
Event::System(
RuntimeEvent::FatTokenomic(
Event::UserStakeChanged {
account: 0202020202020202020202020202020202020202020202020202020202020202 (5C7LYpP2...),
contract: 0x2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a,
stake: 0,
},
),
RuntimeEvent::System(
Event::KilledAccount {
account: 6d6f646c706861742f746f6b0000000000000000000000000000000000000000 (5EYCAe5i...),
},
),
Event::Balances(
RuntimeEvent::Balances(
Event::Transfer {
from: 6d6f646c706861742f746f6b0000000000000000000000000000000000000000 (5EYCAe5i...),
to: 0101010101010101010101010101010101010101010101010101010101010101 (5C62Ck4U...),
amount: 1000000000000,
},
),
Event::FatTokenomic(
RuntimeEvent::FatTokenomic(
Event::ContractDepositChanged {
contract: 0x2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a,
deposit: 0,
},
),
RuntimeEvent::FatTokenomic(
Event::UserStakeChanged {
account: 0101010101010101010101010101010101010101010101010101010101010101 (5C62Ck4U...),
contract: 0x2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a,
stake: 0,
},
),
]
4 changes: 2 additions & 2 deletions pallets/phala/src/fat_tokenomic/tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::*;
use frame_support::{assert_err, assert_ok};
use mock::{Origin, Test, DOLLARS};
use mock::{RuntimeOrigin as Origin, Test, DOLLARS};

use sp_core::crypto::AccountId32;
use sp_core::H256;
Expand All @@ -22,7 +22,7 @@ fn stake_of_contract() -> u128 {
}

fn stake_of_user(user: &AccountId32) -> u128 {
ContractUserStakes::<Test>::get((&CONTRACT, user))
ContractUserStakes::<Test>::get(user, &CONTRACT)
}

fn balance_of_user(user: &AccountId32) -> u128 {
Expand Down
20 changes: 10 additions & 10 deletions pallets/phala/src/fat_tokenomic/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ impl system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = ();
type BlockLength = ();
type Origin = Origin;
type Call = Call;
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type Index = u64;
type BlockNumber = BlockNumber;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = sp_core::crypto::AccountId32;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount;
type DbWeight = ();
type Version = ();
Expand All @@ -73,7 +73,7 @@ impl system::Config for Test {
impl pallet_balances::Config for Test {
type Balance = Balance;
type DustRemoval = ();
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type WeightInfo = ();
Expand All @@ -98,16 +98,16 @@ impl mq::Config for Test {

pub struct MqCallMatcher;
impl mq::CallMatcher<Test> for MqCallMatcher {
fn match_call(call: &Call) -> Option<&mq::Call<Test>> {
fn match_call(call: &RuntimeCall) -> Option<&mq::Call<Test>> {
match call {
Call::PhalaMq(mq_call) => Some(mq_call),
RuntimeCall::PhalaMq(mq_call) => Some(mq_call),
_ => None,
}
}
}

impl registry::Config for Test {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type AttestationValidator = MockValidator;
type UnixTime = Timestamp;
Expand All @@ -117,13 +117,13 @@ impl registry::Config for Test {
}

impl fat::Config for Test {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type InkCodeSizeLimit = ConstU32<{ 1024 * 1024 }>;
type SidevmCodeSizeLimit = ConstU32<{ 1024 * 1024 }>;
}

impl fat_tokenomic::Config for Test {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
}

Expand Down Expand Up @@ -163,7 +163,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
sp_io::TestExternalities::new(t)
}

pub fn take_events() -> Vec<Event> {
pub fn take_events() -> Vec<RuntimeEvent> {
let evt = System::events()
.into_iter()
.map(|evt| evt.event)
Expand Down

0 comments on commit 06ed49a

Please sign in to comment.