Commit aeb2057
committed
fix(fuzz): explicit HostError generic on try_invoke_contract
`soroban-sdk` 22.x changed `Env::try_invoke_contract` to return
`Result<Result<T, ContractError>, HostError>`. The fuzz harnesses
were calling it as `env.try_invoke_contract::<T, _>(...)`, leaving
the host-error type uninferred; with multiple `impl TryFromVal<...>`
candidates for `Error`, rustc refused with:
error[E0283]: type annotations needed
--> fuzz_targets/fuzz_vault_withdraw.rs:42:13
|
42 | let _ = env.try_invoke_contract::<(), _>(
| ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the error type `E`
In the looping harness, the same problem cascaded — the
single `.expect()` was returning `Result<u64, Error>` (the inner
layer) instead of `u64`, breaking the `position_id >= 1` and
`{position_id}` formatting assertions.
Fix: make the second generic argument explicit as
`soroban_sdk::Error` (which is the actual host-error type for the
outer Result), and where `.expect()` is also used, unwrap both layers:
// vault/deposit, vault/withdraw
- try_invoke_contract::<(), _>
+ try_invoke_contract::<(), soroban_sdk::Error>
// looping/open_position
- try_invoke_contract::<u64, _>
+ try_invoke_contract::<u64, soroban_sdk::Error>
- let position_id = result.expect("...");
+ let position_id = result
+ .expect("open_position returned a host error")
+ .expect("open_position with valid args returned a contract error");
The rewards harness only uses `env.invoke_contract` (infallible) and
needed no change.1 parent 943fba6 commit aeb2057
3 files changed
Lines changed: 14 additions & 5 deletions
File tree
- quantara/soroban/contracts
- looping/fuzz/fuzz_targets
- vault/fuzz/fuzz_targets
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
| |||
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
42 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
43 | 48 | | |
44 | 49 | | |
45 | 50 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
| |||
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
42 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
| |||
0 commit comments