|
| 1 | +// This file is part of the SORA network and Polkaswap app. |
| 2 | + |
| 3 | +// Copyright (c) 2020, 2021, Polka Biome Ltd. All rights reserved. |
| 4 | +// SPDX-License-Identifier: BSD-4-Clause |
| 5 | + |
| 6 | +// Redistribution and use in source and binary forms, with or without modification, |
| 7 | +// are permitted provided that the following conditions are met: |
| 8 | + |
| 9 | +// Redistributions of source code must retain the above copyright notice, this list |
| 10 | +// of conditions and the following disclaimer. |
| 11 | +// Redistributions in binary form must reproduce the above copyright notice, this |
| 12 | +// list of conditions and the following disclaimer in the documentation and/or other |
| 13 | +// materials provided with the distribution. |
| 14 | +// |
| 15 | +// All advertising materials mentioning features or use of this software must display |
| 16 | +// the following acknowledgement: This product includes software developed by Polka Biome |
| 17 | +// Ltd., SORA, and Polkaswap. |
| 18 | +// |
| 19 | +// Neither the name of the Polka Biome Ltd. nor the names of its contributors may be used |
| 20 | +// to endorse or promote products derived from this software without specific prior written permission. |
| 21 | + |
| 22 | +// THIS SOFTWARE IS PROVIDED BY Polka Biome Ltd. AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, |
| 23 | +// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 24 | +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Polka Biome Ltd. BE LIABLE FOR ANY |
| 25 | +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 26 | +// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| 27 | +// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 28 | +// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE |
| 29 | +// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | + |
| 31 | +//! BridgeInboundChannel pallet benchmarking |
| 32 | +
|
| 33 | +use super::*; |
| 34 | +use bridge_types::GenericNetworkId; |
| 35 | +use frame_benchmarking::{benchmarks, impl_benchmark_test_suite}; |
| 36 | +use frame_system::{self, RawOrigin}; |
| 37 | +use sp_std::prelude::*; |
| 38 | + |
| 39 | +const BASE_NETWORK_ID: GenericNetworkId = GenericNetworkId::Sub(SubNetworkId::Mainnet); |
| 40 | + |
| 41 | +#[allow(unused_imports)] |
| 42 | +use crate::inbound::Pallet as BridgeInboundChannel; |
| 43 | + |
| 44 | +// This collection of benchmarks should include a benchmark for each |
| 45 | +// call dispatched by the channel, i.e. each "app" pallet function |
| 46 | +// that can be invoked by MessageDispatch. The most expensive call |
| 47 | +// should be used in the `submit` benchmark. |
| 48 | +// |
| 49 | +// We rely on configuration via chain spec of the app pallets because |
| 50 | +// we don't have access to their storage here. |
| 51 | +benchmarks! { |
| 52 | + // Benchmark `submit` extrinsic under worst case conditions: |
| 53 | + // * `submit` dispatches the DotApp::unlock call |
| 54 | + // * `unlock` call successfully unlocks DOT |
| 55 | + submit { |
| 56 | + let messages = vec![]; |
| 57 | + let commitment = bridge_types::GenericCommitment::Sub( |
| 58 | + bridge_types::substrate::Commitment { |
| 59 | + messages: messages.try_into().unwrap(), |
| 60 | + nonce: 1u64, |
| 61 | + } |
| 62 | + ); |
| 63 | + let proof = T::Verifier::valid_proof().unwrap(); |
| 64 | + }: _(RawOrigin::None, BASE_NETWORK_ID, commitment, proof) |
| 65 | + verify { |
| 66 | + assert_eq!(1, <ChannelNonces<T>>::get(BASE_NETWORK_ID)); |
| 67 | + } |
| 68 | +} |
| 69 | + |
| 70 | +impl_benchmark_test_suite!( |
| 71 | + BridgeInboundChannel, |
| 72 | + crate::inbound::test::new_tester(), |
| 73 | + crate::inbound::test::Test, |
| 74 | +); |
0 commit comments