This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
fungible conformance tests: Inspect and Mutate #13852
Merged
Merged
Changes from 45 commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
577e69e
typo
liamaharon 2d43fbc
- create test files for each fungile trait
liamaharon 344d3a6
Merge branch 'master' of github.com:paritytech/substrate into liam-fu…
liamaharon 9e3dc4e
wrap inspect tests in a macro
liamaharon c8b9e80
first run of mutate tests
liamaharon 9f553fd
move test implementation out of ballances
liamaharon 68db553
Merge branch 'master' of github.com:paritytech/substrate into liam-fu…
liamaharon 6ba1a0a
Merge branch 'master' of github.com:paritytech/substrate into liam-fu…
liamaharon bdf0020
make tests more generic
liamaharon c1286cd
transfer tests
liamaharon b1c7b2a
combine inspect and mutate tests
liamaharon 28ae371
set balance failing tests
liamaharon bfd008b
can_deposit tests
liamaharon 7a7fab9
can_withdraw tests
liamaharon d305774
test reducible_balance
liamaharon 7544e0f
remove balanced stub
liamaharon 509f61a
revert set_balance return val fix
liamaharon d7bf251
typo
liamaharon 2873dda
Merge branch 'master' of github.com:paritytech/substrate into liam-fu…
liamaharon 6c4de8e
Merge branch 'master' of github.com:paritytech/substrate into liam-fu…
liamaharon 3ebe6e9
macro and dust trap tests
liamaharon 33f6a6b
disable test when it doesn't make sense
liamaharon 13455c7
remove debug comment
liamaharon a948896
reduce macro boilerplate
liamaharon c12a327
improved var naming
liamaharon 1685856
improve variable naming
liamaharon 1b13509
remove redundant comment
liamaharon 8845504
remove placeholder tests
liamaharon 8b1b707
remove placeholder tests
liamaharon 95286a8
simplify macro
liamaharon 682f33f
Update frame/balances/src/tests/fungible_conformance_tests.rs
liamaharon 090e7bb
use Balance from T
liamaharon bb4242d
Merge branch 'liam-fungibles-conformance-tests' of github.com:parityt…
liamaharon dd7ae89
fix copyright
liamaharon cdb4fa0
Merge branch 'master' of github.com:paritytech/substrate into liam-fu…
liamaharon 880aeb0
add test doc comments
liamaharon 8d8ffa9
improve test naming
liamaharon 6764c26
Merge branch 'master' of github.com:paritytech/substrate into liam-fu…
liamaharon 704f06e
clippy
liamaharon e8b1323
fix rustdoc errors
liamaharon f7baa52
fix rustdoc
liamaharon 137a8dc
improve macro
liamaharon 39c00bb
improve variable naming
liamaharon 76c0808
Merge branch 'master' of github.com:paritytech/substrate into liam-fu…
liamaharon 00d494b
remove redundant comment
liamaharon f265ff1
use path
liamaharon 30b9781
Merge branch 'master' of github.com:paritytech/substrate into liam-fu…
liamaharon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| // This file is part of Substrate. | ||
|
|
||
| // Copyright (C) Parity Technologies (UK) Ltd. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| use super::*; | ||
| use frame_support::traits::fungible::{conformance_tests, Inspect, Mutate}; | ||
| use paste::paste; | ||
|
|
||
| macro_rules! run_tests { | ||
| ($parent_module:tt :: $child_module:tt, $ext_deposit:expr, $($name:ident),*) => { | ||
| $( | ||
| paste! { | ||
| #[test] | ||
| fn [< $name _existential_deposit_ $ext_deposit _dust_trap_on >]() { | ||
| let trap_account = <Test as frame_system::Config>::AccountId::from(65174286u64); | ||
| let builder = ExtBuilder::default().existential_deposit($ext_deposit).dust_trap(trap_account); | ||
| builder.build_and_execute_with(|| { | ||
| Balances::set_balance(&trap_account, Balances::minimum_balance()); | ||
| $parent_module::$child_module::$name::< | ||
| Balances, | ||
| <Test as frame_system::Config>::AccountId, | ||
| >(Some(trap_account)); | ||
| }); | ||
| } | ||
|
|
||
| #[test] | ||
| fn [< $name _existential_deposit_ $ext_deposit _dust_trap_off >]() { | ||
| let builder = ExtBuilder::default().existential_deposit($ext_deposit); | ||
| builder.build_and_execute_with(|| { | ||
| $parent_module::$child_module::$name::< | ||
| Balances, | ||
| <Test as frame_system::Config>::AccountId, | ||
| >(None); | ||
| }); | ||
| } | ||
| } | ||
| )* | ||
| }; | ||
| ($parent_module:tt :: $child_module:tt, $ext_deposit:expr) => { | ||
| run_tests!( | ||
| $parent_module::$child_module, | ||
| $ext_deposit, | ||
| mint_into_success, | ||
| mint_into_overflow, | ||
| mint_into_below_minimum, | ||
| burn_from_exact_success, | ||
| burn_from_best_effort_success, | ||
| burn_from_exact_insufficient_funds, | ||
| restore_success, | ||
| restore_overflow, | ||
| restore_below_minimum, | ||
| shelve_success, | ||
| shelve_insufficient_funds, | ||
| transfer_success, | ||
| transfer_expendable_all, | ||
| transfer_expendable_dust, | ||
| transfer_protect_preserve, | ||
| set_balance_mint_success, | ||
| set_balance_burn_success, | ||
| can_deposit_success, | ||
| can_deposit_below_minimum, | ||
| can_deposit_overflow, | ||
| can_withdraw_success, | ||
| can_withdraw_reduced_to_zero, | ||
| can_withdraw_balance_low, | ||
| reducible_balance_expendable, | ||
| reducible_balance_protect_preserve | ||
| ); | ||
| }; | ||
| } | ||
|
|
||
| run_tests!(conformance_tests::inspect_mutate, 1); | ||
| run_tests!(conformance_tests::inspect_mutate, 2); | ||
| run_tests!(conformance_tests::inspect_mutate, 5); | ||
| run_tests!(conformance_tests::inspect_mutate, 1000); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.