()
| 62 | |
| 63 | #[test] |
| 64 | fn test_string_error_optimization() -> eyre::Result<()> { |
| 65 | //test when base solidiy version is > than 0.8.4 |
| 66 | let file_contents = r#" |
| 67 | pragma solidity >=0.8.13; |
| 68 | |
| 69 | contract Contract0 { |
| 70 | function addressInternalBalance() public returns (uint256) { |
| 71 | |
| 72 | require(true, "some message"); |
| 73 | |
| 74 | require(true && a==b, "some message"); |
| 75 | require(true && a==b && b==c, "thing"); |
| 76 | |
| 77 | return address(this).balance; |
| 78 | } |
| 79 | } |
| 80 | "#; |
| 81 | |
| 82 | let mut source = MockSource::new().add_source("string_error.solx", file_contents); |
| 83 | let optimization_locations = StringError::find(&mut source.source); |
| 84 | |
| 85 | assert_eq!(optimization_locations.unwrap().len(), 3); |
| 86 | |
| 87 | //test when base solidiy version is < than 0.8.4 |
| 88 | let file_contents_1 = r#" |
| 89 | pragma solidity <= 0.8.3; |
| 90 | |
| 91 | contract Contract0 { |
| 92 | function addressInternalBalance() public returns (uint256) { |
| 93 | |
| 94 | require(true, "some message"); |
| 95 | |
| 96 | require(true && a==b, "some message"); |
| 97 | require(true && a==b && b==c, "thing"); |
| 98 | |
| 99 | return address(this).balance; |
| 100 | } |
| 101 | } |
| 102 | "#; |
| 103 | |
| 104 | source = MockSource::new().add_source("string_error_0.sol", file_contents_1); |
| 105 | |
| 106 | let optimization_locations_1 = StringError::find(&mut source.source)?; |
| 107 | |
| 108 | assert_eq!(optimization_locations_1.len(), 0); |
| 109 | |
| 110 | Ok(()) |
| 111 | } |
| 112 | } |
nothing calls this directly
no test coverage detected