Run cargo fmt on the whole code base (#9394)

* Run cargo fmt on the whole code base

* Second run

* Add CI check

* Fix compilation

* More unnecessary braces

* Handle weights

* Use --all

* Use correct attributes...

* Fix UI tests

* AHHHHHHHHH

* 🤦

* Docs

* Fix compilation

* 🤷

* Please stop

* 🤦 x 2

* More

* make rustfmt.toml consistent with polkadot

Co-authored-by: André Silva <andrerfosilva@gmail.com>
This commit is contained in:
Bastian Köcher
2021-07-21 16:32:32 +02:00
committed by GitHub
parent d451c38c1c
commit 7b56ab15b4
1010 changed files with 53339 additions and 51208 deletions
+127 -322
View File
@@ -24,19 +24,19 @@ mod code_cache;
mod prepare;
mod runtime;
use crate::{
CodeHash, Schedule, Config,
wasm::env_def::FunctionImplProvider,
exec::{Ext, Executable, ExportedFunction, ExecResult},
gas::GasMeter,
};
use sp_std::prelude::*;
use sp_core::crypto::UncheckedFrom;
use codec::{Encode, Decode};
use frame_support::dispatch::DispatchError;
pub use self::runtime::{ReturnCode, Runtime, RuntimeCosts};
#[cfg(feature = "runtime-benchmarks")]
pub use self::code_cache::reinstrument;
pub use self::runtime::{ReturnCode, Runtime, RuntimeCosts};
use crate::{
exec::{ExecResult, Executable, ExportedFunction, Ext},
gas::GasMeter,
wasm::env_def::FunctionImplProvider,
CodeHash, Config, Schedule,
};
use codec::{Decode, Encode};
use frame_support::dispatch::DispatchError;
use sp_core::crypto::UncheckedFrom;
use sp_std::prelude::*;
#[cfg(test)]
pub use tests::MockExt;
@@ -108,12 +108,12 @@ impl ExportedFunction {
impl<T: Config> PrefabWasmModule<T>
where
T::AccountId: UncheckedFrom<T::Hash> + AsRef<[u8]>
T::AccountId: UncheckedFrom<T::Hash> + AsRef<[u8]>,
{
/// Create the module by checking and instrumenting `original_code`.
pub fn from_code(
original_code: Vec<u8>,
schedule: &Schedule<T>
schedule: &Schedule<T>,
) -> Result<Self, DispatchError> {
prepare::prepare_contract(original_code, schedule).map_err(Into::into)
}
@@ -127,7 +127,7 @@ where
#[cfg(feature = "runtime-benchmarks")]
pub fn store_code_unchecked(
original_code: Vec<u8>,
schedule: &Schedule<T>
schedule: &Schedule<T>,
) -> Result<(), DispatchError> {
let executable = prepare::benchmarking::prepare_contract(original_code, schedule)
.map_err::<DispatchError, _>(Into::into)?;
@@ -150,7 +150,7 @@ where
impl<T: Config> Executable<T> for PrefabWasmModule<T>
where
T::AccountId: UncheckedFrom<T::Hash> + AsRef<[u8]>
T::AccountId: UncheckedFrom<T::Hash> + AsRef<[u8]>,
{
fn from_storage(
code_hash: CodeHash<T>,
@@ -168,15 +168,14 @@ where
code_cache::store_decremented(self);
}
fn add_user(code_hash: CodeHash<T>, gas_meter: &mut GasMeter<T>)
-> Result<(), DispatchError>
{
fn add_user(code_hash: CodeHash<T>, gas_meter: &mut GasMeter<T>) -> Result<(), DispatchError> {
code_cache::increment_refcount::<T>(code_hash, gas_meter)
}
fn remove_user(code_hash: CodeHash<T>, gas_meter: &mut GasMeter<T>)
-> Result<(), DispatchError>
{
fn remove_user(
code_hash: CodeHash<T>,
gas_meter: &mut GasMeter<T>,
) -> Result<(), DispatchError> {
code_cache::decrement_refcount::<T>(code_hash, gas_meter)
}
@@ -187,16 +186,15 @@ where
input_data: Vec<u8>,
) -> ExecResult {
let memory =
sp_sandbox::Memory::new(self.initial, Some(self.maximum))
.unwrap_or_else(|_| {
sp_sandbox::Memory::new(self.initial, Some(self.maximum)).unwrap_or_else(|_| {
// unlike `.expect`, explicit panic preserves the source location.
// Needed as we can't use `RUST_BACKTRACE` in here.
panic!(
"exec.prefab_module.initial can't be greater than exec.prefab_module.maximum;
panic!(
"exec.prefab_module.initial can't be greater than exec.prefab_module.maximum;
thus Memory::new must not fail;
qed"
)
});
)
});
let mut imports = sp_sandbox::EnvironmentDefinitionBuilder::new();
imports.add_memory(self::prepare::IMPORT_MODULE_MEMORY, "memory", memory.clone());
@@ -204,11 +202,7 @@ where
imports.add_host_func(module, name, func_ptr);
});
let mut runtime = Runtime::new(
ext,
input_data,
memory,
);
let mut runtime = Runtime::new(ext, input_data, memory);
// We store before executing so that the code hash is available in the constructor.
let code = self.code.clone();
@@ -245,31 +239,27 @@ where
mod tests {
use super::*;
use crate::{
CodeHash, BalanceOf, Error, Pallet as Contracts,
exec::{
Ext, StorageKey, AccountIdOf, Executable, SeedOf, BlockNumberOf,
RentParams, ExecError, ErrorOrigin,
AccountIdOf, BlockNumberOf, ErrorOrigin, ExecError, Executable, Ext, RentParams,
SeedOf, StorageKey,
},
gas::GasMeter,
rent::RentStatus,
tests::{Test, Call, ALICE, BOB},
tests::{Call, Test, ALICE, BOB},
BalanceOf, CodeHash, Error, Pallet as Contracts,
};
use std::{
borrow::BorrowMut,
cell::RefCell,
collections::HashMap,
};
use sp_core::{Bytes, H256};
use hex_literal::hex;
use sp_runtime::DispatchError;
use assert_matches::assert_matches;
use frame_support::{
assert_ok,
dispatch::{DispatchResult, DispatchResultWithPostInfo},
weights::Weight,
};
use assert_matches::assert_matches;
use hex_literal::hex;
use pallet_contracts_primitives::{ExecReturnValue, ReturnFlags};
use pretty_assertions::assert_eq;
use sp_core::{Bytes, H256};
use sp_runtime::DispatchError;
use std::{borrow::BorrowMut, cell::RefCell, collections::HashMap};
#[derive(Debug, PartialEq, Eq)]
struct RestoreEntry {
@@ -360,12 +350,7 @@ mod tests {
data: Vec<u8>,
allows_reentry: bool,
) -> Result<ExecReturnValue, ExecError> {
self.calls.push(CallEntry {
to,
value,
data,
allows_reentry,
});
self.calls.push(CallEntry { to, value, data, allows_reentry });
Ok(ExecReturnValue { flags: ReturnFlags::empty(), data: call_return_data() })
}
fn instantiate(
@@ -385,30 +370,15 @@ mod tests {
});
Ok((
Contracts::<Test>::contract_address(&ALICE, &code_hash, salt),
ExecReturnValue {
flags: ReturnFlags::empty(),
data: Bytes(Vec::new()),
},
ExecReturnValue { flags: ReturnFlags::empty(), data: Bytes(Vec::new()) },
))
}
fn transfer(
&mut self,
to: &AccountIdOf<Self::T>,
value: u64,
) -> Result<(), DispatchError> {
self.transfers.push(TransferEntry {
to: to.clone(),
value,
});
fn transfer(&mut self, to: &AccountIdOf<Self::T>, value: u64) -> Result<(), DispatchError> {
self.transfers.push(TransferEntry { to: to.clone(), value });
Ok(())
}
fn terminate(
&mut self,
beneficiary: &AccountIdOf<Self::T>,
) -> Result<(), DispatchError> {
self.terminations.push(TerminationEntry {
beneficiary: beneficiary.clone(),
});
fn terminate(&mut self, beneficiary: &AccountIdOf<Self::T>) -> Result<(), DispatchError> {
self.terminations.push(TerminationEntry { beneficiary: beneficiary.clone() });
Ok(())
}
fn restore_to(
@@ -418,12 +388,7 @@ mod tests {
rent_allowance: u64,
delta: Vec<StorageKey>,
) -> Result<(), DispatchError> {
self.restores.push(RestoreEntry {
dest,
code_hash,
rent_allowance,
delta,
});
self.restores.push(RestoreEntry { dest, code_hash, rent_allowance, delta });
Ok(())
}
fn get_storage(&mut self, key: &StorageKey) -> Option<Vec<u8>> {
@@ -466,8 +431,12 @@ mod tests {
fn rent_allowance(&mut self) -> u64 {
self.rent_allowance
}
fn block_number(&self) -> u64 { 121 }
fn max_value_size(&self) -> u32 { 16_384 }
fn block_number(&self) -> u64 {
121
}
fn max_value_size(&self) -> u32 {
16_384
}
fn get_weight_price(&self, weight: Weight) -> BalanceOf<Self::T> {
BalanceOf::<Self::T>::from(1312_u32).saturating_mul(weight.into())
}
@@ -493,16 +462,11 @@ mod tests {
}
}
fn execute<E: BorrowMut<MockExt>>(
wat: &str,
input_data: Vec<u8>,
mut ext: E,
) -> ExecResult
{
fn execute<E: BorrowMut<MockExt>>(wat: &str, input_data: Vec<u8>, mut ext: E) -> ExecResult {
let wasm = wat::parse_str(wat).unwrap();
let schedule = crate::Schedule::default();
let executable = PrefabWasmModule::<<MockExt as Ext>::T>::from_code(wasm, &schedule)
.unwrap();
let executable =
PrefabWasmModule::<<MockExt as Ext>::T>::from_code(wasm, &schedule).unwrap();
executable.execute(ext.borrow_mut(), &ExportedFunction::Call, input_data)
}
@@ -543,19 +507,9 @@ mod tests {
#[test]
fn contract_transfer() {
let mut mock_ext = MockExt::default();
assert_ok!(execute(
CODE_TRANSFER,
vec![],
&mut mock_ext,
));
assert_ok!(execute(CODE_TRANSFER, vec![], &mut mock_ext,));
assert_eq!(
&mock_ext.transfers,
&[TransferEntry {
to: ALICE,
value: 153,
}]
);
assert_eq!(&mock_ext.transfers, &[TransferEntry { to: ALICE, value: 153 }]);
}
const CODE_CALL: &str = r#"
@@ -607,20 +561,11 @@ mod tests {
#[test]
fn contract_call() {
let mut mock_ext = MockExt::default();
assert_ok!(execute(
CODE_CALL,
vec![],
&mut mock_ext,
));
assert_ok!(execute(CODE_CALL, vec![], &mut mock_ext,));
assert_eq!(
&mock_ext.calls,
&[CallEntry {
to: ALICE,
value: 6,
data: vec![1, 2, 3, 4],
allows_reentry: true,
}]
&[CallEntry { to: ALICE, value: 6, data: vec![1, 2, 3, 4], allows_reentry: true }]
);
}
@@ -675,12 +620,7 @@ mod tests {
assert_eq!(
&mock_ext.calls,
&[CallEntry {
to: ALICE,
value: 0x2a,
data: input,
allows_reentry: false,
}]
&[CallEntry { to: ALICE, value: 0x2a, data: input, allows_reentry: false }]
);
}
@@ -736,12 +676,7 @@ mod tests {
assert_eq!(result.data.0, input);
assert_eq!(
&mock_ext.calls,
&[CallEntry {
to: ALICE,
value: 0x2a,
data: input,
allows_reentry: true,
}]
&[CallEntry { to: ALICE, value: 0x2a, data: input, allows_reentry: true }]
);
}
@@ -789,12 +724,7 @@ mod tests {
assert_eq!(result.data, call_return_data());
assert_eq!(
&mock_ext.calls,
&[CallEntry {
to: ALICE,
value: 0x2a,
data: input,
allows_reentry: false,
}]
&[CallEntry { to: ALICE, value: 0x2a, data: input, allows_reentry: false }]
);
}
@@ -857,11 +787,7 @@ mod tests {
#[test]
fn contract_instantiate() {
let mut mock_ext = MockExt::default();
assert_ok!(execute(
CODE_INSTANTIATE,
vec![],
&mut mock_ext,
));
assert_ok!(execute(CODE_INSTANTIATE, vec![], &mut mock_ext,));
assert_matches!(
&mock_ext.instantiates[..],
@@ -905,18 +831,9 @@ mod tests {
#[test]
fn contract_terminate() {
let mut mock_ext = MockExt::default();
execute(
CODE_TERMINATE,
vec![],
&mut mock_ext,
).unwrap();
execute(CODE_TERMINATE, vec![], &mut mock_ext).unwrap();
assert_eq!(
&mock_ext.terminations,
&[TerminationEntry {
beneficiary: ALICE,
}]
);
assert_eq!(&mock_ext.terminations, &[TerminationEntry { beneficiary: ALICE }]);
}
const CODE_TRANSFER_LIMITED_GAS: &str = r#"
@@ -967,20 +884,11 @@ mod tests {
#[test]
fn contract_call_limited_gas() {
let mut mock_ext = MockExt::default();
assert_ok!(execute(
&CODE_TRANSFER_LIMITED_GAS,
vec![],
&mut mock_ext,
));
assert_ok!(execute(&CODE_TRANSFER_LIMITED_GAS, vec![], &mut mock_ext,));
assert_eq!(
&mock_ext.calls,
&[CallEntry {
to: ALICE,
value: 6,
data: vec![1, 2, 3, 4],
allows_reentry: true,
}]
&[CallEntry { to: ALICE, value: 6, data: vec![1, 2, 3, 4], allows_reentry: true }]
);
}
@@ -1051,20 +959,14 @@ mod tests {
#[test]
fn get_storage_puts_data_into_buf() {
let mut mock_ext = MockExt::default();
mock_ext
.storage
.insert([0x11; 32], [0x22; 32].to_vec());
mock_ext.storage.insert([0x11; 32], [0x22; 32].to_vec());
let output = execute(
CODE_GET_STORAGE,
vec![],
mock_ext,
).unwrap();
let output = execute(CODE_GET_STORAGE, vec![], mock_ext).unwrap();
assert_eq!(output, ExecReturnValue {
flags: ReturnFlags::empty(),
data: Bytes([0x22; 32].to_vec())
});
assert_eq!(
output,
ExecReturnValue { flags: ReturnFlags::empty(), data: Bytes([0x22; 32].to_vec()) }
);
}
/// calls `seal_caller` and compares the result with the constant 42.
@@ -1112,11 +1014,7 @@ mod tests {
#[test]
fn caller() {
assert_ok!(execute(
CODE_CALLER,
vec![],
MockExt::default(),
));
assert_ok!(execute(CODE_CALLER, vec![], MockExt::default(),));
}
/// calls `seal_address` and compares the result with the constant 69.
@@ -1164,11 +1062,7 @@ mod tests {
#[test]
fn address() {
assert_ok!(execute(
CODE_ADDRESS,
vec![],
MockExt::default(),
));
assert_ok!(execute(CODE_ADDRESS, vec![], MockExt::default(),));
}
const CODE_BALANCE: &str = r#"
@@ -1214,11 +1108,7 @@ mod tests {
#[test]
fn balance() {
assert_ok!(execute(
CODE_BALANCE,
vec![],
MockExt::default(),
));
assert_ok!(execute(CODE_BALANCE, vec![], MockExt::default(),));
}
const CODE_GAS_PRICE: &str = r#"
@@ -1264,11 +1154,7 @@ mod tests {
#[test]
fn gas_price() {
assert_ok!(execute(
CODE_GAS_PRICE,
vec![],
MockExt::default(),
));
assert_ok!(execute(CODE_GAS_PRICE, vec![], MockExt::default(),));
}
const CODE_GAS_LEFT: &str = r#"
@@ -1315,11 +1201,7 @@ mod tests {
let mut ext = MockExt::default();
let gas_limit = ext.gas_meter.gas_left();
let output = execute(
CODE_GAS_LEFT,
vec![],
&mut ext,
).unwrap();
let output = execute(CODE_GAS_LEFT, vec![], &mut ext).unwrap();
let gas_left = Weight::decode(&mut &*output.data).unwrap();
let actual_left = ext.gas_meter.gas_left();
@@ -1370,11 +1252,7 @@ mod tests {
#[test]
fn value_transferred() {
assert_ok!(execute(
CODE_VALUE_TRANSFERRED,
vec![],
MockExt::default(),
));
assert_ok!(execute(CODE_VALUE_TRANSFERRED, vec![], MockExt::default(),));
}
const CODE_RETURN_FROM_START_FN: &str = r#"
@@ -1403,18 +1281,11 @@ mod tests {
#[test]
fn return_from_start_fn() {
let output = execute(
CODE_RETURN_FROM_START_FN,
vec![],
MockExt::default(),
).unwrap();
let output = execute(CODE_RETURN_FROM_START_FN, vec![], MockExt::default()).unwrap();
assert_eq!(
output,
ExecReturnValue {
flags: ReturnFlags::empty(),
data: Bytes(vec![1, 2, 3, 4])
}
ExecReturnValue { flags: ReturnFlags::empty(), data: Bytes(vec![1, 2, 3, 4]) }
);
}
@@ -1461,11 +1332,7 @@ mod tests {
#[test]
fn now() {
assert_ok!(execute(
CODE_TIMESTAMP_NOW,
vec![],
MockExt::default(),
));
assert_ok!(execute(CODE_TIMESTAMP_NOW, vec![], MockExt::default(),));
}
const CODE_MINIMUM_BALANCE: &str = r#"
@@ -1510,11 +1377,7 @@ mod tests {
#[test]
fn minimum_balance() {
assert_ok!(execute(
CODE_MINIMUM_BALANCE,
vec![],
MockExt::default(),
));
assert_ok!(execute(CODE_MINIMUM_BALANCE, vec![], MockExt::default(),));
}
const CODE_TOMBSTONE_DEPOSIT: &str = r#"
@@ -1559,11 +1422,7 @@ mod tests {
#[test]
fn tombstone_deposit() {
assert_ok!(execute(
CODE_TOMBSTONE_DEPOSIT,
vec![],
MockExt::default(),
));
assert_ok!(execute(CODE_TOMBSTONE_DEPOSIT, vec![], MockExt::default(),));
}
const CODE_RANDOM: &str = r#"
@@ -1622,11 +1481,7 @@ mod tests {
#[test]
fn random() {
let output = execute(
CODE_RANDOM,
vec![],
MockExt::default(),
).unwrap();
let output = execute(CODE_RANDOM, vec![], MockExt::default()).unwrap();
// The mock ext just returns the same data that was passed as the subject.
assert_eq!(
@@ -1697,26 +1552,24 @@ mod tests {
#[test]
fn random_v1() {
let output = execute(
CODE_RANDOM_V1,
vec![],
MockExt::default(),
).unwrap();
let output = execute(CODE_RANDOM_V1, vec![], MockExt::default()).unwrap();
// The mock ext just returns the same data that was passed as the subject.
assert_eq!(
output,
ExecReturnValue {
flags: ReturnFlags::empty(),
data: Bytes((
data: Bytes(
(
hex!("000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F"),
42u64,
).encode()),
)
.encode()
),
},
);
}
const CODE_DEPOSIT_EVENT: &str = r#"
(module
(import "seal0" "seal_deposit_event" (func $seal_deposit_event (param i32 i32 i32 i32)))
@@ -1743,16 +1596,15 @@ mod tests {
#[test]
fn deposit_event() {
let mut mock_ext = MockExt::default();
assert_ok!(execute(
CODE_DEPOSIT_EVENT,
vec![],
&mut mock_ext,
));
assert_ok!(execute(CODE_DEPOSIT_EVENT, vec![], &mut mock_ext,));
assert_eq!(mock_ext.events, vec![
(vec![H256::repeat_byte(0x33)],
vec![0x00, 0x01, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe5, 0x14, 0x00])
]);
assert_eq!(
mock_ext.events,
vec![(
vec![H256::repeat_byte(0x33)],
vec![0x00, 0x01, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe5, 0x14, 0x00]
)]
);
assert!(mock_ext.gas_meter.gas_left() > 0);
}
@@ -1788,11 +1640,7 @@ mod tests {
#[test]
fn deposit_event_max_topics() {
assert_eq!(
execute(
CODE_DEPOSIT_EVENT_MAX_TOPICS,
vec![],
MockExt::default(),
),
execute(CODE_DEPOSIT_EVENT_MAX_TOPICS, vec![], MockExt::default(),),
Err(ExecError {
error: Error::<Test>::TooManyTopics.into(),
origin: ErrorOrigin::Caller,
@@ -1830,11 +1678,7 @@ mod tests {
#[test]
fn deposit_event_duplicates() {
assert_eq!(
execute(
CODE_DEPOSIT_EVENT_DUPLICATES,
vec![],
MockExt::default(),
),
execute(CODE_DEPOSIT_EVENT_DUPLICATES, vec![], MockExt::default(),),
Err(ExecError {
error: Error::<Test>::DuplicateTopics.into(),
origin: ErrorOrigin::Caller,
@@ -1887,11 +1731,7 @@ mod tests {
#[test]
fn block_number() {
let _ = execute(
CODE_BLOCK_NUMBER,
vec![],
MockExt::default(),
).unwrap();
let _ = execute(CODE_BLOCK_NUMBER, vec![], MockExt::default()).unwrap();
}
const CODE_RETURN_WITH_DATA: &str = r#"
@@ -1932,27 +1772,32 @@ mod tests {
CODE_RETURN_WITH_DATA,
hex!("00000000445566778899").to_vec(),
MockExt::default(),
).unwrap();
)
.unwrap();
assert_eq!(output, ExecReturnValue {
flags: ReturnFlags::empty(),
data: Bytes(hex!("445566778899").to_vec()),
});
assert_eq!(
output,
ExecReturnValue {
flags: ReturnFlags::empty(),
data: Bytes(hex!("445566778899").to_vec()),
}
);
assert!(output.is_success());
}
#[test]
fn return_with_revert_status() {
let output = execute(
CODE_RETURN_WITH_DATA,
hex!("010000005566778899").to_vec(),
MockExt::default(),
).unwrap();
let output =
execute(CODE_RETURN_WITH_DATA, hex!("010000005566778899").to_vec(), MockExt::default())
.unwrap();
assert_eq!(output, ExecReturnValue {
flags: ReturnFlags::REVERT,
data: Bytes(hex!("5566778899").to_vec()),
});
assert_eq!(
output,
ExecReturnValue {
flags: ReturnFlags::REVERT,
data: Bytes(hex!("5566778899").to_vec()),
}
);
assert!(!output.is_success());
}
@@ -1975,11 +1820,7 @@ mod tests {
#[test]
fn contract_out_of_bounds_access() {
let mut mock_ext = MockExt::default();
let result = execute(
CODE_OUT_OF_BOUNDS_ACCESS,
vec![],
&mut mock_ext,
);
let result = execute(CODE_OUT_OF_BOUNDS_ACCESS, vec![], &mut mock_ext);
assert_eq!(
result,
@@ -2009,11 +1850,7 @@ mod tests {
#[test]
fn contract_decode_length_ignored() {
let mut mock_ext = MockExt::default();
let result = execute(
CODE_DECODE_FAILURE,
vec![],
&mut mock_ext,
);
let result = execute(CODE_DECODE_FAILURE, vec![], &mut mock_ext);
// AccountID implements `MaxEncodeLen` and therefore the supplied length is
// no longer needed nor used to determine how much is read from contract memory.
assert_ok!(result);
@@ -2051,17 +1888,11 @@ mod tests {
(func (export "deploy"))
)
"#;
let output = execute(
CODE_RENT_PARAMS,
vec![],
MockExt::default(),
).unwrap();
let output = execute(CODE_RENT_PARAMS, vec![], MockExt::default()).unwrap();
let rent_params = Bytes(<RentParams<Test>>::default().encode());
assert_eq!(output, ExecReturnValue { flags: ReturnFlags::empty(), data: rent_params });
}
#[test]
#[cfg(feature = "unstable-interface")]
fn rent_status_works() {
@@ -2095,11 +1926,7 @@ mod tests {
(func (export "deploy"))
)
"#;
let output = execute(
CODE_RENT_STATUS,
vec![],
MockExt::default(),
).unwrap();
let output = execute(CODE_RENT_STATUS, vec![], MockExt::default()).unwrap();
let rent_status = Bytes(<RentStatus<Test>>::default().encode());
assert_eq!(output, ExecReturnValue { flags: ReturnFlags::empty(), data: rent_status });
}
@@ -2126,11 +1953,7 @@ mod tests {
)
"#;
let mut ext = MockExt::default();
execute(
CODE_DEBUG_MESSAGE,
vec![],
&mut ext,
).unwrap();
execute(CODE_DEBUG_MESSAGE, vec![], &mut ext).unwrap();
assert_eq!(std::str::from_utf8(&ext.debug_buffer).unwrap(), "Hello World!");
}
@@ -2157,11 +1980,7 @@ mod tests {
)
"#;
let mut ext = MockExt::default();
let result = execute(
CODE_DEBUG_MESSAGE_FAIL,
vec![],
&mut ext,
);
let result = execute(CODE_DEBUG_MESSAGE_FAIL, vec![], &mut ext);
assert_eq!(
result,
Err(ExecError {
@@ -2213,15 +2032,8 @@ mod tests {
use std::convert::TryInto;
let call = Call::System(frame_system::Call::remark(b"Hello World".to_vec()));
let mut ext = MockExt::default();
let result = execute(
CODE_CALL_RUNTIME,
call.encode(),
&mut ext,
).unwrap();
assert_eq!(
*ext.runtime_calls.borrow(),
vec![call],
);
let result = execute(CODE_CALL_RUNTIME, call.encode(), &mut ext).unwrap();
assert_eq!(*ext.runtime_calls.borrow(), vec![call],);
// 0 = ReturnCode::Success
assert_eq!(u32::from_le_bytes(result.data.0.try_into().unwrap()), 0);
}
@@ -2230,11 +2042,7 @@ mod tests {
#[cfg(feature = "unstable-interface")]
fn call_runtime_panics_on_invalid_call() {
let mut ext = MockExt::default();
let result = execute(
CODE_CALL_RUNTIME,
vec![0x42],
&mut ext,
);
let result = execute(CODE_CALL_RUNTIME, vec![0x42], &mut ext);
assert_eq!(
result,
Err(ExecError {
@@ -2242,9 +2050,6 @@ mod tests {
origin: ErrorOrigin::Caller,
})
);
assert_eq!(
*ext.runtime_calls.borrow(),
vec![],
);
assert_eq!(*ext.runtime_calls.borrow(), vec![],);
}
}