Skip to content

Commit

Permalink
Add integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
fmoletta committed Mar 9, 2023
1 parent 8005605 commit 1045dd8
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
16 changes: 16 additions & 0 deletions cairo_programs/ec_op.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
%builtins ec_op

from starkware.cairo.common.cairo_builtins import EcOpBuiltin
from starkware.cairo.common.ec_point import EcPoint
from starkware.cairo.common.ec import ec_op


func main{ec_op_ptr: EcOpBuiltin*}() {
let p = EcPoint(3,0);
let m = 34;
let q = EcPoint(4,0);
let (r) = ec_op(p, m, q);
assert r.x = 3;
assert r.y = 0;
return ();
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ use felt::Felt;
#[cfg(feature = "skip_next_instruction_hint")]
use crate::hint_processor::builtin_hint_processor::skip_next_instruction::skip_next_instruction;

use super::ec_utils::random_ec_point_hint;

pub struct HintProcessorData {
pub code: String,
pub ap_tracking: ApTracking,
Expand Down Expand Up @@ -438,6 +440,9 @@ impl HintProcessor for BuiltinHintProcessor {
hint_code::VERIFY_ECDSA_SIGNATURE => {
verify_ecdsa_signature(vm, &hint_data.ids_data, &hint_data.ap_tracking)
}
hint_code::RANDOM_EC_POINT => {
random_ec_point_hint(vm, &hint_data.ids_data, &hint_data.ap_tracking)
}
#[cfg(feature = "skip_next_instruction_hint")]
hint_code::SKIP_NEXT_INSTRUCTION => skip_next_instruction(vm),
code => Err(HintError::UnknownHint(code.to_string())),
Expand Down
16 changes: 16 additions & 0 deletions tests/cairo_run_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1408,3 +1408,19 @@ fn cairo_run_verify_signature_hint() {
)
.expect("Couldn't run program");
}

#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn cairo_run_ec_op() {
let mut hint_executor = BuiltinHintProcessor::new_empty();
let cairo_run_config = cairo_run::CairoRunConfig {
layout: "all",
..cairo_vm::cairo_run::CairoRunConfig::default()
};
cairo_run::cairo_run(
include_bytes!("../cairo_programs/ec_op.json"),
&cairo_run_config,
&mut hint_executor,
)
.expect("Couldn't run program");
}

1 comment on commit 1045dd8

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.30.

Benchmark suite Current: 1045dd8 Previous: 17f467c Ratio
cairo_run(cairo_programs/benchmarks/keccak_integration_benchmark.json) 1570155938 ns/iter (± 78533328) 1204174242 ns/iter (± 3341977) 1.30
cairo_run(cairo_programs/benchmarks/secp_integration_benchmark.json) 1900735496 ns/iter (± 157026563) 1404153184 ns/iter (± 2596536) 1.35
cairo_run(cairo_programs/benchmarks/operations_with_data_structures_benchmarks.json) 2308697431 ns/iter (± 102864270) 1738920910 ns/iter (± 4509653) 1.33
cairo_run(cairo_programs/benchmarks/uint256_integration_benchmark.json) 1533897742 ns/iter (± 49668051) 1170903770 ns/iter (± 3675965) 1.31

This comment was automatically generated by workflow using github-action-benchmark.

CC: @unbalancedparentheses

Please sign in to comment.