mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 19:17:58 +00:00
Rename: srml-contract → srml-contracts (#2905)
* srml-contract → srml-contracts * Trim. * Bump version
This commit is contained in:
committed by
Bastian Köcher
parent
37acb90847
commit
828485ec08
@@ -27,7 +27,7 @@ staking = { package = "srml-staking", path = "../../srml/staking" }
|
||||
system = { package = "srml-system", path = "../../srml/system" }
|
||||
timestamp = { package = "srml-timestamp", path = "../../srml/timestamp" }
|
||||
treasury = { package = "srml-treasury", path = "../../srml/treasury" }
|
||||
contract = { package = "srml-contract", path = "../../srml/contract" }
|
||||
contracts = { package = "srml-contracts", path = "../../srml/contracts" }
|
||||
grandpa = { package = "srml-grandpa", path = "../../srml/grandpa" }
|
||||
indices = { package = "srml-indices", path = "../../srml/indices" }
|
||||
wabt = "~0.7.4"
|
||||
|
||||
@@ -23,7 +23,17 @@
|
||||
|
||||
pub use substrate_executor::NativeExecutor;
|
||||
use substrate_executor::native_executor_instance;
|
||||
native_executor_instance!(pub Executor, node_runtime::api::dispatch, node_runtime::native_version, include_bytes!("../../runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm"));
|
||||
|
||||
// Declare an instance of the native executor named `Executor`. Include the wasm binary as the
|
||||
// equivalent wasm code.
|
||||
native_executor_instance!(
|
||||
pub Executor,
|
||||
node_runtime::api::dispatch,
|
||||
node_runtime::native_version,
|
||||
include_bytes!(
|
||||
"../../runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm"
|
||||
)
|
||||
);
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
@@ -39,8 +49,8 @@ mod tests {
|
||||
use node_primitives::{Hash, BlockNumber, AccountId};
|
||||
use runtime_primitives::traits::{Header as HeaderT, Hash as HashT};
|
||||
use runtime_primitives::{generic::Era, ApplyOutcome, ApplyError, ApplyResult, Perbill};
|
||||
use {balances, indices, system, staking, timestamp, treasury, contract};
|
||||
use contract::ContractAddressFor;
|
||||
use {balances, indices, system, staking, timestamp, treasury, contracts};
|
||||
use contracts::ContractAddressFor;
|
||||
use system::{EventRecord, Phase};
|
||||
use node_runtime::{Header, Block, UncheckedExtrinsic, CheckedExtrinsic, Call, Runtime, Balances,
|
||||
BuildStorage, GenesisConfig, BalancesConfig, SessionConfig, StakingConfig, System,
|
||||
@@ -48,8 +58,23 @@ mod tests {
|
||||
use wabt;
|
||||
use primitives::map;
|
||||
|
||||
const BLOATY_CODE: &[u8] = include_bytes!("../../runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.wasm");
|
||||
const COMPACT_CODE: &[u8] = include_bytes!("../../runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm");
|
||||
/// The wasm runtime code.
|
||||
///
|
||||
/// `compact` since it is after post-processing with wasm-gc which performs tree-shaking thus
|
||||
/// making the binary slimmer. There is a convention to use compact version of the runtime
|
||||
/// as canonical. This is why `native_executor_instance` also uses the compact version of the
|
||||
/// runtime.
|
||||
const COMPACT_CODE: &[u8] =
|
||||
include_bytes!("../../runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm");
|
||||
|
||||
/// The wasm runtime binary which hasn't undergone the compacting process.
|
||||
///
|
||||
/// The idea here is to pass it as the current runtime code to the executor so the executor will
|
||||
/// have to execute provided wasm code instead of the native equivalent. This trick is used to
|
||||
/// test code paths that differ between native and wasm versions.
|
||||
const BLOATY_CODE: &[u8] =
|
||||
include_bytes!("../../runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.wasm");
|
||||
|
||||
const GENESIS_HASH: [u8; 32] = [69u8; 32];
|
||||
|
||||
type TestExternalities<H> = CoreTestExternalities<H, u64>;
|
||||
@@ -363,7 +388,7 @@ mod tests {
|
||||
council_seats: Some(Default::default()),
|
||||
timestamp: Some(Default::default()),
|
||||
treasury: Some(Default::default()),
|
||||
contract: Some(Default::default()),
|
||||
contracts: Some(Default::default()),
|
||||
sudo: Some(Default::default()),
|
||||
grandpa: Some(GrandpaConfig {
|
||||
_genesis_phantom_data: Default::default(),
|
||||
@@ -751,10 +776,17 @@ mod tests {
|
||||
)
|
||||
;; Destination AccountId to transfer the funds.
|
||||
;; Represented by H256 (32 bytes long) in little endian.
|
||||
(data (i32.const 4) "\09\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00")
|
||||
(data (i32.const 4)
|
||||
"\09\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
|
||||
"\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
|
||||
"\00\00\00\00"
|
||||
)
|
||||
;; Amount of value to transfer.
|
||||
;; Represented by u128 (16 bytes long) in little endian.
|
||||
(data (i32.const 36) "\06\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00")
|
||||
(data (i32.const 36)
|
||||
"\06\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
|
||||
"\00\00"
|
||||
)
|
||||
)
|
||||
"#;
|
||||
|
||||
@@ -764,7 +796,7 @@ mod tests {
|
||||
let transfer_code = wabt::wat2wasm(CODE_TRANSFER).unwrap();
|
||||
let transfer_ch = <Runtime as system::Trait>::Hashing::hash(&transfer_code);
|
||||
|
||||
let addr = <Runtime as contract::Trait>::DetermineContractAddress::contract_address_for(
|
||||
let addr = <Runtime as contracts::Trait>::DetermineContractAddress::contract_address_for(
|
||||
&transfer_ch,
|
||||
&[],
|
||||
&charlie(),
|
||||
@@ -781,20 +813,25 @@ mod tests {
|
||||
},
|
||||
CheckedExtrinsic {
|
||||
signed: Some((charlie(), 0)),
|
||||
function: Call::Contract(
|
||||
contract::Call::put_code::<Runtime>(10_000, transfer_code)
|
||||
function: Call::Contracts(
|
||||
contracts::Call::put_code::<Runtime>(10_000, transfer_code)
|
||||
),
|
||||
},
|
||||
CheckedExtrinsic {
|
||||
signed: Some((charlie(), 1)),
|
||||
function: Call::Contract(
|
||||
contract::Call::create::<Runtime>(10, 10_000, transfer_ch, Vec::new())
|
||||
function: Call::Contracts(
|
||||
contracts::Call::create::<Runtime>(10, 10_000, transfer_ch, Vec::new())
|
||||
),
|
||||
},
|
||||
CheckedExtrinsic {
|
||||
signed: Some((charlie(), 2)),
|
||||
function: Call::Contract(
|
||||
contract::Call::call::<Runtime>(indices::address::Address::Id(addr.clone()), 10, 10_000, vec![0x00, 0x01, 0x02, 0x03])
|
||||
function: Call::Contracts(
|
||||
contracts::Call::call::<Runtime>(
|
||||
indices::address::Address::Id(addr.clone()),
|
||||
10,
|
||||
10_000,
|
||||
vec![0x00, 0x01, 0x02, 0x03]
|
||||
)
|
||||
),
|
||||
},
|
||||
]
|
||||
@@ -807,7 +844,7 @@ mod tests {
|
||||
runtime_io::with_externalities(&mut t, || {
|
||||
// Verify that the contract constructor worked well and code of TRANSFER contract is actually deployed.
|
||||
assert_eq!(
|
||||
&contract::ContractInfoOf::<Runtime>::get(addr)
|
||||
&contracts::ContractInfoOf::<Runtime>::get(addr)
|
||||
.and_then(|c| c.get_alive())
|
||||
.unwrap()
|
||||
.code_hash,
|
||||
@@ -861,8 +898,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn panic_execution_gives_error() {
|
||||
let foreign_code = include_bytes!("../../runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.wasm");
|
||||
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(foreign_code, map![
|
||||
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(BLOATY_CODE, map![
|
||||
blake2_256(&<balances::FreeBalance<Runtime>>::key_for(alice())).to_vec() => {
|
||||
vec![69u8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
},
|
||||
@@ -889,8 +925,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn successful_execution_gives_ok() {
|
||||
let foreign_code = include_bytes!("../../runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm");
|
||||
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(foreign_code, map![
|
||||
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(COMPACT_CODE, map![
|
||||
blake2_256(&<balances::FreeBalance<Runtime>>::key_for(alice())).to_vec() => {
|
||||
vec![111u8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user