Skip to content

Commit

Permalink
Add test case for build-external reexports
Browse files Browse the repository at this point in the history
  • Loading branch information
maciektr committed Nov 29, 2024
1 parent 715f414 commit e31a545
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions scarb/tests/build_starknet_external_contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,3 +495,67 @@ fn will_warn_about_unmatched_paths() {
]
);
}

#[test]
fn can_build_external_reexported_contracts() {
let t = TempDir::new().unwrap();
let hello = t.child("hello");
let beautiful = t.child("beautiful");
let world = t.child("world");

ProjectBuilder::start()
.name("hello")
.version("0.1.0")
.manifest_extra(indoc! {r#"
[lib]
[[target.starknet-contract]]
"#})
.dep_starknet()
.lib_cairo("pub mod a; pub mod b;")
.src("src/a.cairo", BALANCE_CONTRACT)
.src("src/b.cairo", HELLO_CONTRACT)
.build(&hello);

ProjectBuilder::start()
.name("beautiful")
.version("0.1.0")
.manifest_extra(indoc! {r#"
[lib]
[[target.starknet-contract]]
"#})
.dep_starknet()
.dep("hello", &hello)
.lib_cairo("pub use hello as hello_world; pub use hello::a::Balance;")
.build(&beautiful);

ProjectBuilder::start()
.name("world")
.version("0.1.0")
.dep("beautiful", beautiful)
.manifest_extra(formatdoc! {r#"
[[target.starknet-contract]]
build-external-contracts = ["beautiful::hello_world::b::*", "beautiful::Balance"]
"#})
.dep_starknet()
.build(&world);

Scarb::quick_snapbox()
.arg("build")
.current_dir(&world)
.assert()
.success()
.stdout_matches(indoc! {r#"
[..] Compiling world v0.1.0 ([..]/Scarb.toml)
warn: external contracts not found for selectors: `beautiful::*`
[..] Finished `dev` profile target(s) in [..]
"#});

assert_eq!(
world.child("target/dev").files(),
vec![
"world.starknet_artifacts.json",
"world_Balance.contract_class.json",
"world_HelloContract.contract_class.json"
]
);
}

0 comments on commit e31a545

Please sign in to comment.