Skip to content

Commit

Permalink
Add bytecode
Browse files Browse the repository at this point in the history
  • Loading branch information
fmoletta committed Nov 24, 2023
1 parent b02e7e2 commit 45976d8
Showing 1 changed file with 34 additions and 3 deletions.
37 changes: 34 additions & 3 deletions vm/src/tests/run_deprecated_contract_class_simplified.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::HashMap;

use felt::Felt252;
use num_traits::{One, Zero};
use num_traits::{One, Zero, Num};
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::*;

Expand Down Expand Up @@ -139,6 +139,11 @@ pub fn compile_class(
// Now we can fill each struct field with our hardcoded values
let mut ptr = compiled_class_ptr;
// For this test's purpose we will be using the following cairo 0 contract:
// %lang starknet
// @view
// func get_number() -> (number: felt) {
// return (number=14);
// }

// struct DeprecatedCompiledClass {
// compiled_class_version: felt,
Expand Down Expand Up @@ -202,11 +207,37 @@ pub fn compile_class(
ptr.offset += 1;

// // The length and pointer of the bytecode.
let byte_code = vec![
Felt252::from_str_radix("480680017fff8000", 16).unwrap().into(),
Felt252::from_str_radix("e", 16).unwrap().into(),
Felt252::from_str_radix("208b7fff7fff7ffe", 16).unwrap().into(),
Felt252::from_str_radix("40780017fff7fff", 16).unwrap().into(),
Felt252::from_str_radix("1", 16).unwrap().into(),
Felt252::from_str_radix("4003800080007ffc", 16).unwrap().into(),
Felt252::from_str_radix("4826800180008000", 16).unwrap().into(),
Felt252::from_str_radix("1", 16).unwrap().into(),
Felt252::from_str_radix("480a7ffd7fff8000", 16).unwrap().into(),
Felt252::from_str_radix("4828800080007ffe", 16).unwrap().into(),
Felt252::from_str_radix("480a80007fff8000", 16).unwrap().into(),
Felt252::from_str_radix("208b7fff7fff7ffe", 16).unwrap().into(),
Felt252::from_str_radix("402b7ffd7ffc7ffd", 16).unwrap().into(),
Felt252::from_str_radix("1104800180018000", 16).unwrap().into(),
Felt252::from_str_radix("800000000000010fffffffffffffffffffffffffffffffffffffffffffffff4", 16).unwrap().into(),
Felt252::from_str_radix("480280017ffb8000", 16).unwrap().into(),
Felt252::from_str_radix("1104800180018000", 16).unwrap().into(),
Felt252::from_str_radix("800000000000010fffffffffffffffffffffffffffffffffffffffffffffff4", 16).unwrap().into(),
Felt252::from_str_radix("480280007ffb8000", 16).unwrap().into(),
Felt252::from_str_radix("48127ffc7fff8000", 16).unwrap().into(),
Felt252::from_str_radix("48127ffc7fff8000", 16).unwrap().into(),
Felt252::from_str_radix("48127ffc7fff8000", 16).unwrap().into(),
Felt252::from_str_radix("208b7fff7fff7ffe", 16).unwrap().into(),
];
// bytecode_length: felt,
vm.insert_value(ptr, Felt252::zero())?; // TODO
vm.insert_value(ptr, Felt252::from(byte_code.len()))?;
ptr.offset += 1;
// bytecode_ptr: felt*,
let byte_code_ptr = vm.add_memory_segment(); // TODO
let byte_code_ptr = vm.add_memory_segment();
vm.load_data(byte_code_ptr, &byte_code)?;
vm.insert_value(ptr, byte_code_ptr)?;
//}

Expand Down

0 comments on commit 45976d8

Please sign in to comment.