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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
use casper_execution_engine::shared::opcode_costs::OpcodeCosts; use crate::engine_server::ipc; impl From<OpcodeCosts> for ipc::ChainSpec_WasmConfig_OpcodeCosts { fn from(opcode_costs: OpcodeCosts) -> Self { ipc::ChainSpec_WasmConfig_OpcodeCosts { bit: opcode_costs.bit, add: opcode_costs.add, mul: opcode_costs.mul, div: opcode_costs.div, load: opcode_costs.load, store: opcode_costs.store, field_const: opcode_costs.op_const, local: opcode_costs.local, global: opcode_costs.global, control_flow: opcode_costs.control_flow, integer_comparsion: opcode_costs.integer_comparsion, conversion: opcode_costs.conversion, unreachable: opcode_costs.unreachable, nop: opcode_costs.nop, current_memory: opcode_costs.current_memory, grow_memory: opcode_costs.grow_memory, regular: opcode_costs.regular, ..Default::default() } } } impl From<ipc::ChainSpec_WasmConfig_OpcodeCosts> for OpcodeCosts { fn from(pb_opcode_costs: ipc::ChainSpec_WasmConfig_OpcodeCosts) -> Self { OpcodeCosts { bit: pb_opcode_costs.bit, add: pb_opcode_costs.add, mul: pb_opcode_costs.mul, div: pb_opcode_costs.div, load: pb_opcode_costs.load, store: pb_opcode_costs.store, op_const: pb_opcode_costs.field_const, local: pb_opcode_costs.local, global: pb_opcode_costs.global, control_flow: pb_opcode_costs.control_flow, integer_comparsion: pb_opcode_costs.integer_comparsion, conversion: pb_opcode_costs.conversion, unreachable: pb_opcode_costs.unreachable, nop: pb_opcode_costs.nop, current_memory: pb_opcode_costs.current_memory, grow_memory: pb_opcode_costs.grow_memory, regular: pb_opcode_costs.regular, } } } #[cfg(test)] mod tests { use proptest::proptest; use casper_execution_engine::shared::opcode_costs::gens; use super::*; use crate::engine_server::mappings::test_utils; proptest! { #[test] fn round_trip(opcode_costs in gens::opcode_costs_arb()) { test_utils::protobuf_round_trip::<OpcodeCosts, ipc::ChainSpec_WasmConfig_OpcodeCosts>(opcode_costs); } } }