Skip to content
Open
Changes from all 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
21 changes: 21 additions & 0 deletions packages/contracts/defindex-adapter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,27 @@ mod tests {
adapter.withdraw(&amount, &recipient);
}

#[test]
#[should_panic]
fn deposit_panics_with_typed_error_when_dfx_vault_is_unset() {
// The deposit()-side counterpart to
// withdraw_panics_with_typed_error_when_dfx_vault_is_unset above:
// __constructor always sets DFX_VAULT on any real deployment, so
// this state is unreachable in practice; this test clears it
// directly after construction to prove deposit() still fails with
// the typed NotInitialized panic rather than an opaque unwrap trap
// if that invariant is ever violated by a future change.
let (env, _vault, _usdc, adapter, _dfx) = setup();

env.as_contract(&adapter.address, || {
env.storage().instance().remove(&DFX_VAULT);
});

// The NotInitialized check runs before any token movement, so no
// USDC funding is needed to reach it.
adapter.deposit(&100_0000000_i128);
}

#[test]
fn get_protocol_returns_defindex() {
let (env, _vault, _usdc, adapter, _dfx) = setup();
Expand Down