mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-08-04 10:55:41 +00:00
Contracts: Refactor test builder (#4158)
- Moved `substrate/frame/contracts/src/tests/builder.rs` into a pub test_utils module, so we can use that in the `pallet-contracts-mock-network` tests - Refactor xcm tests to use XCM builders, and simplify the use case for xcm-send
This commit is contained in:
@@ -15,7 +15,6 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
mod builder;
|
||||
mod pallet_dummy;
|
||||
mod test_debug;
|
||||
|
||||
@@ -98,7 +97,6 @@ macro_rules! assert_refcount {
|
||||
}
|
||||
|
||||
pub mod test_utils {
|
||||
|
||||
use super::{Contracts, DepositPerByte, DepositPerItem, Hash, SysConfig, Test};
|
||||
use crate::{
|
||||
exec::AccountIdOf, BalanceOf, CodeHash, CodeInfo, CodeInfoOf, Config, ContractInfo,
|
||||
@@ -166,6 +164,38 @@ pub mod test_utils {
|
||||
}
|
||||
}
|
||||
|
||||
mod builder {
|
||||
use super::Test;
|
||||
use crate::{
|
||||
test_utils::{builder::*, AccountId32, ALICE},
|
||||
tests::RuntimeOrigin,
|
||||
AccountIdLookupOf, Code, CodeHash,
|
||||
};
|
||||
|
||||
pub fn bare_instantiate(code: Code<CodeHash<Test>>) -> BareInstantiateBuilder<Test> {
|
||||
BareInstantiateBuilder::<Test>::bare_instantiate(ALICE, code)
|
||||
}
|
||||
|
||||
pub fn bare_call(dest: AccountId32) -> BareCallBuilder<Test> {
|
||||
BareCallBuilder::<Test>::bare_call(ALICE, dest)
|
||||
}
|
||||
|
||||
pub fn instantiate_with_code(code: Vec<u8>) -> InstantiateWithCodeBuilder<Test> {
|
||||
InstantiateWithCodeBuilder::<Test>::instantiate_with_code(
|
||||
RuntimeOrigin::signed(ALICE),
|
||||
code,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn instantiate(code_hash: CodeHash<Test>) -> InstantiateBuilder<Test> {
|
||||
InstantiateBuilder::<Test>::instantiate(RuntimeOrigin::signed(ALICE), code_hash)
|
||||
}
|
||||
|
||||
pub fn call(dest: AccountIdLookupOf<Test>) -> CallBuilder<Test> {
|
||||
CallBuilder::<Test>::call(RuntimeOrigin::signed(ALICE), dest)
|
||||
}
|
||||
}
|
||||
|
||||
impl Test {
|
||||
pub fn set_unstable_interface(unstable_interface: bool) {
|
||||
UNSTABLE_INTERFACE.with(|v| *v.borrow_mut() = unstable_interface);
|
||||
@@ -2439,14 +2469,7 @@ fn failed_deposit_charge_should_roll_back_call() {
|
||||
transfer_proxy_call,
|
||||
);
|
||||
|
||||
<Pallet<Test>>::call(
|
||||
RuntimeOrigin::signed(ALICE),
|
||||
addr_caller.clone(),
|
||||
0,
|
||||
GAS_LIMIT,
|
||||
None,
|
||||
data.encode(),
|
||||
)
|
||||
builder::call(addr_caller).data(data.encode()).build()
|
||||
})
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user