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

Error in migrate_db_chrysalis_to_stardust() if no chrysalis data exists #1215

Merged
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
6 changes: 5 additions & 1 deletion bindings/nodejs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Security -->

## 1.0.10 - 2023-mm-dd
## 1.0.10 - 2023-09-12

### Fixed

- Type of `value` property in `CustomAddress`;

### Changed

- `migrateDbChrysalisToStardust()` returns an error if no chrysalis data was found;

## 1.0.9 - 2023-09-07

### Added
Expand Down
2 changes: 1 addition & 1 deletion bindings/nodejs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@iota/sdk",
"version": "1.0.9",
"version": "1.0.10",
"description": "Node.js binding to the IOTA SDK library",
"main": "out/index.js",
"types": "out/index.d.ts",
Expand Down
6 changes: 6 additions & 0 deletions sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Security -->

## 1.0.4 - 2023-MM-DD

### Changed

- `migrate_db_chrysalis_to_stardust()` returns an error if no chrysalis data was found;

## 1.0.3 - 2023-09-07

### Added
Expand Down
5 changes: 5 additions & 0 deletions sdk/src/wallet/migration/chrysalis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ pub async fn migrate_db_chrysalis_to_stardust(
// `/db` will be appended to the chrysalis storage path, because that's how it was done in the chrysalis wallet
let chrysalis_storage_path = &(*storage_path_string).join("db");

if !chrysalis_storage_path.is_dir() {
thibault-martinez marked this conversation as resolved.
Show resolved Hide resolved
return Err(crate::wallet::Error::Migration(
"no chrysalis data to migrate".to_string(),
));
}
let chrysalis_data = get_chrysalis_data(chrysalis_storage_path, password)?;

// create new accounts base on previous data
Expand Down
14 changes: 14 additions & 0 deletions sdk/tests/wallet/chrysalis_migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,20 @@ async fn migrate_chrysalis_stronghold() -> Result<()> {
tear_down(storage_path)
}

#[tokio::test]
async fn migrate_empty_chrysalis_db() -> Result<()> {
iota_stronghold::engine::snapshot::try_set_encrypt_work_factor(0).unwrap();
let storage_path = "migrate_empty_chrysalis_db";
thibault-martinez marked this conversation as resolved.
Show resolved Hide resolved
setup(storage_path)?;

assert!(matches!(
migrate_db_chrysalis_to_stardust("migrate_empty_chrysalis_db", None, None).await,
Err(iota_sdk::wallet::error::Error::Migration(msg)) if msg == "no chrysalis data to migrate"
));
thibault-martinez marked this conversation as resolved.
Show resolved Hide resolved

tear_down(storage_path)
}

fn copy_folder(src: impl AsRef<Path>, dest: impl AsRef<Path>) -> io::Result<()> {
fs::create_dir_all(&dest)?;
for entry in fs::read_dir(src)? {
Expand Down
Loading