1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//! Some functions to use in tests.
use std::collections::BTreeMap;

use engine_wasm_prep::wasm_costs::WasmCosts;
use types::{account::PublicKey, AccessRights, Key, URef};

use crate::{account::Account, stored_value::StoredValue};

/// Returns an account value paired with its key
pub fn mocked_account(public_key: PublicKey) -> Vec<(Key, StoredValue)> {
    let purse = URef::new([0u8; 32], AccessRights::READ_ADD_WRITE);
    let account = Account::create(public_key, BTreeMap::new(), purse);
    vec![(Key::Account(public_key), StoredValue::Account(account))]
}

pub fn wasm_costs_mock() -> WasmCosts {
    WasmCosts {
        regular: 1,
        div: 16,
        mul: 4,
        mem: 2,
        initial_mem: 4096,
        grow_mem: 8192,
        memcpy: 1,
        max_stack_height: 64 * 1024,
        opcodes_mul: 3,
        opcodes_div: 8,
    }
}

pub fn wasm_costs_free() -> WasmCosts {
    WasmCosts {
        regular: 0,
        div: 0,
        mul: 0,
        mem: 0,
        initial_mem: 4096,
        grow_mem: 8192,
        memcpy: 0,
        max_stack_height: 64 * 1024,
        opcodes_mul: 1,
        opcodes_div: 1,
    }
}