fix(solc): use empty bytecode as default instead unlinked (#1743)

* fix(solc): use empty bytecode as default instead unlinked

* chore: fmt

Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
This commit is contained in:
Matthias Seitz 2022-09-26 19:35:19 +02:00 committed by GitHub
parent 7888aaecde
commit d8791482d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 30 additions and 2 deletions

View File

@ -352,10 +352,10 @@ impl BytecodeObject {
}
}
// Returns a not deployable bytecode by default as empty
// Returns an empty bytecode object
impl Default for BytecodeObject {
fn default() -> Self {
BytecodeObject::Unlinked("".to_string())
BytecodeObject::Bytecode(Default::default())
}
}
@ -457,3 +457,31 @@ impl From<CompactDeployedBytecode> for DeployedBytecode {
}
}
}
#[cfg(test)]
mod tests {
use crate::{artifacts::ContractBytecode, ConfigurableContractArtifact};
#[test]
fn test_empty_bytecode() {
let empty = r#"
{
"abi": [],
"bytecode": {
"object": "0x",
"linkReferences": {}
},
"deployedBytecode": {
"object": "0x",
"linkReferences": {}
}
}
"#;
let artifact: ConfigurableContractArtifact = serde_json::from_str(empty).unwrap();
let contract = artifact.into_contract_bytecode();
let bytecode: ContractBytecode = contract.into();
let bytecode = bytecode.unwrap();
assert!(!bytecode.bytecode.object.is_unlinked());
}
}