Skip to content

Commit f7b11ca

Browse files
shanevclaude
andcommitted
test: add comprehensive test for ContractInfo query fallback mechanism
- Added test_real_contract_detected_by_contract_info_query test - Tests that actual contracts (like minter addresses) are properly detected - Even if contract address is <50 chars, ContractInfo query catches it - Now have 6 total contract detection tests covering all scenarios: 1. EOAs can mint 2. Short addresses treated as EOAs 3. Long addresses blocked as contracts 4. Admin mints bypass checks 5. Boundary testing at 50 chars 6. Real contracts detected by ContractInfo query 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 2cd3240 commit f7b11ca

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

test-suite/src/vending_minter/tests/contract_detection.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,3 +197,47 @@ fn test_boundary_address_length() {
197197
let contract_err = err.downcast_ref::<ContractError>().unwrap();
198198
assert_eq!(*contract_err, ContractError::ContractsCannotMint {});
199199
}
200+
201+
#[test]
202+
fn test_real_contract_detected_by_contract_info_query() {
203+
let vt = vending_minter_template(1);
204+
let (mut router, _creator, _buyer) = (vt.router, vt.accts.creator, vt.accts.buyer);
205+
let minter_addr = vt.collection_response_vec[0].minter.clone().unwrap();
206+
207+
// Use the actual minter contract address (which is a real contract but short address)
208+
// This tests the ContractInfo query fallback since the minter address is likely <50 chars
209+
// but is definitely a contract that should be blocked from minting
210+
211+
// Set time after start time to enable minting
212+
setup_block_time(&mut router, GENESIS_MINT_START_TIME + 1, None);
213+
214+
// Fund the minter contract address so it can attempt to mint
215+
router
216+
.sudo(cw_multi_test::SudoMsg::Bank(
217+
cw_multi_test::BankSudo::Mint {
218+
to_address: minter_addr.to_string(),
219+
amount: coins(MINT_PRICE * 2, NATIVE_DENOM),
220+
},
221+
))
222+
.unwrap();
223+
224+
// The minter contract trying to mint from itself should be blocked
225+
let mint_msg = ExecuteMsg::Mint {};
226+
let res = router.execute_contract(
227+
minter_addr.clone(),
228+
minter_addr,
229+
&mint_msg,
230+
&coins(MINT_PRICE, NATIVE_DENOM),
231+
);
232+
233+
// This should fail with ContractsCannotMint error because the ContractInfo
234+
// query should detect that minter_addr is a contract, even if it's <50 chars
235+
assert!(
236+
res.is_err(),
237+
"Real contract address should be blocked from minting via ContractInfo query"
238+
);
239+
240+
let err = res.unwrap_err();
241+
let contract_err = err.downcast_ref::<ContractError>().unwrap();
242+
assert_eq!(*contract_err, ContractError::ContractsCannotMint {});
243+
}

0 commit comments

Comments
 (0)