Add verify block to benchmark tests (#5551)

* Add verify block to benchmarks macro.

* Update all benchmarks.

* Add tests, add params.

* Should panic.

* ups, add closures

* Update tests.rs

* update macro syntax

* Revert benchmark syntax change

* verify only in tests

* Update tests.rs

* Uncomment staking

* Fix tests for benchmark instance

* Add docs

* Update frame/benchmarking/src/lib.rs

* add trace logs to benchmarks

* Verify returns closure

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
Marcio Diaz
2020-04-08 12:55:06 +02:00
committed by GitHub
parent c73398ab03
commit 7cc095ec9f
6 changed files with 332 additions and 70 deletions
+5 -2
View File
@@ -51,10 +51,13 @@ benchmarks! {
let _ = <Balances<T> as Currency<_>>::make_free_balance_be(&caller, balance);
// Transfer `e - 1` existential deposits + 1 unit, which guarantees to create one account, and reap this user.
let recipient = account("recipient", u, SEED);
let recipient_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(recipient);
let recipient: T::AccountId = account("recipient", u, SEED);
let recipient_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(recipient.clone());
let transfer_amount = existential_deposit.saturating_mul((e - 1).into()) + 1.into();
}: _(RawOrigin::Signed(caller), recipient_lookup, transfer_amount)
verify {
assert_eq!(Balances::<T>::free_balance(&recipient), transfer_amount);
}
// Benchmark `transfer` with the best possible condition:
// * Both accounts exist and will continue to exist.