Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: add tests for migration #2614

Merged
merged 7 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bin/sozo/src/commands/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl ExecuteArgs {
);

config.tokio_handle().block_on(async {
let mut spinner = MigrationUi::new("").with_silent();
let mut spinner = MigrationUi::new(None).with_silent();

let (world_diff, account, _) = utils::get_world_diff_and_account(
self.account,
Expand Down
2 changes: 1 addition & 1 deletion bin/sozo/src/commands/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl MigrateArgs {
config.tokio_handle().block_on(async {
print_banner(&ws, &starknet).await?;

let mut spinner = MigrationUi::new("Evaluating world diff...");
let mut spinner = MigrationUi::new(Some("Evaluating world diff..."));

let mut txn_config: TxnConfig = self.transaction.into();
txn_config.wait = true;
Expand Down
2 changes: 1 addition & 1 deletion crates/dojo/world/src/remote/events_to_remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ impl WorldRemote {
resource.push_class_hash(e.class_hash.into());
}
WorldEvent::ContractInitialized(e) => {
// Unwrap is safe bcause the contract must exist in the world.
// Unwrap is safe because the contract must exist in the world.
let resource = self.resources.get_mut(&e.selector).unwrap();
let contract = resource.as_contract_mut()?;
contract.is_initialized = true;
Expand Down
3 changes: 3 additions & 0 deletions crates/sozo/ops/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ dojo-test-utils = { workspace = true, features = [ "build-examples" ] }
ipfs-api-backend-hyper = { git = "https://github.com/ferristseng/rust-ipfs-api", rev = "af2c17f7b19ef5b9898f458d97a90055c3605633", features = [ "with-hyper-rustls" ] }
katana-runner.workspace = true
dojo-types.workspace = true
tokio.workspace = true
scarb.workspace = true
sozo-scarbext.workspace = true

[features]
test-utils = [ "dep:dojo-test-utils", "dep:katana-runner" ]
Expand Down
10 changes: 4 additions & 6 deletions crates/sozo/ops/src/migrate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,17 +204,15 @@ where

let has_changed = !invoker.calls.is_empty();

if !ordered_init_calls.is_empty() {
if !invoker.calls.is_empty() {
if self.do_multicall() {
let ui_text = format!("Initializing {} contracts...", ordered_init_calls.len());
let ui_text = format!("Initializing {} contracts...", invoker.calls.len());
ui.update_text_boxed(ui_text);

invoker.multicall().await?;
} else {
let ui_text = format!(
"Initializing {} contracts (sequentially)...",
ordered_init_calls.len()
);
let ui_text =
format!("Initializing {} contracts (sequentially)...", invoker.calls.len());
ui.update_text_boxed(ui_text);

invoker.invoke_all_sequentially().await?;
Expand Down
14 changes: 10 additions & 4 deletions crates/sozo/ops/src/migration_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,16 @@ impl fmt::Debug for MigrationUi {

impl MigrationUi {
/// Returns a new instance with the default frames.
pub fn new(text: &'static str) -> Self {
let frames = spinner!(["⛩️ ", "🎃", "👻", "🧟", "💀"], 500);
let spinner = Spinner::new(frames.clone(), text, None);
Self { spinner, default_frames: frames, silent: false }
pub fn new(text: Option<&'static str>) -> Self {
if let Some(text) = text {
let frames = spinner!(["⛩️ ", "🎃", "👻", "🧟", "💀"], 500);
let spinner = Spinner::new(frames.clone(), text, None);
Self { spinner, default_frames: frames, silent: false }
} else {
let frames = spinner!([""], 5000);
let spinner = Spinner::new(frames.clone(), "", None);
Self { spinner, default_frames: frames, silent: false }
}
}

/// Returns a new instance with the silent flag set.
Expand Down
Loading
Loading