Contracts: revert reverted changes from 4266 (#4277)

revert some reverted changes from #4266
This commit is contained in:
PG Herveou
2024-04-30 16:29:14 +02:00
committed by GitHub
parent b8593ccd1b
commit c973fe86f8
4 changed files with 9 additions and 66 deletions
@@ -14,8 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
use super::{Balances, Runtime, RuntimeCall, RuntimeEvent, RuntimeHoldReason};
use frame_support::{derive_impl, parameter_types, traits::Contains};
use super::{Balances, Runtime, RuntimeCall, RuntimeEvent};
use crate::parachain::RuntimeHoldReason;
use frame_support::{derive_impl, parameter_types};
parameter_types! {
pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();
@@ -28,14 +29,5 @@ impl pallet_contracts::Config for Runtime {
type Currency = Balances;
type Schedule = Schedule;
type Time = super::Timestamp;
type CallFilter = CallFilter;
type Xcm = pallet_xcm::Pallet<Self>;
}
/// In this mock, we only allow other contract calls via XCM.
pub struct CallFilter;
impl Contains<RuntimeCall> for CallFilter {
fn contains(call: &RuntimeCall) -> bool {
matches!(call, RuntimeCall::Contracts(pallet_contracts::Call::call { .. }))
}
}
@@ -22,10 +22,7 @@ use crate::{
relay_chain, MockNet, ParaA, ParachainBalances, Relay, ALICE, BOB, INITIAL_BALANCE,
};
use codec::{Decode, Encode};
use frame_support::{
assert_err,
traits::{fungibles::Mutate, Currency},
};
use frame_support::traits::{fungibles::Mutate, Currency};
use pallet_contracts::{test_utils::builder::*, Code};
use pallet_contracts_fixtures::compile_module;
use pallet_contracts_uapi::ReturnErrorCode;
@@ -132,26 +129,6 @@ fn test_xcm_execute_incomplete() {
});
}
#[test]
fn test_xcm_execute_filtered_call() {
MockNet::reset();
let contract_addr = instantiate_test_contract("xcm_execute");
ParaA::execute_with(|| {
// `remark` should be rejected, as it is not allowed by our CallFilter.
let call = parachain::RuntimeCall::System(frame_system::Call::remark { remark: vec![] });
let message: Xcm<parachain::RuntimeCall> = Xcm::builder_unsafe()
.transact(OriginKind::Native, Weight::MAX, call.encode())
.build();
let result = bare_call(contract_addr.clone())
.data(VersionedXcm::V4(message).encode())
.build()
.result;
assert_err!(result, frame_system::Error::<parachain::Runtime>::CallFiltered);
});
}
#[test]
fn test_xcm_execute_reentrant_call() {
MockNet::reset();