Browse Source

Remove unnecessary .into_iter() and raw string (#1456)

These are clippies in the next rust version.

Signed-off-by: Sean Young <sean@mess.org>
Sean Young 2 years ago
parent
commit
1693d29efd

+ 2 - 2
src/bin/doc/mod.rs

@@ -396,7 +396,7 @@ pub fn generate_docs(outdir: &OsString, files: &[ast::Namespace], verbose: bool)
 
     reg.register_template_string(
         "soldoc",
-        r##"<!doctype html><head><title>soldoc</title><meta charset="utf-8"></head><body>
+        r#"<!doctype html><head><title>soldoc</title><meta charset="utf-8"></head><body>
 <h2>Contracts</h2>
 {{#each contracts}}
 <h3>{{ty}} {{name}}</h3>
@@ -470,7 +470,7 @@ Fields:<dl>
 {{#if author}}Author: {{author}}<p>{{/if}}
 Values: {{field}}
 {{/each}}
-</body></html>"##,
+</body></html>"#,
     )
     .expect("template should be good");
 

+ 1 - 1
src/codegen/statements.rs

@@ -891,7 +891,7 @@ fn returns(
     let cast_values = func
         .returns
         .iter()
-        .zip(uncast_values.into_iter())
+        .zip(uncast_values)
         .map(|(left, right)| try_load_and_cast(&right.loc(), &right, &left.ty, ns, cfg, vartab))
         .collect();
 

+ 2 - 2
src/sema/expression/tests.rs

@@ -6,12 +6,12 @@ use crate::sema::expression::strings::unescape;
 
 #[test]
 fn test_unescape() {
-    let s = r#"\u00f3"#;
+    let s = r"\u00f3";
     let mut vec = Diagnostics::default();
     let res = unescape(s, 0, 0, &mut vec);
     assert!(vec.is_empty());
     assert_eq!(res, vec![0xc3, 0xb3]);
-    let s = r#"\xff"#;
+    let s = r"\xff";
     let res = unescape(s, 0, 0, &mut vec);
     assert!(vec.is_empty());
     assert_eq!(res, vec![255]);

+ 1 - 1
src/sema/yul/tests/expression.rs

@@ -273,7 +273,7 @@ fn resolve_string_literal() {
         StringLiteral {
             loc,
             unicode: false,
-            string: r#"ab\xffa\u00e0g"#.to_string(),
+            string: r"ab\xffa\u00e0g".to_string(),
         },
         Some(Identifier {
             loc,

+ 6 - 9
tests/evm.rs

@@ -46,7 +46,7 @@ fn address() {
 #[test]
 fn try_catch() {
     let ns = test_solidity(
-        r##"
+        r#"
         contract b {
             int32 x;
 
@@ -85,7 +85,7 @@ fn try_catch() {
 
                 return state;
             }
-        }"##,
+        }"#,
     );
 
     assert!(!ns.diagnostics.any_errors());
@@ -179,13 +179,10 @@ fn ethereum_solidity_tests() {
             .join("testdata/solidity/test/libsolidity/semanticTests"),
     )
     .into_iter()
-    .chain(
-        WalkDir::new(
-            Path::new(env!("CARGO_MANIFEST_DIR"))
-                .join("testdata/solidity/test/libsolidity/syntaxTests"),
-        )
-        .into_iter(),
-    );
+    .chain(WalkDir::new(
+        Path::new(env!("CARGO_MANIFEST_DIR"))
+            .join("testdata/solidity/test/libsolidity/syntaxTests"),
+    ));
 
     let errors: usize = entries
         .par_bridge()

+ 2 - 2
tests/polkadot_tests/abi.rs

@@ -8,7 +8,7 @@ use std::sync::Mutex;
 
 /// Partially mimicking the ink! "mother" integration test.
 static MOTHER: Lazy<Mutex<(InkProject, InkProject)>> = Lazy::new(|| {
-    let src = r##"
+    let src = r#"
 import "polkadot";
 
 contract Mother {
@@ -32,7 +32,7 @@ contract Mother {
     function echo_auction(Auction _auction) public pure returns (Auction) {
         return _auction;
     }
-}"##;
+}"#;
 
     let solang_abi = load_abi(&build_wasm(src, false, false)[0].1);
     let ink_str = std::fs::read_to_string("testdata/ink/mother.json").unwrap();

+ 4 - 4
tests/polkadot_tests/arrays.rs

@@ -1459,7 +1459,7 @@ fn alloc_size_from_storage() {
 #[test]
 fn fixed_bytes() {
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract Storage {
             bytes32[] data;
             constructor() {
@@ -1470,7 +1470,7 @@ fn fixed_bytes() {
                 return(data[j][i]);
             }
         }
-        "##,
+        "#,
     );
 
     runtime.constructor(0, vec![]);
@@ -1484,7 +1484,7 @@ fn fixed_bytes() {
     }
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract Memory {
             constructor() {
             }
@@ -1495,7 +1495,7 @@ fn fixed_bytes() {
                 return(data[j][i]);
             }
         }
-        "##,
+        "#,
     );
 
     runtime.constructor(0, vec![]);

+ 26 - 26
tests/polkadot_tests/builtins.rs

@@ -7,7 +7,7 @@ use crate::build_solidity;
 #[test]
 fn abi_decode() {
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract bar {
             function test() public {
                 (int16 a, bool b) = abi.decode(hex"7f0001", (int16, bool));
@@ -15,20 +15,20 @@ fn abi_decode() {
                 assert(a == 127);
                 assert(b == true);
             }
-        }"##,
+        }"#,
     );
 
     runtime.function("test", Vec::new());
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract bar {
             function test() public {
                 uint8 a = abi.decode(hex"40", (uint8));
 
                 assert(a == 64);
             }
-        }"##,
+        }"#,
     );
 
     runtime.function("test", Vec::new());
@@ -37,7 +37,7 @@ fn abi_decode() {
 #[test]
 fn abi_encode() {
     let mut runtime = build_solidity(
-        r##"
+        r#"
         struct s {
             int32 f1;
             uint8 f2;
@@ -65,7 +65,7 @@ fn abi_encode() {
 
                 assert(abi.encode(x) == hex"ff010000f71874657374696504000500");
             }
-        }"##,
+        }"#,
     );
 
     runtime.function("test", Vec::new());
@@ -81,7 +81,7 @@ fn abi_encode() {
 #[test]
 fn abi_encode_packed() {
     let mut runtime = build_solidity(
-        r##"
+        r#"
         struct s {
             int32 f1;
             uint8 f2;
@@ -110,7 +110,7 @@ fn abi_encode_packed() {
 
                 assert(abi.encodePacked(x) == hex"ff010000f774657374696504000500");
             }
-        }"##,
+        }"#,
     );
 
     runtime.function("test", Vec::new());
@@ -123,7 +123,7 @@ fn abi_encode_packed() {
 #[test]
 fn abi_encode_with_selector() {
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract bar {
             function test1() public {
                 uint16 a = 0xfd01;
@@ -143,7 +143,7 @@ fn abi_encode_with_selector() {
 
                 assert(abi.encodeWithSelector(hex"01020304", arr) == hex"010203040cfefcf8");
             }
-        }"##,
+        }"#,
     );
 
     runtime.function("test1", Vec::new());
@@ -154,7 +154,7 @@ fn abi_encode_with_selector() {
 #[test]
 fn abi_encode_with_signature() {
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract bar {
             string bla = "Hello, World!";
 
@@ -174,7 +174,7 @@ fn abi_encode_with_signature() {
 
                 assert(abi.encodeWithSelector(hex"01020304", arr) == hex"010203040cfefcf8");
             }
-        }"##,
+        }"#,
     );
 
     runtime.constructor(0, Vec::new());
@@ -185,7 +185,7 @@ fn abi_encode_with_signature() {
 #[test]
 fn call() {
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract superior {
             function test1() public {
                 inferior i = new inferior();
@@ -228,7 +228,7 @@ fn call() {
             function test2(uint64 x) public returns (uint64) {
                 return x ^ 1;
             }
-        }"##,
+        }"#,
     );
 
     runtime.constructor(0, Vec::new());
@@ -236,7 +236,7 @@ fn call() {
     runtime.function("test2", Vec::new());
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract superior {
             function test1() public {
                 inferior i = new inferior();
@@ -287,7 +287,7 @@ fn call() {
             function test2(uint64 x) public returns (uint64) {
                 return x ^ 1;
             }
-        }"##,
+        }"#,
     );
 
     runtime.constructor(0, Vec::new());
@@ -430,7 +430,7 @@ fn data() {
     struct String(Vec<u8>);
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract bar {
             constructor(string memory s) public {
                 assert(msg.data == hex"98dd1bb318666f6f626172");
@@ -441,7 +441,7 @@ fn data() {
                 assert(msg.data == hex"e3cff634addeadde");
                 assert(msg.sig == hex"e3cf_f634");
             }
-        }"##,
+        }"#,
     );
 
     runtime.constructor(0, String(b"foobar".to_vec()).encode());
@@ -713,7 +713,7 @@ fn my_token() {
 #[test]
 fn hash() {
     let mut runtime = build_solidity(
-        r##"
+        r#"
         import "polkadot";
 
         contract Foo {
@@ -735,7 +735,7 @@ fn hash() {
                 assert(abi.encode(current2) == abi.encode(h));
             }
         }
-        "##,
+        "#,
     );
 
     #[derive(Encode)]
@@ -759,14 +759,14 @@ fn hash() {
 #[test]
 fn call_chain_extension() {
     let mut runtime = build_solidity(
-        r##"
+        r#"
         import {chain_extension as ChainExtension} from "polkadot";
 
         contract Foo {
             function chain_extension(bytes input) public returns (uint32, bytes) {
                 return ChainExtension(123, input);
             }
-        }"##,
+        }"#,
     );
 
     let data = 0xdeadbeefu32.to_be_bytes().to_vec();
@@ -779,13 +779,13 @@ fn call_chain_extension() {
 #[test]
 fn is_contract() {
     let mut runtime = build_solidity(
-        r##"
+        r#"
         import "polkadot";
         contract Foo {
             function test(address _a) public view returns (bool) {
                 return is_contract(_a);
             }
-        }"##,
+        }"#,
     );
 
     runtime.function("test", runtime.0.data().accounts[0].address.to_vec());
@@ -798,7 +798,7 @@ fn is_contract() {
 #[test]
 fn set_code_hash() {
     let mut runtime = build_solidity(
-        r##"
+        r#"
         import "polkadot";
 
         abstract contract SetCode {
@@ -821,7 +821,7 @@ fn set_code_hash() {
             function inc() external {
                 count -= 1;
             }
-        }"##,
+        }"#,
     );
 
     runtime.function("inc", vec![]);

+ 32 - 32
tests/polkadot_tests/calls.rs

@@ -9,7 +9,7 @@ struct RevertReturn(u32, String);
 #[test]
 fn revert() {
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract bar {
             function test() public {
                 revert("yo!");
@@ -30,7 +30,7 @@ fn revert() {
             function d() public {
                 revert("revert value has to be passed down the stack");
             }
-        }"##,
+        }"#,
     );
 
     runtime.function_expect_failure("test", Vec::new());
@@ -62,7 +62,7 @@ fn revert() {
 #[test]
 fn require() {
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract c {
             function test1() public {
                 require(false, "Program testing can be used to show the presence of bugs, but never to show their absence!");
@@ -71,7 +71,7 @@ fn require() {
             function test2() public {
                 require(true, "Program testing can be used to show the presence of bugs, but never to show their absence!");
             }
-        }"##,
+        }"#,
     );
 
     runtime.function_expect_failure("test1", Vec::new());
@@ -194,7 +194,7 @@ fn try_catch_external_calls() {
     runtime.function("test", Vec::new());
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract c {
             function test() public {
                 other o = new other();
@@ -214,14 +214,14 @@ fn try_catch_external_calls() {
                 revert("foo");
             }
         }
-        "##,
+        "#,
     );
 
     runtime.constructor(0, Vec::new());
     runtime.function("test", Vec::new());
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract c {
             function test() public {
                 other o = new other();
@@ -271,7 +271,7 @@ fn try_catch_external_calls() {
                 }
             }
         }
-        "##,
+        "#,
     );
 
     runtime.constructor(0, Vec::new());
@@ -283,7 +283,7 @@ fn try_catch_external_calls() {
     struct Ret(u32);
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract dominator {
             child c;
 
@@ -330,7 +330,7 @@ fn try_catch_external_calls() {
             function go_bang() public pure returns (int32) {
                 revert("gone bang in child");
             }
-        }"##,
+        }"#,
     );
 
     runtime.constructor(0, Vec::new());
@@ -345,7 +345,7 @@ fn try_catch_external_calls_dont_decode_returns() {
     // try not using the return values of test() - revert case
     // note the absense of "try o.test() returns (int32 y, bool) {"
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract c {
             function test() public returns (int32 x) {
                 other o = new other();
@@ -362,7 +362,7 @@ fn try_catch_external_calls_dont_decode_returns() {
                 revert("foo");
             }
         }
-        "##,
+        "#,
     );
 
     runtime.constructor(0, Vec::new());
@@ -456,7 +456,7 @@ fn try_catch_constructor() {
     runtime.function("test", Vec::new());
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract c {
             function test() public {
                 int32 x = 0;
@@ -478,7 +478,7 @@ fn try_catch_constructor() {
 
             function _ext() public {}
         }
-        "##,
+        "#,
     );
 
     runtime.constructor(0, Vec::new());
@@ -488,7 +488,7 @@ fn try_catch_constructor() {
 #[test]
 fn local_destructure_call() {
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract c {
             function test() public {
                 (, bytes32 b, string s) = foo();
@@ -501,7 +501,7 @@ fn local_destructure_call() {
                 return (true, "0123", "abcd");
             }
         }
-        "##,
+        "#,
     );
 
     runtime.function("test", Vec::new());
@@ -687,20 +687,20 @@ fn payable_functions() {
 #[test]
 fn hash_tests() {
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract tester {
             function test() public {
                 bytes32 hash = keccak256("Hello, World!");
 
                 assert(hash == hex"acaf3289d7b601cbd114fb36c4d29c85bbfd5e133f14cb355c3fd8d99367964f");
             }
-        }"##,
+        }"#,
     );
 
     runtime.function("test", Vec::new());
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract tester {
             function test() public {
                 bytes memory s = "Hello, World!";
@@ -708,13 +708,13 @@ fn hash_tests() {
 
                 assert(hash == hex"acaf3289d7b601cbd114fb36c4d29c85bbfd5e133f14cb355c3fd8d99367964f");
             }
-        }"##,
+        }"#,
     );
 
     runtime.function("test", Vec::new());
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract tester {
             bytes s = "Hello, World!";
 
@@ -723,60 +723,60 @@ fn hash_tests() {
 
                 assert(hash == hex"acaf3289d7b601cbd114fb36c4d29c85bbfd5e133f14cb355c3fd8d99367964f");
             }
-        }"##,
+        }"#,
     );
 
     runtime.constructor(0, Vec::new());
     runtime.function("test", Vec::new());
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract tester {
             function test() public {
                 bytes32 hash = sha256("Hello, World!");
 
                 assert(hash == hex"dffd6021bb2bd5b0af676290809ec3a53191dd81c7f70a4b28688a362182986f");
             }
-        }"##,
+        }"#,
     );
 
     runtime.function("test", Vec::new());
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract tester {
             function test() public {
                 bytes32 hash = blake2_256("Hello, World!");
 
                 assert(hash == hex"511bc81dde11180838c562c82bb35f3223f46061ebde4a955c27b3f489cf1e03");
             }
-        }"##,
+        }"#,
     );
 
     runtime.function("test", Vec::new());
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract tester {
             function test() public {
                 bytes16 hash = blake2_128("Hello, World!");
 
                 assert(hash == hex"3895c59e4aeb0903396b5be3fbec69fe");
             }
-        }"##,
+        }"#,
     );
 
     runtime.function("test", Vec::new());
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract tester {
             function test() public {
                 bytes20 hash = ripemd160("Hello, World!");
 
                 assert(hash == hex"527a6a4b9a6da75607546842e0e00105350b1aaf");
             }
-        }"##,
+        }"#,
     );
 
     runtime.function("test", Vec::new());
@@ -838,7 +838,7 @@ fn try_catch_reachable() {
 #[test]
 fn log_api_call_return_values_works() {
     let mut runtime = build_solidity_with_options(
-        r##"
+        r#"
         contract Test {
             constructor () payable {}
 
@@ -854,7 +854,7 @@ fn log_api_call_return_values_works() {
                 print("hi!");
             }
         }
-        "##,
+        "#,
         true,
         false,
     );

+ 8 - 8
tests/polkadot_tests/contracts.rs

@@ -44,7 +44,7 @@ fn external_call() {
 #[test]
 fn revert_external_call() {
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract c {
             b x;
             constructor() public {
@@ -63,7 +63,7 @@ fn revert_external_call() {
             function get_x(int32 t) public returns (int32) {
                 revert("The reason why");
             }
-        }"##,
+        }"#,
     );
 
     runtime.constructor(0, Vec::new());
@@ -74,7 +74,7 @@ fn revert_external_call() {
 #[test]
 fn revert_constructor() {
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract c {
             b x;
             constructor() public {
@@ -95,7 +95,7 @@ fn revert_constructor() {
             function get_x(int32 t) public returns (int32) {
                 return x * t;
             }
-        }"##,
+        }"#,
     );
 
     runtime.constructor(0, Vec::new());
@@ -108,7 +108,7 @@ fn external_datatypes() {
     struct Ret(u64);
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract c {
             b x;
             constructor() public {
@@ -144,7 +144,7 @@ fn external_datatypes() {
             bytes4 f1;
             address f2;
             int f3;
-        }"##,
+        }"#,
     );
 
     runtime.constructor(0, Vec::new());
@@ -191,7 +191,7 @@ fn creation_code() {
 #[test]
 fn issue666() {
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract Flipper {
             function flip () pure public {
                 print("flip");
@@ -208,7 +208,7 @@ fn issue666() {
             function superFlip () pure public {
                 _flipper.flip();
             }
-        }"##,
+        }"#,
     );
 
     runtime.constructor(0, Vec::new());

+ 2 - 2
tests/polkadot_tests/events.rs

@@ -50,7 +50,7 @@ fn emit() {
     }
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract a {
             event foo(bool,uint32,int64 indexed i);
             event bar(uint32,uint64,string indexed s);
@@ -58,7 +58,7 @@ fn emit() {
                 emit foo(true, 102, 1);
                 emit bar(0xdeadcafe, 102, "foobar");
             }
-        }"##,
+        }"#,
     );
 
     runtime.constructor(0, Vec::new());

+ 25 - 59
tests/polkadot_tests/expressions.rs

@@ -824,11 +824,7 @@ fn power() {
     );
 
     // 4**5 = 1024
-    let args = Val(4)
-        .encode()
-        .into_iter()
-        .chain(Val(5).encode().into_iter())
-        .collect();
+    let args = Val(4).encode().into_iter().chain(Val(5).encode()).collect();
 
     runtime.function("power", args);
 
@@ -838,7 +834,7 @@ fn power() {
     let args = Val(2345)
         .encode()
         .into_iter()
-        .chain(Val(1).encode().into_iter())
+        .chain(Val(1).encode())
         .collect();
 
     runtime.function("power", args);
@@ -849,7 +845,7 @@ fn power() {
     let args = Val(0xdead_beef)
         .encode()
         .into_iter()
-        .chain(Val(0).encode().into_iter())
+        .chain(Val(0).encode())
         .collect();
 
     runtime.function("power", args);
@@ -860,7 +856,7 @@ fn power() {
     let args = Val(0)
         .encode()
         .into_iter()
-        .chain(Val(0xdead_beef).encode().into_iter())
+        .chain(Val(0xdead_beef).encode())
         .collect();
 
     runtime.function("power", args);
@@ -888,11 +884,7 @@ fn large_power() {
     );
 
     // 4**5 = 1024
-    let args = Val(4)
-        .encode()
-        .into_iter()
-        .chain(Val(5).encode().into_iter())
-        .collect();
+    let args = Val(4).encode().into_iter().chain(Val(5).encode()).collect();
 
     runtime.function("power", args);
 
@@ -902,7 +894,7 @@ fn large_power() {
     let args = Val(2345)
         .encode()
         .into_iter()
-        .chain(Val(1).encode().into_iter())
+        .chain(Val(1).encode())
         .collect();
 
     runtime.function("power", args);
@@ -913,7 +905,7 @@ fn large_power() {
     let args = Val(0xdeadbeef)
         .encode()
         .into_iter()
-        .chain(Val(0).encode().into_iter())
+        .chain(Val(0).encode())
         .collect();
 
     runtime.function("power", args);
@@ -924,7 +916,7 @@ fn large_power() {
     let args = Val(0)
         .encode()
         .into_iter()
-        .chain(Val(0xdeadbeef).encode().into_iter())
+        .chain(Val(0xdeadbeef).encode())
         .collect();
 
     runtime.function("power", args);
@@ -935,7 +927,7 @@ fn large_power() {
     let args = Val(10)
         .encode()
         .into_iter()
-        .chain(Val(36).encode().into_iter())
+        .chain(Val(36).encode())
         .collect();
 
     runtime.function("power", args);
@@ -972,11 +964,7 @@ fn test_power_overflow_boundaries() {
 
         contract.function(
             "pow",
-            base_data
-                .clone()
-                .into_iter()
-                .chain(exp_data.into_iter())
-                .collect(),
+            base_data.clone().into_iter().chain(exp_data).collect(),
         );
 
         let res = BigUint::from(2_usize).pow((width - 1).try_into().unwrap());
@@ -989,10 +977,7 @@ fn test_power_overflow_boundaries() {
         let mut exp_data = exp.to_bytes_le();
         exp_data.resize(width_rounded, 0);
 
-        contract.function_expect_failure(
-            "pow",
-            base_data.into_iter().chain(exp_data.into_iter()).collect(),
-        );
+        contract.function_expect_failure("pow", base_data.into_iter().chain(exp_data).collect());
     }
 }
 
@@ -1038,10 +1023,7 @@ fn multiply() {
 
         println!("in: a:{a_data:?} b:{b_data:?}");
 
-        runtime.function(
-            "multiply",
-            a_data.into_iter().chain(b_data.into_iter()).collect(),
-        );
+        runtime.function("multiply", a_data.into_iter().chain(b_data).collect());
 
         println!("out: res:{:?}", runtime.output());
 
@@ -1079,7 +1061,7 @@ fn test_mul_within_range_signed() {
         let a_sign = a.sign();
         let mut a_data = a.to_signed_bytes_le();
 
-        let side = vec![-1, 0, 1];
+        let side = [-1, 0, 1];
         let b = BigInt::from(*side.choose(&mut rng).unwrap());
         let b_sign = b.sign();
         let mut b_data = b.to_signed_bytes_le();
@@ -1087,10 +1069,7 @@ fn test_mul_within_range_signed() {
         a_data.resize(width_rounded, sign_extend(a_sign));
         b_data.resize(width_rounded, sign_extend(b_sign));
 
-        runtime.function(
-            "mul",
-            a_data.into_iter().chain(b_data.into_iter()).collect(),
-        );
+        runtime.function("mul", a_data.into_iter().chain(b_data).collect());
 
         let value = a * b;
         let value_sign = value.sign();
@@ -1128,10 +1107,7 @@ fn test_mul_within_range() {
         a_data.resize(width_rounded, 0);
         b_data.resize(width_rounded, 0);
 
-        runtime.function(
-            "mul",
-            a_data.into_iter().chain(b_data.into_iter()).collect(),
-        );
+        runtime.function("mul", a_data.into_iter().chain(b_data).collect());
 
         let value = a * b;
 
@@ -1176,7 +1152,7 @@ fn test_overflow_boundaries() {
             up_data
                 .clone()
                 .into_iter()
-                .chain(sec_data.clone().into_iter())
+                .chain(sec_data.clone())
                 .collect(),
         );
 
@@ -1191,7 +1167,7 @@ fn test_overflow_boundaries() {
             low_data
                 .clone()
                 .into_iter()
-                .chain(sec_data.clone().into_iter())
+                .chain(sec_data.clone())
                 .collect(),
         );
 
@@ -1224,7 +1200,7 @@ fn test_overflow_boundaries() {
             upper_second_op_data
                 .clone()
                 .into_iter()
-                .chain(two_data.clone().into_iter())
+                .chain(two_data.clone())
                 .collect(),
         );
 
@@ -1234,18 +1210,14 @@ fn test_overflow_boundaries() {
             lower_second_op_data
                 .clone()
                 .into_iter()
-                .chain(two_data.clone().into_iter())
+                .chain(two_data.clone())
                 .collect(),
         );
 
         // Upper boundary * Upper boundary
         contract.function_expect_failure(
             "mul",
-            up_data
-                .clone()
-                .into_iter()
-                .chain(up_data.clone().into_iter())
-                .collect(),
+            up_data.clone().into_iter().chain(up_data.clone()).collect(),
         );
 
         // Lower boundary * Lower boundary
@@ -1254,7 +1226,7 @@ fn test_overflow_boundaries() {
             low_data
                 .clone()
                 .into_iter()
-                .chain(low_data.clone().into_iter())
+                .chain(low_data.clone())
                 .collect(),
         );
 
@@ -1264,7 +1236,7 @@ fn test_overflow_boundaries() {
             low_data
                 .clone()
                 .into_iter()
-                .chain(up_data.clone().into_iter())
+                .chain(up_data.clone())
                 .collect(),
         );
     }
@@ -1307,7 +1279,7 @@ fn test_overflow_detect_signed() {
             "mul",
             first_op_data
                 .into_iter()
-                .chain(second_op_data.clone().into_iter())
+                .chain(second_op_data.clone())
                 .collect(),
         );
 
@@ -1324,10 +1296,7 @@ fn test_overflow_detect_signed() {
 
         contract.function_expect_failure(
             "mul",
-            first_op_data
-                .into_iter()
-                .chain(second_op_data.into_iter())
-                .collect(),
+            first_op_data.into_iter().chain(second_op_data).collect(),
         );
     }
 }
@@ -1365,10 +1334,7 @@ fn test_overflow_detect_unsigned() {
 
         contract.function_expect_failure(
             "mul",
-            first_op_data
-                .into_iter()
-                .chain(second_op_data.into_iter())
-                .collect(),
+            first_op_data.into_iter().chain(second_op_data).collect(),
         );
     }
 }

+ 20 - 20
tests/polkadot_tests/format.rs

@@ -6,12 +6,12 @@ use parity_scale_codec::Encode;
 #[test]
 fn output() {
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract format {
             function foo(bool x) public {
                 print("val:{}".format(x));
             }
-        }"##,
+        }"#,
     );
 
     runtime.constructor(0, Vec::new());
@@ -27,12 +27,12 @@ fn output() {
     assert_eq!(runtime.debug_buffer(), "print: val:false,\n");
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract format {
             function foo(bytes bar) public {
                 print("bar:{}".format(bar));
             }
-        }"##,
+        }"#,
     );
 
     runtime.constructor(0, Vec::new());
@@ -42,12 +42,12 @@ fn output() {
     assert_eq!(runtime.debug_buffer(), "print: bar:41424344,\n");
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract format {
             function foo(bytes5 bar) public {
                 print("bar:{}".format(bar));
             }
-        }"##,
+        }"#,
     );
 
     runtime.constructor(0, Vec::new());
@@ -57,12 +57,12 @@ fn output() {
     assert_eq!(runtime.debug_buffer(), "print: bar:0103fe0709,\n");
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract format {
             function foo(string bar) public {
                 print("bar:{} address:{}".format(bar, this));
             }
-        }"##,
+        }"#,
     );
 
     runtime.constructor(0, Vec::new());
@@ -78,12 +78,12 @@ fn output() {
     );
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract format {
             function foo(uint64 bar) public {
                 print("bar:{:x}".format(bar));
             }
-        }"##,
+        }"#,
     );
 
     runtime.constructor(0, Vec::new());
@@ -105,12 +105,12 @@ fn output() {
     assert_eq!(runtime.debug_buffer(), "print: bar:0x0,\n");
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract format {
             function foo(int128 bar) public {
                 print("bar:{:x}".format(bar));
             }
-        }"##,
+        }"#,
     );
 
     runtime.constructor(0, Vec::new());
@@ -123,12 +123,12 @@ fn output() {
     );
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract format {
             function foo(int128 bar) public {
                 print("there is an old android joke which goes {:b} ".format(bar));
             }
-        }"##,
+        }"#,
     );
 
     runtime.constructor(0, Vec::new());
@@ -140,12 +140,12 @@ fn output() {
     assert!(runtime.debug_buffer().contains("goes -0b111111 ,"));
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract format {
             function foo(int64 bar) public {
                 print("number:{} ".format(bar));
             }
-        }"##,
+        }"#,
     );
 
     runtime.constructor(0, Vec::new());
@@ -157,12 +157,12 @@ fn output() {
     assert!(runtime.debug_buffer().contains("print: number:-102 ,"));
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract format {
             function foo(int128 bar) public {
                 print("number:{} ".format(bar));
             }
-        }"##,
+        }"#,
     );
 
     runtime.constructor(0, Vec::new());
@@ -197,7 +197,7 @@ fn output() {
     runtime.debug_buffer().truncate(0);
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract format {
             enum enum1 { bar1, bar2, bar3 }
             function foo(int256 bar) public {
@@ -212,7 +212,7 @@ fn output() {
             function e() public returns (string) {
                 return "number<{}>".format(enum1.bar3);
             }
-        }"##,
+        }"#,
     );
 
     runtime.constructor(0, Vec::new());

+ 4 - 4
tests/polkadot_tests/function_types.rs

@@ -203,7 +203,7 @@ fn virtual_contract_function() {
 #[test]
 fn ext() {
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract ft {
             function test() public {
                 function(int32) external returns (bool) func = this.foo;
@@ -215,7 +215,7 @@ fn ext() {
             function foo(int32) public returns (bool) {
                 return false;
             }
-        }"##,
+        }"#,
     );
 
     runtime.function("test", Vec::new());
@@ -335,7 +335,7 @@ fn ext() {
 #[test]
 fn encode_decode_ext_func() {
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract A {
             @selector([0,0,0,0])
             function a() public pure returns (uint8) {
@@ -362,7 +362,7 @@ fn encode_decode_ext_func() {
                 return dec2{flags: 8}();
             }
         }
-        "##,
+        "#,
     );
 
     runtime.function("it", vec![]);

+ 4 - 4
tests/polkadot_tests/mappings.rs

@@ -9,7 +9,7 @@ use crate::build_solidity;
 #[test]
 fn basic() {
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract c {
             mapping(uint => bytes4) data;
 
@@ -19,7 +19,7 @@ fn basic() {
                 assert(data[1] == hex"cafedead");
             }
         }
-        "##,
+        "#,
     );
 
     runtime.function("test", Vec::new());
@@ -206,7 +206,7 @@ fn test_user() {
     struct GetRet(bool, [u8; 32]);
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract b {
             struct user {
                 bool exists;
@@ -238,7 +238,7 @@ fn test_user() {
 
                 return (s.exists, s.addr);
             }
-        }"##,
+        }"#,
     );
 
     let mut rng = rand::thread_rng();

+ 4 - 4
tests/polkadot_tests/modifier.rs

@@ -268,7 +268,7 @@ fn return_values() {
     assert_eq!(runtime.output(), Val(5).encode());
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         struct S {
             int64 f1;
             string f2;
@@ -288,7 +288,7 @@ fn return_values() {
                     _;
                     s2 += 2;
             }
-        }"##,
+        }"#,
     );
 
     runtime.constructor(0, Vec::new());
@@ -307,7 +307,7 @@ fn return_values() {
 #[test]
 fn repeated_modifier() {
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract Test {
             modifier notZero(uint64 num) {
                 require(num != 0, "invalid number");
@@ -317,7 +317,7 @@ fn repeated_modifier() {
             function contfunc(uint64 num1, uint64 num2) public notZero(num1) notZero(num2) {
                 // any code
             }
-        }"##,
+        }"#,
     );
 
     runtime.constructor(0, Vec::new());

+ 6 - 6
tests/polkadot_tests/primitives.rs

@@ -99,7 +99,7 @@ fn bytes() {
 
     // parse
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract test {
             function const3() public returns (bytes3) {
                 return hex"112233";
@@ -142,7 +142,7 @@ fn bytes() {
                     hex"00d4f4fc2f5752f06faf7ece82edbdcd093e8ee1144d482ea5820899b3520315"
                 );
             }
-        }"##,
+        }"#,
     );
 
     runtime.function("const3", Vec::new());
@@ -225,7 +225,7 @@ fn address() {
 fn type_name() {
     // parse
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract test {
             function foo() public returns (uint32) {
                 assert(type(foobar).name == "foobar");
@@ -239,7 +239,7 @@ fn type_name() {
 
         abstract contract foobar {
             int32 a;
-        }"##,
+        }"#,
     );
 
     runtime.function("foo", Vec::new());
@@ -315,7 +315,7 @@ fn units() {
 fn literal_bytes_cast() {
     // parse
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract test {
             function foo() public {
                 bytes4 x = bytes4(hex"acaf3289d7b601cbd114fb36c4d29c85bbfd5e133f14cb355c3fd8d99367964f");
@@ -327,7 +327,7 @@ fn literal_bytes_cast() {
 
                 assert(bytes4(x) == hex"acaf_3289");
             }
-        }"##,
+        }"#,
     );
 
     runtime.function("foo", Vec::new());

File diff suppressed because it is too large
+ 39 - 39
tests/polkadot_tests/strings.rs


+ 20 - 20
tests/polkadot_tests/structs.rs

@@ -14,7 +14,7 @@ struct Val8(u8);
 #[test]
 fn struct_members() {
     let mut runtime = build_solidity(
-        r##"
+        r#"
         pragma solidity 0;
         pragma experimental ABIEncoderV2;
 
@@ -47,7 +47,7 @@ fn struct_members() {
                         assert(f3.y == 102);
                         assert(f3.d == hex"00dead");
                     }
-        }"##,
+        }"#,
     );
 
     runtime.function("test", Vec::new());
@@ -99,7 +99,7 @@ fn structs_encode() {
     }
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract test_struct_parsing {
             struct foo {
                 bytes3 f1;
@@ -110,7 +110,7 @@ fn structs_encode() {
                 assert(f.f1 == "ABC");
                 assert(f.f2 == true);
             }
-        }"##,
+        }"#,
     );
 
     runtime.function(
@@ -132,7 +132,7 @@ fn structs_decode() {
     }
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract test_struct_parsing {
             struct foo {
                 bytes3 f1;
@@ -147,7 +147,7 @@ fn structs_decode() {
 
                 return f;
             }
-        }"##,
+        }"#,
     );
 
     runtime.function("test", Vec::new());
@@ -166,7 +166,7 @@ fn structs_decode() {
     // the allocation and also that the abi encoder can
     // an struct when the pointer is still null
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract test_struct_parsing {
             struct foo {
                 bytes3 f1;
@@ -181,7 +181,7 @@ fn structs_decode() {
 
                 return f;
             }
-        }"##,
+        }"#,
     );
 
     runtime.constructor(0, Vec::new());
@@ -263,7 +263,7 @@ fn structs_decode() {
 #[test]
 fn struct_in_struct() {
     let mut runtime = build_solidity(
-        r##"
+        r#"
         pragma solidity 0;
 
         contract struct_in_struct {
@@ -288,7 +288,7 @@ fn struct_in_struct() {
 
                 return f.b;
             }
-        }"##,
+        }"#,
     );
 
     runtime.function("test", Vec::new());
@@ -309,7 +309,7 @@ fn structs_in_structs_decode() {
     }
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract test_struct_parsing {
             struct foo {
                 bytes3 f1;
@@ -327,7 +327,7 @@ fn structs_in_structs_decode() {
 
                 return f;
             }
-        }"##,
+        }"#,
     );
 
     runtime.function("test", Vec::new());
@@ -364,7 +364,7 @@ fn structs_in_structs_encode() {
     }
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract test_struct_parsing {
             struct foo {
                 bytes3 f1;
@@ -383,7 +383,7 @@ fn structs_in_structs_encode() {
                 test_struct_parsing.foo b;
                 test_struct_parsing.foo c;
             }
-        }"##,
+        }"#,
     );
 
     runtime.function(
@@ -406,7 +406,7 @@ fn structs_in_structs_encode() {
 #[test]
 fn struct_storage_to_memory() {
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract test_struct_parsing {
             struct foo {
                 bytes3 f1;
@@ -425,7 +425,7 @@ fn struct_storage_to_memory() {
                 assert(f.f1 == hex"123456");
                 assert(f.f2 == 81985529216486895);
             }
-        }"##,
+        }"#,
     );
 
     runtime.constructor(0, Vec::new());
@@ -442,7 +442,7 @@ fn return_from_struct_storage() {
     }
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         struct foo {
             bytes3 f1;
             uint32 f2;
@@ -458,7 +458,7 @@ fn return_from_struct_storage() {
             function test() public returns (foo) {
                 return bar;
             }
-        }"##,
+        }"#,
     );
 
     runtime.constructor(0, Vec::new());
@@ -600,7 +600,7 @@ fn encode_decode_bytes_in_field() {
     struct Foo([u8; 4]);
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract encode_decode_bytes_in_field {
             struct foo { bytes4 f1; }
             function test() public pure returns(foo) {
@@ -608,7 +608,7 @@ fn encode_decode_bytes_in_field() {
                 assert(abi.encode(f) == hex"41424344");
                 return f;
             }
-        }"##,
+        }"#,
     );
 
     runtime.function("test", vec![]);

+ 4 - 4
tests/polkadot_tests/value.rs

@@ -196,7 +196,7 @@ fn constructor_salt() {
     runtime.function("step1", Vec::new());
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract b {
             function step1() public {
                 a f = new a{salt: hex"01"}();
@@ -206,7 +206,7 @@ fn constructor_salt() {
         contract a {
             function test(int32 l) public payable {
             }
-        }"##,
+        }"#,
     );
     runtime.constructor(0, Vec::new());
 
@@ -214,7 +214,7 @@ fn constructor_salt() {
 
     // we can instantiate the same contract if we provide a different contract
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract b {
             function step1() public {
                 a f = new a{salt: hex"01"}();
@@ -225,7 +225,7 @@ fn constructor_salt() {
         contract a {
             function test(int32 l) public payable {
             }
-        }"##,
+        }"#,
     );
     runtime.constructor(0, Vec::new());
 

+ 4 - 4
tests/polkadot_tests/variables.rs

@@ -21,13 +21,13 @@ fn global_constants() {
     runtime.function("test", Vec::new());
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         string constant foo = "FOO";
         contract error {
             function test() public payable {
                 assert(foo == "FOO");
             }
-        }"##,
+        }"#,
     );
 
     runtime.constructor(0, Vec::new());
@@ -35,14 +35,14 @@ fn global_constants() {
     runtime.function("test", Vec::new());
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         string constant foo = "FOO";
         contract a {
             function test(uint64 error) public payable {
                 assert(error == 0);
                 assert(foo == "FOO");
             }
-        }"##,
+        }"#,
     );
 
     runtime.constructor(0, Vec::new());

+ 6 - 6
tests/solana_tests/hash.rs

@@ -5,42 +5,42 @@ use crate::{build_solidity, BorshToken};
 #[test]
 fn constants_hash_tests() {
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract tester {
             function test() public {
                 bytes32 hash = keccak256("Hello, World!");
 
                 assert(hash == hex"acaf3289d7b601cbd114fb36c4d29c85bbfd5e133f14cb355c3fd8d99367964f");
             }
-        }"##,
+        }"#,
     );
 
     runtime.constructor(&[]);
     runtime.function("test", &[]);
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract tester {
             function test() public {
                 bytes32 hash = sha256("Hello, World!");
 
                 assert(hash == hex"dffd6021bb2bd5b0af676290809ec3a53191dd81c7f70a4b28688a362182986f");
             }
-        }"##,
+        }"#,
     );
 
     runtime.constructor(&[]);
     runtime.function("test", &[]);
 
     let mut runtime = build_solidity(
-        r##"
+        r#"
         contract tester {
             function test() public {
                 bytes20 hash = ripemd160("Hello, World!");
 
                 assert(hash == hex"527a6a4b9a6da75607546842e0e00105350b1aaf");
             }
-        }"##,
+        }"#,
     );
 
     runtime.constructor(&[]);

+ 1 - 1
tests/solana_tests/primitives.rs

@@ -1005,7 +1005,7 @@ fn test_mul_within_range_signed() {
         let first_operand_rand = rng.gen_bigint(width - 1).sub(1_u32);
         println!("First op : {first_operand_rand:?}");
 
-        let side = vec![-1, 0, 1];
+        let side = [-1, 0, 1];
         // -1, 1 or 0
         let second_op = BigInt::from(*side.choose(&mut rng).unwrap());
         println!("second op : {second_op:?}");

Some files were not shown because too many files changed in this diff