Skip to content

Commit

Permalink
fix(deps): the second pull forget to set wasm_hash_download in pulled…
Browse files Browse the repository at this point in the history
….json (#3674)

* add e2e test to reveal the issue

* fix(deps): the second pull forget to set wasm_hash_download in pulled.json

* changelog
  • Loading branch information
lwshang authored Mar 25, 2024
1 parent 5065517 commit 810732b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ dfx.json. This is now performed by dfxvm.
When all the arguments are optional, dfx automatically provides a `null` value when no arguments are provided.
`--always-assist` flag enables the candid assist feature for optional arguments, instead of providing a default `null` value.

### fix(deps): the second pull forget to set wasm_hash_download in pulled.json

When the dependency has been in the cache, `dfx deps pull` forgot to set correct `wasm_hash_download` in `pulled.json`.

It caused the following `init/deploy` commands to fail.

## Dependencies

### Replica
Expand Down
19 changes: 19 additions & 0 deletions e2e/tests-dfx/deps.bash
Original file line number Diff line number Diff line change
Expand Up @@ -656,3 +656,22 @@ Installing canister: $CANISTER_ID_C (dep_c)"

assert_directory_not_exists "deps"
}

@test "dfx deps pull can set correct pulled.json when the dependency is already in cache" {
use_test_specific_cache_root # dfx deps pull will download files to cache

# start a "mainnet" replica which host the onchain canisters
dfx_start

setup_onchain

# pull canisters in app project and the dependencies are cached
cd app
assert_command dfx deps pull --network local

# the second pull should be able to set the correct pulled.json
assert_command dfx deps pull --network local

# this command will fail if the pulled.json is not correct
assert_command dfx deps init
}
1 change: 1 addition & 0 deletions src/dfx/src/commands/deps/pull.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ async fn download_and_generate_pulled_canister(
if hash_cache.as_slice() == hash_on_chain {
cache_hit = true;
pulled_canister.gzip = gzip;
pulled_canister.wasm_hash_download = hex::encode(hash_cache);
trace!(logger, "The canister wasm was found in the cache.");
}
break;
Expand Down

0 comments on commit 810732b

Please sign in to comment.