Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/node/cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ pub fn testnet_genesis(

GenesisConfig {
frame_system: Some(SystemConfig {
code: WASM_BINARY.to_vec(),
code: WASM_BINARY.expect("Testing wasm binary not available").to_vec(),
changes_trie_config: Default::default(),
}),
pallet_balances: Some(BalancesConfig {
Expand Down
38 changes: 19 additions & 19 deletions bin/node/executor/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use self::common::{*, sign};
/// 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.
pub const BLOATY_CODE: &[u8] = node_runtime::WASM_BINARY_BLOATY;
pub const BLOATY_CODE: Option<&[u8]> = node_runtime::WASM_BINARY_BLOATY;

/// Default transfer fee. This will use the same logic that is implemented in transaction-payment module.
///
Expand Down Expand Up @@ -75,7 +75,7 @@ fn set_heap_pages<E: Externalities>(ext: &mut E, heap_pages: u64) {

fn changes_trie_block() -> (Vec<u8>, Hash) {
construct_block(
&mut new_test_ext(COMPACT_CODE, true),
&mut new_test_ext(COMPACT_CODE.unwrap(), true),
1,
GENESIS_HASH.into(),
vec![
Expand All @@ -95,7 +95,7 @@ fn changes_trie_block() -> (Vec<u8>, Hash) {
/// are not guaranteed to be deterministic) and to ensure that the correct state is propagated
/// from block1's execution to block2 to derive the correct storage_root.
fn blocks() -> ((Vec<u8>, Hash), (Vec<u8>, Hash)) {
let mut t = new_test_ext(COMPACT_CODE, false);
let mut t = new_test_ext(COMPACT_CODE.unwrap(), false);
let block1 = construct_block(
&mut t,
1,
Expand Down Expand Up @@ -140,7 +140,7 @@ fn blocks() -> ((Vec<u8>, Hash), (Vec<u8>, Hash)) {

fn block_with_size(time: u64, nonce: u32, size: usize) -> (Vec<u8>, Hash) {
construct_block(
&mut new_test_ext(COMPACT_CODE, false),
&mut new_test_ext(COMPACT_CODE.unwrap(), false),
1,
GENESIS_HASH.into(),
vec![
Expand All @@ -158,7 +158,7 @@ fn block_with_size(time: u64, nonce: u32, size: usize) -> (Vec<u8>, Hash) {

#[test]
fn panic_execution_with_foreign_code_gives_error() {
let mut t = new_test_ext(BLOATY_CODE, false);
let mut t = new_test_ext(BLOATY_CODE.unwrap(), false);
t.insert(
<frame_system::Account<Runtime>>::hashed_key_for(alice()),
(69u128, 0u8, 0u128, 0u128, 0u128).encode()
Expand Down Expand Up @@ -187,7 +187,7 @@ fn panic_execution_with_foreign_code_gives_error() {

#[test]
fn bad_extrinsic_with_native_equivalent_code_gives_error() {
let mut t = new_test_ext(COMPACT_CODE, false);
let mut t = new_test_ext(COMPACT_CODE.unwrap(), false);
t.insert(
<frame_system::Account<Runtime>>::hashed_key_for(alice()),
(0u32, 0u8, 69u128, 0u128, 0u128, 0u128).encode()
Expand Down Expand Up @@ -216,7 +216,7 @@ fn bad_extrinsic_with_native_equivalent_code_gives_error() {

#[test]
fn successful_execution_with_native_equivalent_code_gives_ok() {
let mut t = new_test_ext(COMPACT_CODE, false);
let mut t = new_test_ext(COMPACT_CODE.unwrap(), false);
t.insert(
<frame_system::Account<Runtime>>::hashed_key_for(alice()),
(0u32, 0u8, 111 * DOLLARS, 0u128, 0u128, 0u128).encode()
Expand Down Expand Up @@ -259,7 +259,7 @@ fn successful_execution_with_native_equivalent_code_gives_ok() {

#[test]
fn successful_execution_with_foreign_code_gives_ok() {
let mut t = new_test_ext(BLOATY_CODE, false);
let mut t = new_test_ext(BLOATY_CODE.unwrap(), false);
t.insert(
<frame_system::Account<Runtime>>::hashed_key_for(alice()),
(0u32, 0u8, 111 * DOLLARS, 0u128, 0u128, 0u128).encode()
Expand Down Expand Up @@ -302,7 +302,7 @@ fn successful_execution_with_foreign_code_gives_ok() {

#[test]
fn full_native_block_import_works() {
let mut t = new_test_ext(COMPACT_CODE, false);
let mut t = new_test_ext(COMPACT_CODE.unwrap(), false);

let (block1, block2) = blocks();

Expand Down Expand Up @@ -439,7 +439,7 @@ fn full_native_block_import_works() {

#[test]
fn full_wasm_block_import_works() {
let mut t = new_test_ext(COMPACT_CODE, false);
let mut t = new_test_ext(COMPACT_CODE.unwrap(), false);

let (block1, block2) = blocks();

Expand Down Expand Up @@ -586,7 +586,7 @@ fn deploying_wasm_contract_should_work() {
);

let b = construct_block(
&mut new_test_ext(COMPACT_CODE, false),
&mut new_test_ext(COMPACT_CODE.unwrap(), false),
1,
GENESIS_HASH.into(),
vec![
Expand Down Expand Up @@ -625,7 +625,7 @@ fn deploying_wasm_contract_should_work() {
]
);

let mut t = new_test_ext(COMPACT_CODE, false);
let mut t = new_test_ext(COMPACT_CODE.unwrap(), false);

executor_call::<NeverNativeValue, fn() -> _>(
&mut t,
Expand All @@ -649,7 +649,7 @@ fn deploying_wasm_contract_should_work() {

#[test]
fn wasm_big_block_import_fails() {
let mut t = new_test_ext(COMPACT_CODE, false);
let mut t = new_test_ext(COMPACT_CODE.unwrap(), false);

set_heap_pages(&mut t.ext(), 4);

Expand All @@ -665,7 +665,7 @@ fn wasm_big_block_import_fails() {

#[test]
fn native_big_block_import_succeeds() {
let mut t = new_test_ext(COMPACT_CODE, false);
let mut t = new_test_ext(COMPACT_CODE.unwrap(), false);

executor_call::<NeverNativeValue, fn() -> _>(
&mut t,
Expand All @@ -678,7 +678,7 @@ fn native_big_block_import_succeeds() {

#[test]
fn native_big_block_import_fails_on_fallback() {
let mut t = new_test_ext(COMPACT_CODE, false);
let mut t = new_test_ext(COMPACT_CODE.unwrap(), false);

assert!(
executor_call::<NeverNativeValue, fn() -> _>(
Expand All @@ -693,7 +693,7 @@ fn native_big_block_import_fails_on_fallback() {

#[test]
fn panic_execution_gives_error() {
let mut t = new_test_ext(BLOATY_CODE, false);
let mut t = new_test_ext(BLOATY_CODE.unwrap(), false);
t.insert(
<frame_system::Account<Runtime>>::hashed_key_for(alice()),
(0u32, 0u8, 0 * DOLLARS, 0u128, 0u128, 0u128).encode()
Expand Down Expand Up @@ -722,7 +722,7 @@ fn panic_execution_gives_error() {

#[test]
fn successful_execution_gives_ok() {
let mut t = new_test_ext(COMPACT_CODE, false);
let mut t = new_test_ext(COMPACT_CODE.unwrap(), false);
t.insert(
<frame_system::Account<Runtime>>::hashed_key_for(alice()),
(0u32, 0u8, 111 * DOLLARS, 0u128, 0u128, 0u128).encode()
Expand Down Expand Up @@ -775,7 +775,7 @@ fn full_native_block_import_works_with_changes_trie() {
let block_data = block1.0;
let block = Block::decode(&mut &block_data[..]).unwrap();

let mut t = new_test_ext(COMPACT_CODE, true);
let mut t = new_test_ext(COMPACT_CODE.unwrap(), true);
executor_call::<NeverNativeValue, fn() -> _>(
&mut t,
"Core_execute_block",
Expand All @@ -791,7 +791,7 @@ fn full_native_block_import_works_with_changes_trie() {
fn full_wasm_block_import_works_with_changes_trie() {
let block1 = changes_trie_block();

let mut t = new_test_ext(COMPACT_CODE, true);
let mut t = new_test_ext(COMPACT_CODE.unwrap(), true);
executor_call::<NeverNativeValue, fn() -> _>(
&mut t,
"Core_execute_block",
Expand Down
2 changes: 1 addition & 1 deletion bin/node/executor/tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl AppCrypto<MultiSigner, MultiSignature> for TestAuthorityId {
/// 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.
pub const COMPACT_CODE: &[u8] = node_runtime::WASM_BINARY;
pub const COMPACT_CODE: Option<&[u8]> = node_runtime::WASM_BINARY;

pub const GENESIS_HASH: [u8; 32] = [69u8; 32];

Expand Down
14 changes: 7 additions & 7 deletions bin/node/executor/tests/fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use self::common::{*, sign};

#[test]
fn fee_multiplier_increases_and_decreases_on_big_weight() {
let mut t = new_test_ext(COMPACT_CODE, false);
let mut t = new_test_ext(COMPACT_CODE.unwrap(), false);

// initial fee multiplier must be one.
let mut prev_multiplier = Multiplier::one();
Expand All @@ -45,7 +45,7 @@ fn fee_multiplier_increases_and_decreases_on_big_weight() {
assert_eq!(TransactionPayment::next_fee_multiplier(), prev_multiplier);
});

let mut tt = new_test_ext(COMPACT_CODE, false);
let mut tt = new_test_ext(COMPACT_CODE.unwrap(), false);

// big one in terms of weight.
let block1 = construct_block(
Expand Down Expand Up @@ -130,7 +130,7 @@ fn transaction_fee_is_correct() {
// - 1 MILLICENTS in substrate node.
// - 1 milli-dot based on current polkadot runtime.
// (this baed on assigning 0.1 CENT to the cheapest tx with `weight = 100`)
let mut t = new_test_ext(COMPACT_CODE, false);
let mut t = new_test_ext(COMPACT_CODE.unwrap(), false);
t.insert(
<frame_system::Account<Runtime>>::hashed_key_for(alice()),
(0u32, 0u8, 100 * DOLLARS, 0 * DOLLARS, 0 * DOLLARS, 0 * DOLLARS).encode()
Expand Down Expand Up @@ -209,9 +209,9 @@ fn block_weight_capacity_report() {
use node_primitives::Index;

// execution ext.
let mut t = new_test_ext(COMPACT_CODE, false);
let mut t = new_test_ext(COMPACT_CODE.unwrap(), false);
// setup ext.
let mut tt = new_test_ext(COMPACT_CODE, false);
let mut tt = new_test_ext(COMPACT_CODE.unwrap(), false);

let factor = 50;
let mut time = 10;
Expand Down Expand Up @@ -276,9 +276,9 @@ fn block_length_capacity_report() {
use node_primitives::Index;

// execution ext.
let mut t = new_test_ext(COMPACT_CODE, false);
let mut t = new_test_ext(COMPACT_CODE.unwrap(), false);
// setup ext.
let mut tt = new_test_ext(COMPACT_CODE, false);
let mut tt = new_test_ext(COMPACT_CODE.unwrap(), false);

let factor = 256 * 1024;
let mut time = 10;
Expand Down
12 changes: 6 additions & 6 deletions bin/node/executor/tests/submit_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use self::common::*;

#[test]
fn should_submit_unsigned_transaction() {
let mut t = new_test_ext(COMPACT_CODE, false);
let mut t = new_test_ext(COMPACT_CODE.unwrap(), false);
let (pool, state) = TestTransactionPoolExt::new();
t.register_extension(TransactionPoolExt::new(pool));

Expand All @@ -67,7 +67,7 @@ const PHRASE: &str = "news slush supreme milk chapter athlete soap sausage put c

#[test]
fn should_submit_signed_transaction() {
let mut t = new_test_ext(COMPACT_CODE, false);
let mut t = new_test_ext(COMPACT_CODE.unwrap(), false);
let (pool, state) = TestTransactionPoolExt::new();
t.register_extension(TransactionPoolExt::new(pool));

Expand All @@ -92,7 +92,7 @@ fn should_submit_signed_transaction() {

#[test]
fn should_submit_signed_twice_from_the_same_account() {
let mut t = new_test_ext(COMPACT_CODE, false);
let mut t = new_test_ext(COMPACT_CODE.unwrap(), false);
let (pool, state) = TestTransactionPoolExt::new();
t.register_extension(TransactionPoolExt::new(pool));

Expand Down Expand Up @@ -136,7 +136,7 @@ fn should_submit_signed_twice_from_the_same_account() {

#[test]
fn should_submit_signed_twice_from_all_accounts() {
let mut t = new_test_ext(COMPACT_CODE, false);
let mut t = new_test_ext(COMPACT_CODE.unwrap(), false);
let (pool, state) = TestTransactionPoolExt::new();
t.register_extension(TransactionPoolExt::new(pool));

Expand Down Expand Up @@ -195,7 +195,7 @@ fn submitted_transaction_should_be_valid() {
use sp_runtime::transaction_validity::{ValidTransaction, TransactionSource};
use sp_runtime::traits::StaticLookup;

let mut t = new_test_ext(COMPACT_CODE, false);
let mut t = new_test_ext(COMPACT_CODE.unwrap(), false);
let (pool, state) = TestTransactionPoolExt::new();
t.register_extension(TransactionPoolExt::new(pool));

Expand All @@ -216,7 +216,7 @@ fn submitted_transaction_should_be_valid() {
// check that transaction is valid, but reset environment storage,
// since CreateTransaction increments the nonce
let tx0 = state.read().transactions[0].clone();
let mut t = new_test_ext(COMPACT_CODE, false);
let mut t = new_test_ext(COMPACT_CODE.unwrap(), false);
t.execute_with(|| {
let source = TransactionSource::External;
let extrinsic = UncheckedExtrinsic::decode(&mut &*tx0).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion bin/node/testing/src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ impl BenchKeyring {
pub fn generate_genesis(&self) -> node_runtime::GenesisConfig {
crate::genesis::config_endowed(
false,
Some(node_runtime::WASM_BINARY),
Some(node_runtime::WASM_BINARY.expect("Wasm binary must be built for testing")),
self.collect_account_ids(),
)
}
Expand Down
2 changes: 1 addition & 1 deletion bin/node/testing/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub fn config_endowed(
digest_interval: 2,
digest_levels: 2,
}) } else { None },
code: code.map(|x| x.to_vec()).unwrap_or_else(|| WASM_BINARY.to_vec()),
code: code.map(|x| x.to_vec()).unwrap_or_else(|| WASM_BINARY.expect("Wasm binary must be built for testing").to_vec()),
}),
pallet_indices: Some(IndicesConfig {
indices: vec![],
Expand Down
14 changes: 7 additions & 7 deletions client/executor/src/integration_tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fn call_in_wasm<E: Externalities>(
8,
);
executor.call_in_wasm(
&WASM_BINARY[..],
&WASM_BINARY.unwrap()[..],
None,
function,
call_data,
Expand Down Expand Up @@ -533,7 +533,7 @@ fn should_trap_when_heap_exhausted(wasm_method: WasmExecutionMethod) {
8,
);
executor.call_in_wasm(
&WASM_BINARY[..],
&WASM_BINARY.unwrap()[..],
None,
"test_exhaust_heap",
&[0],
Expand All @@ -548,7 +548,7 @@ fn returns_mutable_static(wasm_method: WasmExecutionMethod) {
let runtime = crate::wasm_runtime::create_wasm_runtime_with_code(
wasm_method,
1024,
&WASM_BINARY[..],
&WASM_BINARY.unwrap()[..],
HostFunctions::host_functions(),
true,
).expect("Creates runtime");
Expand Down Expand Up @@ -582,7 +582,7 @@ fn restoration_of_globals(wasm_method: WasmExecutionMethod) {
let runtime = crate::wasm_runtime::create_wasm_runtime_with_code(
wasm_method,
REQUIRED_MEMORY_PAGES,
&WASM_BINARY[..],
&WASM_BINARY.unwrap()[..],
HostFunctions::host_functions(),
true,
).expect("Creates runtime");
Expand All @@ -602,7 +602,7 @@ fn heap_is_reset_between_calls(wasm_method: WasmExecutionMethod) {
let runtime = crate::wasm_runtime::create_wasm_runtime_with_code(
wasm_method,
1024,
&WASM_BINARY[..],
&WASM_BINARY.unwrap()[..],
HostFunctions::host_functions(),
true,
).expect("Creates runtime");
Expand Down Expand Up @@ -630,7 +630,7 @@ fn parallel_execution(wasm_method: WasmExecutionMethod) {
HostFunctions::host_functions(),
8,
));
let code_hash = blake2_256(WASM_BINARY).to_vec();
let code_hash = blake2_256(WASM_BINARY.unwrap()).to_vec();
let threads: Vec<_> = (0..8).map(|_|
{
let executor = executor.clone();
Expand All @@ -640,7 +640,7 @@ fn parallel_execution(wasm_method: WasmExecutionMethod) {
let mut ext = ext.ext();
assert_eq!(
executor.call_in_wasm(
&WASM_BINARY[..],
&WASM_BINARY.unwrap()[..],
Some(code_hash.clone()),
"test_twox_128",
&[0],
Expand Down
2 changes: 1 addition & 1 deletion client/executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ mod tests {
8,
);
let res = executor.call_in_wasm(
&WASM_BINARY[..],
&WASM_BINARY.unwrap()[..],
None,
"test_empty_return",
&[],
Expand Down
Loading