Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
StringNick committed Jun 14, 2024
1 parent f82200f commit 61a3967
Show file tree
Hide file tree
Showing 31 changed files with 1,589 additions and 2,813 deletions.
51 changes: 2 additions & 49 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const external_dependencies = [_]build_helpers.Dependency{
// runner.
pub fn build(b: *std.Build) void {
const options = b.addOptions();
options.addOption(bool, "extensive", false);
options.addOption(bool, "extensive", true);

// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
Expand Down Expand Up @@ -91,7 +91,6 @@ pub fn build(b: *std.Build) void {
.link_libc = true,
.omit_frame_pointer = if (optimize == .ReleaseFast) true else false,
.strip = true,
.error_tracing = false,
});
exe.root_module.addOptions("cfg", options);

Expand Down Expand Up @@ -124,14 +123,6 @@ pub fn build(b: *std.Build) void {

integration_test(b, optimize, target, deps);

// This creates a build step. It will be visible in the `zig build --help` menu,
// and can be selected like this: `zig build poseidon_consts_gen`
poseidon_consts_gen(b, optimize, target);

// This creates a build step. It will be visible in the `zig build --help` menu,
// and can be selected like this: `zig build pedersen_table_gen`
pedersen_table_gen(b, optimize, target);

// This creates a build step. It will be visible in the `zig build --help` menu,
// and can be selected like this: `zig build run`
// This will evaluate the `run` step rather than the default, which is "install".
Expand All @@ -154,8 +145,8 @@ pub fn build(b: *std.Build) void {
.target = target,
.optimize = optimize,
.filter = test_filter,
.single_threaded = false,
});
unit_tests.root_module.addOptions("cfg", options);

// Add dependency modules to the tests.
for (deps) |mod| unit_tests.root_module.addImport(
Expand Down Expand Up @@ -203,41 +194,3 @@ fn integration_test(
const install_step = b.addInstallArtifact(binary, .{});
integration_test_build.dependOn(&install_step.step);
}

fn poseidon_consts_gen(
b: *std.Build,
mode: std.builtin.Mode,
target: std.Build.ResolvedTarget,
) void {
const binary = b.addExecutable(.{
.name = "poseidon_consts_gen",
.root_source_file = b.path("src/poseidon_consts_gen.zig"),
.target = target,
.optimize = mode,
});

const poseidon_consts_gen_build = b.step("poseidon_consts_gen", "Cli: poseidon consts generator");
poseidon_consts_gen_build.dependOn(&binary.step);

const install_step = b.addInstallArtifact(binary, .{});
poseidon_consts_gen_build.dependOn(&install_step.step);
}

fn pedersen_table_gen(
b: *std.Build,
mode: std.builtin.Mode,
target: std.Build.ResolvedTarget,
) void {
const binary = b.addExecutable(.{
.name = "pedersen_table_gen",
.root_source_file = b.path("src/pedersen_table_gen.zig"),
.target = target,
.optimize = mode,
});

const pedersen_table_gen_build = b.step("pedersen_table_gen", "Cli: pedersen table generator");
pedersen_table_gen_build.dependOn(&binary.step);

const install_step = b.addInstallArtifact(binary, .{});
pedersen_table_gen_build.dependOn(&install_step.step);
}
2 changes: 1 addition & 1 deletion build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
.starknet = .{
.url = "https://github.com/StringNick/starknet-zig/archive/refs/heads/main.tar.gz",
.hash = "1220e84359c65fe34c4d6c5667fbb57dc19835205910004a890c023844a776b0d0c0",
.hash = "12208598f7b7ccf1229c3fc25cae00f468e789d65d6077549bb1732a3be41990ac66",
},
},
}
1 change: 1 addition & 0 deletions profile.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/hint_processor/felt_bit_length.zig
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ test "FeltBitLength: range test" {
try vm.segments.memory.set(
std.testing.allocator,
Relocatable.init(1, 0),
MaybeRelocatable.fromFelt(Felt252.two().pow(i)),
MaybeRelocatable.fromFelt(Felt252.two().powToInt(@intCast(i))),
);
defer vm.segments.memory.deinitData(std.testing.allocator);

Expand Down Expand Up @@ -171,7 +171,7 @@ test "FeltBitLength: wrap around" {
std.testing.allocator,
Relocatable.init(1, 0),
MaybeRelocatable.fromFelt(
Felt252.fromInt(u256, Felt252.Modulo - 1).add(Felt252.one()),
Felt252.fromInt(u256, Felt252.Modulus.toU256() - 1).add(&Felt252.one()),
),
);
defer vm.segments.memory.deinitData(std.testing.allocator);
Expand Down
8 changes: 4 additions & 4 deletions src/hint_processor/find_element.zig
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ test "Element found by search" {

try expectEqual(
MaybeRelocatable.fromInt(u8, 1),
setup.vm.segments.memory.data.items[1].items[3].?.maybe_relocatable,
setup.vm.segments.memory.data.items[1].items[3].getValue().?,
);
}

Expand Down Expand Up @@ -328,7 +328,7 @@ test "Element found by oracle" {

try expectEqual(
MaybeRelocatable.fromInt(u8, 1),
setup.vm.segments.memory.data.items[1].items[3].?.maybe_relocatable,
setup.vm.segments.memory.data.items[1].items[3].getValue().?,
);
}

Expand Down Expand Up @@ -693,7 +693,7 @@ test "Search sorted lower simple" {

try expectEqual(
MaybeRelocatable.fromInt(u8, 1),
setup.vm.segments.memory.data.items[1].items[3].?.maybe_relocatable,
setup.vm.segments.memory.data.items[1].items[3].getValue().?,
);
}

Expand Down Expand Up @@ -725,7 +725,7 @@ test "Search sorted lower with no match" {

try expectEqual(
MaybeRelocatable.fromInt(u8, 2),
setup.vm.segments.memory.data.items[1].items[3].?.maybe_relocatable,
setup.vm.segments.memory.data.items[1].items[3].getValue().?,
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/hint_processor/keccak_utils.zig
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ test "KeccakUtils: unsafeKeccak invalid word size" {
defer exec_scopes.deinit();

inline for (0..3) |i| {
try vm.insertInMemory(std.testing.allocator, Relocatable.init(data_ptr.segment_index, data_ptr.offset + i), MaybeRelocatable.fromFelt(Felt252.fromSignedInt(-1)));
try vm.insertInMemory(std.testing.allocator, Relocatable.init(data_ptr.segment_index, data_ptr.offset + i), MaybeRelocatable.fromFelt(Felt252.fromInt(i8, -1)));
}

const hint_processor: HintProcessor = .{};
Expand Down
Loading

0 comments on commit 61a3967

Please sign in to comment.