Skip to content

Commit

Permalink
hotfix-init-crashes (#1745)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arcticae authored Feb 21, 2024
1 parent f840f8b commit 48f909a
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
#### Changed

- Unknown entry point error when calling a contract counts as a panic
- Cairo edition set to `2023_11`

#### Fixed

Expand Down
3 changes: 1 addition & 2 deletions crates/forge/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ use anyhow::{anyhow, Context, Ok, Result};

use include_dir::{include_dir, Dir};

use forge::CAIRO_EDITION;
use scarb_api::ScarbCommand;
use std::fs::{self, OpenOptions};
use std::io::Write;
use std::path::Path;
use toml_edit::{value, ArrayOfTables, Document, Item, Table};

const CAIRO_EDITION: &str = "2023_10";

static TEMPLATE: Dir = include_dir!("starknet_forge_template");

fn overwrite_files_from_scarb_template(
Expand Down
3 changes: 3 additions & 0 deletions crates/forge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ use crate::test_filter::TestsFilter;

pub mod block_number_map;
pub mod compiled_raw;

pub mod pretty_printing;
pub mod scarb;
pub mod shared_cache;
pub mod test_filter;
mod warn;

pub const CAIRO_EDITION: &str = "2023_11";

pub(crate) fn replace_id_with_params<'a>(
raw_fork_config: &'a RawForkConfig,
fork_targets: &'a [ForkTarget],
Expand Down
7 changes: 5 additions & 2 deletions crates/forge/tests/e2e/running.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use crate::e2e::common::runner::{
get_current_branch, get_remote_url, runner, setup_package, test_runner,
};

use assert_fs::fixture::{FileWriteStr, PathChild, PathCopy};
use camino::Utf8PathBuf;
use forge::CAIRO_EDITION;
use indoc::{formatdoc, indoc};
use std::fs;
use std::{path::Path, str::FromStr};
Expand Down Expand Up @@ -749,7 +751,7 @@ fn init_new_project_test() {
[package]
name = "test_name"
version = "0.1.0"
edition = "2023_10"
edition = "{}"
# See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html
Expand All @@ -760,7 +762,8 @@ fn init_new_project_test() {
[[target.starknet-contract]]
casm = true
"#,
version
CAIRO_EDITION,
version,
);

assert_eq!(generated_toml, expected_toml);
Expand Down
2 changes: 1 addition & 1 deletion starknet_forge_template/src/lib.cairo
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[starknet::interface]
trait IHelloStarknet<TContractState> {
pub trait IHelloStarknet<TContractState> {
fn increase_balance(ref self: TContractState, amount: felt252);
fn get_balance(self: @TContractState) -> felt252;
}
Expand Down
2 changes: 1 addition & 1 deletion starknet_forge_template/tests/test_contract.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn test_cannot_increase_balance_with_zero_value() {

#[feature("safe_dispatcher")]
match safe_dispatcher.increase_balance(0) {
Result::Ok(_) => panic_with_felt252('Should have panicked'),
Result::Ok(_) => core::panic_with_felt252('Should have panicked'),
Result::Err(panic_data) => {
assert(*panic_data.at(0) == 'Amount cannot be 0', *panic_data.at(0));
}
Expand Down

0 comments on commit 48f909a

Please sign in to comment.