stellar / rs-soroban-sdk

Rust SDK for Soroban contracts.
Apache License 2.0
128 stars 67 forks source link

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

Closed leighmcculloch closed 1 month ago

leighmcculloch commented 4 months 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:

leighmcculloch commented 1 month ago

This doesn't appear to have been a recurring issue. I haven't seen recurring complaints. I'm going to close since it doesn't seem high impact, but we can reopen if that is the wrong call.