diff --git a/scarb/tests/build_starknet_external_contracts.rs b/scarb/tests/build_starknet_external_contracts.rs index f86dbe7a1..8f2853e66 100644 --- a/scarb/tests/build_starknet_external_contracts.rs +++ b/scarb/tests/build_starknet_external_contracts.rs @@ -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" + ] + ); +}