Skip to content

Commit

Permalink
Add unit tests for ExecutionScopes (keep-starknet-strange#442)
Browse files Browse the repository at this point in the history
* Add unit tests for ExecutionScopes

* solve conflicts

---------

Co-authored-by: lanaivina <[email protected]>
  • Loading branch information
tcoratger and lana-shanghai authored Mar 6, 2024
1 parent 20a5cd1 commit 44ff356
Show file tree
Hide file tree
Showing 4 changed files with 360 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/hint_processor/math_hints.zig
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ pub fn assertLeFeltExcluded0(
vm: *CairoVM,
exec_scopes: *const ExecutionScopes,
) !void {
const excluded = try exec_scopes.getFelt("excluded");
const excluded = try exec_scopes.getValue(.felt,"excluded");

if (!excluded.isZero()) {
try hint_utils.insertValueIntoAp(allocator, vm, MaybeRelocatable.fromFelt(Felt252.one()));
Expand All @@ -325,7 +325,7 @@ pub fn assertLeFeltExcluded1(
vm: *CairoVM,
exec_scopes: *ExecutionScopes,
) !void {
const excluded = try exec_scopes.getFelt("excluded");
const excluded = try exec_scopes.getValue(.felt, "excluded");

if (!excluded.isOne()) {
try hint_utils.insertValueIntoAp(allocator, vm, MaybeRelocatable.fromFelt(Felt252.one()));
Expand All @@ -335,7 +335,7 @@ pub fn assertLeFeltExcluded1(
}

pub fn assertLeFeltExcluded2(exec_scopes: *ExecutionScopes) !void {
const excluded = try exec_scopes.getFelt("excluded");
const excluded = try exec_scopes.getValue(.felt, "excluded");

if (!excluded.equal(Felt252.fromInt(u256, 2))) {
return HintError.ExcludedNot2;
Expand Down
1 change: 1 addition & 0 deletions src/lib.zig
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub const vm = struct {
pub usingnamespace @import("vm/types/diluted_pool_instance_def.zig");
pub usingnamespace @import("vm/types/cpu_instance_def.zig");
pub usingnamespace @import("vm/types/layout.zig");
pub usingnamespace @import("vm/types/execution_scopes.zig");
pub usingnamespace @import("vm/decoding/decoder.zig");
};

Expand Down
5 changes: 5 additions & 0 deletions src/vm/error.zig
Original file line number Diff line number Diff line change
Expand Up @@ -302,3 +302,8 @@ pub const InsufficientAllocatedCellsError = error{
// There are only cells to fill the memory address holes, but are required.
MemoryAddresses,
};

pub const ExecScopeError = error{
ExitMainScopeError,
NoScopeError,
};
Loading

0 comments on commit 44ff356

Please sign in to comment.