stellar / rs-soroban-sdk

Rust SDK for Soroban contracts.
Apache License 2.0
118 stars 66 forks source link

Make Env::from_snapshot_file return meaningful error when someone calls it with a ledger snapshot #1305

Open leighmcculloch opened 1 month ago

leighmcculloch commented 1 month ago

@kalepail pointed out that the Env::from_snapshot_file is misleading it looks like it takes a snapshot file from the CLI, but the CLI actually outputs ledger snapshots that need to be given to Env::from_ledger_snapshot_file.

Env::from_snapshot_file is for test snapshots that contain not only the ledger but an entire snapshot of the test environment.

Env::from_ledger_snapshot_file is for ledger snapshots that can come from a test environment or from a deployed network like pubnet or testnet.

It's unfortunate that we have two competing concepts that are easily confusable.

It might be difficult to rename these functions now, but we can at least provide a meaningful error pointing a developer towards the fix they need. We can detect if the file is a ledger only and tell the develoepr to use Env::from_ledger_snapshot_file.

Discussion: