Skip to content

Commit

Permalink
Passing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dastansam committed Feb 3, 2024
1 parent b0371f4 commit dd1e8ae
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 41 deletions.
11 changes: 7 additions & 4 deletions pallets/iso-8583/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,23 @@ sp-runtime = { workspace = true }

[dev-dependencies]
sp-io = { workspace = true }
sp-runtime = { workspace = true }
sp-runtime = { workspace = true, features = ["std"] }
pallet-balances = { workspace = true, features = ["std", "insecure_zero_ed"] }
pallet-timestamp = { workspace = true }
pallet-timestamp = { workspace = true, features = ["std"] }

[features]
default = ["std"]
std = [
"codec/std",
"frame-benchmarking",
"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",
"scale-info/std",
"sp-core/std",
"sp-runtime/std",
]
runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks"]
runtime-benchmarks = [
"frame-benchmarking",
"frame-support/runtime-benchmarks",
]
try-runtime = ["frame-support/try-runtime"]
30 changes: 12 additions & 18 deletions pallets/iso-8583/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ use sp_runtime::DispatchError;

use crate::{mock::*, types::FinalisedTransaction, Error};

/// Assert a certain event is emitted by the runtime
fn assert_event_emitted(event: RuntimeEvent) {
assert!(System::events().iter().any(|r| r.event == event));
}

mod extrinsics {
use super::*;

Expand Down Expand Up @@ -63,7 +58,7 @@ mod extrinsics {
assert_eq!(Balances::reserved_balance(3), 100);

// event is emitted
assert_event_emitted(RuntimeEvent::ISO8583(
System::assert_has_event(RuntimeEvent::ISO8583(
crate::Event::<Test>::InitiateTransfer { from: 3, to: 10, amount: 100 },
));
});
Expand All @@ -86,7 +81,7 @@ mod extrinsics {
assert_ok!(ISO8583::approve(RuntimeOrigin::signed(3), 10, 50));

// event is emitted
assert_event_emitted(RuntimeEvent::ISO8583(crate::Event::<Test>::Allowance {
System::assert_has_event(RuntimeEvent::ISO8583(crate::Event::<Test>::Allowance {
from: 3,
to: 10,
amount: 50,
Expand Down Expand Up @@ -124,10 +119,9 @@ mod extrinsics {
assert_ok!(ISO8583::initiate_revert(RuntimeOrigin::signed(1), dummy_hash));

// event is emitted
assert_event_emitted(RuntimeEvent::ISO8583(crate::Event::<Test>::InitiateRevert {
who: 1,
hash: dummy_hash,
}));
System::assert_has_event(RuntimeEvent::ISO8583(
crate::Event::<Test>::InitiateRevert { who: 1, hash: dummy_hash },
));
});
}

Expand Down Expand Up @@ -177,7 +171,7 @@ mod extrinsics {
));

// event is emitted
assert_event_emitted(RuntimeEvent::ISO8583(
System::assert_has_event(RuntimeEvent::ISO8583(
crate::Event::<Test>::ProcessedTransaction {
event_id: finalised_transaction_mint.event_id,
status: finalised_transaction_mint.status,
Expand All @@ -188,7 +182,7 @@ mod extrinsics {
assert_eq!(Balances::free_balance(4), INITIAL_BALANCE + 20);

// mint event is emitted
assert_event_emitted(RuntimeEvent::Balances(
System::assert_has_event(RuntimeEvent::Balances(
pallet_balances::Event::<Test>::Deposit { who: 4, amount: 20 },
));

Expand All @@ -215,7 +209,7 @@ mod extrinsics {
));

// event is emitted
assert_event_emitted(RuntimeEvent::ISO8583(
System::assert_has_event(RuntimeEvent::ISO8583(
crate::Event::<Test>::ProcessedTransaction {
event_id: finalised_transaction_transfer.event_id.clone(),
status: finalised_transaction_transfer.status.clone(),
Expand All @@ -226,7 +220,7 @@ mod extrinsics {
assert_eq!(Balances::free_balance(5), INITIAL_BALANCE + 23);

// transfer event is emitted
assert_event_emitted(RuntimeEvent::Balances(
System::assert_has_event(RuntimeEvent::Balances(
pallet_balances::Event::<Test>::Transfer { from: 3, to: 5, amount: 23 },
));
});
Expand Down Expand Up @@ -269,7 +263,7 @@ mod trait_tests {
assert_ok!(ISO8583::transfer(&3, &4, 20));

// event is emitted
assert_event_emitted(RuntimeEvent::Balances(
System::assert_has_event(RuntimeEvent::Balances(
pallet_balances::Event::<Test>::Transfer { from: 3, to: 4, amount: 20 },
));
});
Expand All @@ -285,7 +279,7 @@ mod trait_tests {
assert_ok!(ISO8583::approve(RuntimeOrigin::signed(3), 4, 50));

// event is emitted
assert_event_emitted(RuntimeEvent::ISO8583(crate::Event::<Test>::Allowance {
System::assert_has_event(RuntimeEvent::ISO8583(crate::Event::<Test>::Allowance {
from: 3,
to: 4,
amount: 50,
Expand Down Expand Up @@ -333,7 +327,7 @@ mod trait_tests {
);

// event is emitted
assert_event_emitted(RuntimeEvent::Balances(
System::assert_has_event(RuntimeEvent::Balances(
pallet_balances::Event::<Test>::Transfer { from: 4, to: 10, amount: 25 },
));
});
Expand Down
5 changes: 0 additions & 5 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,6 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("iso-8583"),
impl_name: create_runtime_str!("iso-8583"),
authoring_version: 1,
// The version of the runtime specification. A full node will not attempt to use its native
// runtime in substitute for the on-chain Wasm runtime unless all of `spec_name`,
// `spec_version`, and `authoring_version` are the same between Wasm and native.
// This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use
// the compatible custom types.
spec_version: 100,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
Expand Down
14 changes: 0 additions & 14 deletions rust-toolchain.toml

This file was deleted.

0 comments on commit dd1e8ae

Please sign in to comment.