neo-cli 1.0.0

Command-line interface for the NeoRust SDK
#[cfg(test)]
mod tests {
	use crate::integration::utils::CliTest;

	#[test]
	fn test_contract_info() {
		let cli = CliTest::new();

		// For testing, we'll use a known contract hash
		// This should be replaced with a valid hash in a real environment
		let _contract_hash = "0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5"; // Example GAS token hash

		let output = cli.run_command(&["contract", "list-native-contracts"]);

		// Command requires network connectivity, so just check it's recognized
		assert!(output.status.code().unwrap_or(127) != 127, "Command not found");
	}

	#[test]
	#[ignore] // Command not implemented yet
	fn test_contract_manifest() {
		let cli = CliTest::new();

		// For testing purposes
		let _contract_hash = "0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5"; // Example GAS token hash

		let output = cli.run_command(&["contract", "list-native-contracts"]);

		// The command structure should be valid even if the contract doesn't exist
		assert!(output.status.code().unwrap_or(127) != 127, "Command not found");
	}

	#[test]
	#[ignore] // Command not implemented yet
	fn test_contract_methods() {
		let cli = CliTest::new();

		// For testing purposes
		let _contract_hash = "0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5"; // Example GAS token hash

		let output = cli.run_command(&["contract", "list-native-contracts"]);

		// The command structure should be valid
		assert!(output.status.code().unwrap_or(127) != 127, "Command not found");
	}

	#[test]
	fn test_contract_test_invoke() {
		let cli = CliTest::new();

		// Create parameters JSON for the test invoke
		let params_json = r#"["test"]"#;

		let contract_hash = "0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5"; // Example GAS token hash
		let method = "transfer";

		let output = cli.run_command(&[
			"contract",
			"invoke",
			"--script-hash",
			contract_hash,
			"--method",
			method,
			"--params",
			params_json,
			"--test-invoke",
		]);

		// The command should be recognized (exit code != 127)
		// It may fail due to no connection, but the command structure should be valid
		assert!(output.status.code().unwrap_or(127) != 127, "Command not found");
	}

	#[test]
	#[ignore] // Command not implemented yet
	fn test_contract_storage() {
		let cli = CliTest::new();

		let _contract_hash = "0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5"; // Example GAS token hash

		let output = cli.run_command(&["contract", "list-native-contracts"]);

		// The command structure should be valid even if no storage items exist
		assert!(output.status.code().unwrap_or(127) != 127, "Command not found");
	}

	#[test]
	fn test_contract_deploy() {
		let cli = CliTest::new();

		// Create sample NEF file content (this is just a mock for testing)
		let nef_content = "NEF1FAKECONTENTaa";
		let nef_file = cli.create_temp_file(nef_content);

		// Create sample manifest content
		let manifest_content = r#"{
            "name": "TestContract",
            "groups": [],
            "features": {},
            "abi": {
                "methods": [
                    {
                        "name": "verify",
                        "parameters": [],
                        "returntype": "Boolean",
                        "offset": 0
                    }
                ],
                "events": []
            },
            "permissions": [
                {
                    "contract": "*",
                    "methods": "*"
                }
            ],
            "trusts": [],
            "supportedstandards": [],
            "extra": null
        }"#;
		let manifest_file = cli.create_temp_file(manifest_content);

		let output = cli.run_command(&[
			"contract",
			"deploy",
			"--nef",
			nef_file.to_str().unwrap(),
			"--manifest",
			manifest_file.to_str().unwrap(),
		]);

		// The command should be recognized (exit code != 127)
		// It may fail due to no wallet or connection, but the command structure should be valid
		assert!(output.status.code().unwrap_or(127) != 127, "Command not found");
	}
}