@@ -1245,78 +1245,26 @@ mod tests {
12451245
12461246	#[ tokio:: test]  
12471247	async  fn  query_storage_with_composite_key_works ( )  -> Result < ( ) >  { 
1248- 		// Spawn a test node and prepare chain configuration via the command flow  
1248+ 		// Spawn a test node 
12491249		let  node = TestNode :: spawn ( ) . await ?; 
12501250		let  node_url = node. ws_url ( ) ; 
12511251
1252- 		// Provide composite key parts separately  to ensure the command converts them into  a tuple  
1253- 		let  mut  call_config  = CallChainCommand  { 
1252+ 		// Build the command  to directly execute a storage query using  a composite key  
1253+ 		let  cmd  = CallChainCommand  { 
12541254			pallet :  Some ( "Assets" . to_string ( ) ) , 
12551255			function :  Some ( "Account" . to_string ( ) ) , 
12561256			args :  vec ! [ 
12571257				"10000" . to_string( ) ,  // AssetId 
12581258				// Alice AccountId32 (hex) in dev networks 
12591259				"0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d" . to_string( ) , 
12601260			] , 
1261+ 			url :  Some ( Url :: parse ( node_url) ?) , 
1262+ 			skip_confirm :  true ,  // Avoid interactive confirmation at the end of execute loop 
12611263			..Default :: default ( ) 
12621264		} ; 
12631265
1264- 		let  mut  cli = MockCli :: new ( ) 
1265- 			. expect_select ( 
1266- 				"Select a chain (type to filter):" . to_string ( ) , 
1267- 				Some ( true ) , 
1268- 				true , 
1269- 				Some ( vec ! [ ( "Custom" . to_string( ) ,  "Type the chain URL manually" . to_string( ) ) ] ) , 
1270- 				0 , 
1271- 				None , 
1272- 			) 
1273- 			. expect_input ( "Which chain would you like to interact with?" ,  node_url. into ( ) ) ; 
1274- 
1275- 		let  chain = chain:: configure ( 
1276- 			"Which chain would you like to interact with?" , 
1277- 			node_url, 
1278- 			& None , 
1279- 			|_| true , 
1280- 			& mut  cli, 
1281- 		) 
1282- 		. await ?; 
1283- 
1284- 		// Configure the call; since pallet and storage name are provided and args present, 
1285- 		// this should not prompt further. 
1286- 		// For composite keys the command should convert the 
1287- 		// two args into a single tuple string argument. 
1288- 		let  call = call_config. configure_call ( & chain,  & mut  cli) ?; 
1289- 		assert_eq ! ( call. function. pallet( ) ,  "Assets" ) ; 
1290- 		assert_eq ! ( call. function. name( ) ,  "Account" ) ; 
1291- 		assert_eq ! ( call. args. len( ) ,  1 ,  "Composite key should be represented as a single tuple arg" ) ; 
1292- 		assert_eq ! ( call. args[ 0 ] ,  "(100000,0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d)" ) ; 
1293- 
1294- 		// Perform the query similar to the execute() path 
1295- 		if  let  CallItem :: Storage ( storage)  = & call. function  { 
1296- 			let  keys = if  let  Some ( key_ty)  = storage. key_id  { 
1297- 				let  metadata = chain. client . metadata ( ) ; 
1298- 				let  registry = metadata. types ( ) ; 
1299- 				let  type_info = registry
1300- 					. resolve ( key_ty) 
1301- 					. ok_or ( anyhow:: anyhow!( "Failed to resolve storage key type: {key_ty}" ) ) ?; 
1302- 				let  name = type_info. path . segments . last ( ) . unwrap_or ( & "" . to_string ( ) ) . to_string ( ) ; 
1303- 				let  key_param = type_to_param ( & name,  registry,  key_ty) 
1304- 					. map_err ( |e| anyhow ! ( "Failed to parse storage key type: {e}" ) ) ?; 
1305- 
1306- 				pop_chains:: parse_dispatchable_arguments ( & [ key_param] ,  call. args . clone ( ) ) 
1307- 					. map_err ( |e| anyhow ! ( "Failed to parse storage arguments: {e}" ) ) ?
1308- 			}  else  { 
1309- 				vec ! [ ] 
1310- 			} ; 
1311- 
1312- 			// Execute the storage query; result may be None if the (AssetId, AccountId) 
1313- 			// combination does not exist on the fresh test chain, but the query should succeed 
1314- 			// without errors. 
1315- 			let  _maybe_value = storage. query ( & chain. client ,  keys) . await ?; 
1316- 		}  else  { 
1317- 			panic ! ( "Expected a storage query" ) ; 
1318- 		} 
1319- 
1320- 		cli. verify ( ) 
1266+ 		// Execute the command end-to-end; it should parse the composite key and perform the storage 
1267+ 		// query 
1268+ 		cmd. execute ( ) . await 
13211269	} 
13221270} 
0 commit comments