{"record":{"id":"394891a3c54f94d4","repo":"FuelLabs/sway","slug":"fetching-gas-costs-from-testnet-is-currently-not-i","errorCode":null,"errorMessage":"Fetching gas costs from testnet is currently not implemented.","messagePattern":"Fetching gas costs from testnet is currently not implemented\\.","errorType":"console","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"forc-test/src/lib.rs","lineNumber":208,"sourceCode":"    Testnet,\n    File(String),\n}\n\nimpl GasCostsSource {\n    pub fn provide_gas_costs(&self) -> Result<GasCostsValues, anyhow::Error> {\n        match self {\n            // Values in the `gas_costs_values.json` are taken from the `chain-configuration` repository:\n            //      chain-configuration/upgradelog/ignition/consensus_parameters/<version>.json\n            // Update these values when there are changes to the on-chain gas costs.\n            Self::BuiltIn => Ok(serde_json::from_str(include_str!(\n                \"../gas_costs_values.json\"\n            ))?),\n            // TODO: (GAS-COSTS) Fetch actual gas costs from mainnet/testnet and JSON file.\n            //       See: https://github.com/FuelLabs/sway/issues/7472\n            Self::Mainnet => Err(anyhow::anyhow!(\n                \"Fetching gas costs from mainnet is currently not implemented.\"\n            )),\n            Self::Testnet => Err(anyhow::anyhow!(\n                \"Fetching gas costs from testnet is currently not implemented.\"\n            )),\n            Self::File(_file_path) => Err(anyhow::anyhow!(\n                \"Loading gas costs from a JSON file is currently not implemented.\"\n            )),\n        }\n    }\n}\n\nimpl FromStr for GasCostsSource {\n    type Err = anyhow::Error;\n\n    fn from_str(value: &str) -> Result<Self, Self::Err> {\n        match value {\n            \"built-in\" => Ok(Self::BuiltIn),\n            \"mainnet\" => Ok(Self::Mainnet),\n            \"testnet\" => Ok(Self::Testnet),\n            file_path => Ok(Self::File(file_path.to_string())),","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/FuelLabs/sway/blob/47e5e902faa42baf652dd6a0c88cd23390c1a614/forc-test/src/lib.rs#L190-L226","documentation":"Identical stub to the Mainnet arm: GasCostsSource::provide_gas_costs() returns a hard-coded anyhow error for Self::Testnet because fetching live gas costs is not implemented (sway#7472). Only the BuiltIn arm returns Ok, by deserializing the packaged gas_costs_values.json.","triggerScenarios":"`forc test --gas-costs testnet`, or GasCostsSource::from_str(\"testnet\") followed by provide_gas_costs(). Parsing \"testnet\" succeeds; the failure happens at gas-cost provisioning time.","commonSituations":"Developers targeting testnet who expect cost profiles to mirror the live network, or CI configs pinned to `--gas-costs testnet` copied from templates for a forc version that never supported it.","solutions":["Run `forc test` with the built-in source (default, or explicitly `--gas-costs built-in`)","Track/upgrade to a forc version implementing testnet fetching (sway#7472)","If you maintain the tool, implement the arm by fetching consensus parameters and deserializing into GasCostsValues"],"exampleFix":"# before\nforc test --gas-costs testnet\n\n# after\nforc test --gas-costs built-in","handlingStrategy":"validation","validationCode":"let source = GasCostsSource::from_str(value)?;\nif matches!(source, GasCostsSource::Testnet | GasCostsSource::Mainnet | GasCostsSource::File(_)) {\n    anyhow::bail!(\"only 'built-in' gas costs are supported by this forc version\");\n}","typeGuard":"fn supported(src: &GasCostsSource) -> bool {\n    matches!(src, GasCostsSource::BuiltIn)\n}","tryCatchPattern":"if let Err(e) = source.provide_gas_costs() {\n    if e.to_string().contains(\"testnet\") {\n        // fall back to built-in values for now\n        return GasCostsSource::BuiltIn.provide_gas_costs();\n    }\n    return Err(e);\n}","preventionTips":["Default to omitting --gas-costs (BuiltIn is the default variant)","Wrap forc invocations in scripts and validate the supported source list once per forc version"],"tags":["forc-test","gas-costs","not-implemented","cli"],"backgroundTag":null,"analyzedSha":"47e5e902faa42baf652dd6a0c88cd23390c1a614","analyzedAt":"2026-08-16T07:57:45.555Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}