From 1693d29efdbb6e81ec34b65e2c7fcba6abee9027 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Tue, 25 Jul 2023 12:55:47 +0200 Subject: [PATCH] Remove unnecessary .into_iter() and raw string (#1456) These are clippies in the next rust version. Signed-off-by: Sean Young --- src/bin/doc/mod.rs | 4 +- src/codegen/statements.rs | 2 +- src/sema/expression/tests.rs | 4 +- src/sema/yul/tests/expression.rs | 2 +- tests/evm.rs | 15 ++--- tests/polkadot_tests/abi.rs | 4 +- tests/polkadot_tests/arrays.rs | 8 +-- tests/polkadot_tests/builtins.rs | 52 ++++++++-------- tests/polkadot_tests/calls.rs | 64 ++++++++++---------- tests/polkadot_tests/contracts.rs | 16 ++--- tests/polkadot_tests/events.rs | 4 +- tests/polkadot_tests/expressions.rs | 84 ++++++++------------------ tests/polkadot_tests/format.rs | 40 ++++++------ tests/polkadot_tests/function_types.rs | 8 +-- tests/polkadot_tests/mappings.rs | 8 +-- tests/polkadot_tests/modifier.rs | 8 +-- tests/polkadot_tests/primitives.rs | 12 ++-- tests/polkadot_tests/strings.rs | 84 +++++++++++++------------- tests/polkadot_tests/structs.rs | 40 ++++++------ tests/polkadot_tests/value.rs | 8 +-- tests/polkadot_tests/variables.rs | 8 +-- tests/solana_tests/hash.rs | 12 ++-- tests/solana_tests/primitives.rs | 2 +- 23 files changed, 226 insertions(+), 263 deletions(-) diff --git a/src/bin/doc/mod.rs b/src/bin/doc/mod.rs index 4b2b6fe2f..8938283c0 100644 --- a/src/bin/doc/mod.rs +++ b/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##"soldoc + r#"soldoc

Contracts

{{#each contracts}}

{{ty}} {{name}}

@@ -470,7 +470,7 @@ Fields:
{{#if author}}Author: {{author}}

{{/if}} Values: {{field}} {{/each}} -"##, +"#, ) .expect("template should be good"); diff --git a/src/codegen/statements.rs b/src/codegen/statements.rs index 6b49d9e0b..0ba2702d4 100644 --- a/src/codegen/statements.rs +++ b/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(); diff --git a/src/sema/expression/tests.rs b/src/sema/expression/tests.rs index 514c6c008..430e61414 100644 --- a/src/sema/expression/tests.rs +++ b/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]); diff --git a/src/sema/yul/tests/expression.rs b/src/sema/yul/tests/expression.rs index d443d75e0..f1bef9432 100644 --- a/src/sema/yul/tests/expression.rs +++ b/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, diff --git a/tests/evm.rs b/tests/evm.rs index cc2dd9734..6af45afbf 100644 --- a/tests/evm.rs +++ b/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() diff --git a/tests/polkadot_tests/abi.rs b/tests/polkadot_tests/abi.rs index 7c9dfddb6..6369cfa66 100644 --- a/tests/polkadot_tests/abi.rs +++ b/tests/polkadot_tests/abi.rs @@ -8,7 +8,7 @@ use std::sync::Mutex; /// Partially mimicking the ink! "mother" integration test. static MOTHER: Lazy> = 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(); diff --git a/tests/polkadot_tests/arrays.rs b/tests/polkadot_tests/arrays.rs index 3cf943c7d..d589b2aa2 100644 --- a/tests/polkadot_tests/arrays.rs +++ b/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![]); diff --git a/tests/polkadot_tests/builtins.rs b/tests/polkadot_tests/builtins.rs index db5c14023..7b01c6f61 100644 --- a/tests/polkadot_tests/builtins.rs +++ b/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); 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![]); diff --git a/tests/polkadot_tests/calls.rs b/tests/polkadot_tests/calls.rs index 334a1a2f1..6d411441c 100644 --- a/tests/polkadot_tests/calls.rs +++ b/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, ); diff --git a/tests/polkadot_tests/contracts.rs b/tests/polkadot_tests/contracts.rs index 03f56499c..eb0bd3281 100644 --- a/tests/polkadot_tests/contracts.rs +++ b/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()); diff --git a/tests/polkadot_tests/events.rs b/tests/polkadot_tests/events.rs index adbf6ced0..a961f2d80 100644 --- a/tests/polkadot_tests/events.rs +++ b/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()); diff --git a/tests/polkadot_tests/expressions.rs b/tests/polkadot_tests/expressions.rs index 6eeeb057a..d8f23e67c 100644 --- a/tests/polkadot_tests/expressions.rs +++ b/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(), ); } } diff --git a/tests/polkadot_tests/format.rs b/tests/polkadot_tests/format.rs index ff588c510..22f88f3c3 100644 --- a/tests/polkadot_tests/format.rs +++ b/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()); diff --git a/tests/polkadot_tests/function_types.rs b/tests/polkadot_tests/function_types.rs index c8bf86ffb..b3e4f02b5 100644 --- a/tests/polkadot_tests/function_types.rs +++ b/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![]); diff --git a/tests/polkadot_tests/mappings.rs b/tests/polkadot_tests/mappings.rs index b330879cd..43a5abda9 100644 --- a/tests/polkadot_tests/mappings.rs +++ b/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(); diff --git a/tests/polkadot_tests/modifier.rs b/tests/polkadot_tests/modifier.rs index 0532a31ca..f7d60c898 100644 --- a/tests/polkadot_tests/modifier.rs +++ b/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()); diff --git a/tests/polkadot_tests/primitives.rs b/tests/polkadot_tests/primitives.rs index 1866ad39e..5a0a50658 100644 --- a/tests/polkadot_tests/primitives.rs +++ b/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()); diff --git a/tests/polkadot_tests/strings.rs b/tests/polkadot_tests/strings.rs index dce3cbe70..6b7bfed5c 100644 --- a/tests/polkadot_tests/strings.rs +++ b/tests/polkadot_tests/strings.rs @@ -69,7 +69,7 @@ fn more_tests() { runtime.function("test", Vec::new()); let mut runtime = build_solidity( - r##" + r#" contract foo { function test() public { bytes s = "ABCD"; @@ -81,7 +81,7 @@ fn more_tests() { s[2] = 0x43; s[3] = 0x44; } - }"##, + }"#, ); runtime.function("test", Vec::new()); @@ -91,20 +91,20 @@ fn more_tests() { fn string_compare() { // compare literal to literal. This should be compile-time thing let mut runtime = build_solidity( - r##" + r#" contract foo { function test() public { assert(hex"414243" == 'ABC'); assert(hex'414243' != "ABD"); } - }"##, + }"#, ); runtime.function("test", Vec::new()); let mut runtime = build_solidity( - r##" + r#" contract foo { function lets_compare1(string s) private returns (bool) { return s == unicode'the quick brown fox jumps over the lazy dog'; @@ -131,7 +131,7 @@ fn string_compare() { assert(s1 == s2); } - }"##, + }"#, ); runtime.function("test", Vec::new()); @@ -141,18 +141,18 @@ fn string_compare() { fn string_concat() { // concat literal and literal. This should be compile-time thing let mut runtime = build_solidity( - r##" + r#" contract foo { function test() public { assert(hex"41424344" == "AB" + "CD"); } - }"##, + }"#, ); runtime.function("test", Vec::new()); let mut runtime = build_solidity( - r##" + r#" contract foo { function test() public { string s1 = "x"; @@ -163,7 +163,7 @@ fn string_concat() { assert(s1 + s2 == "xasdfasdf"); } - }"##, + }"#, ); runtime.function("test", Vec::new()); @@ -181,12 +181,12 @@ fn string_abi_encode() { struct RetStringArray(Vec); let mut runtime = build_solidity( - r##" + r#" contract foo { function test() public returns (string) { return "foobar"; } - }"##, + }"#, ); runtime.function("test", Vec::new()); @@ -194,13 +194,13 @@ fn string_abi_encode() { assert_eq!(runtime.output(), Val("foobar".to_string()).encode()); let mut runtime = build_solidity( - r##" + r#" contract foo { function test() public returns (int8[4], string, bool) { return ([ int8(120), 3, -127, 64], "Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. It is a way I have of driving off the spleen and regulating the circulation. Whenever I find myself growing grim about the mouth; whenever it is a damp, drizzly November in my soul; whenever I find myself involuntarily pausing before coffin warehouses, and bringing up the rear of every funeral I meet; and especially whenever my hypos get such an upper hand of me, that it requires a strong moral principle to prevent me from deliberately stepping into the street, and methodically knocking people’s hats off—then, I account it high time to get to sea as soon as I can. This is my substitute for pistol and ball. With a philosophical flourish Cato throws himself upon his sword; I quietly take to the ship. There is nothing surprising in this. If they but knew it, almost all men in their degree, some time or other, cherish very nearly the same feelings towards the ocean with me.", true); } - }"##, + }"#, ); runtime.function("test", Vec::new()); @@ -208,7 +208,7 @@ fn string_abi_encode() { assert_eq!(runtime.output(), Ret3([ 120, 3, -127, 64], "Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. It is a way I have of driving off the spleen and regulating the circulation. Whenever I find myself growing grim about the mouth; whenever it is a damp, drizzly November in my soul; whenever I find myself involuntarily pausing before coffin warehouses, and bringing up the rear of every funeral I meet; and especially whenever my hypos get such an upper hand of me, that it requires a strong moral principle to prevent me from deliberately stepping into the street, and methodically knocking people’s hats off—then, I account it high time to get to sea as soon as I can. This is my substitute for pistol and ball. With a philosophical flourish Cato throws himself upon his sword; I quietly take to the ship. There is nothing surprising in this. If they but knew it, almost all men in their degree, some time or other, cherish very nearly the same feelings towards the ocean with me.".to_string(), true).encode()); let mut runtime = build_solidity( - r##" + r#" struct s { int8[4] f1; string f2; @@ -220,7 +220,7 @@ fn string_abi_encode() { return s({ f1: [ int8(120), 3, -127, 64], f2: "Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. It is a way I have of driving off the spleen and regulating the circulation. Whenever I find myself growing grim about the mouth; whenever it is a damp, drizzly November in my soul; whenever I find myself involuntarily pausing before coffin warehouses, and bringing up the rear of every funeral I meet; and especially whenever my hypos get such an upper hand of me, that it requires a strong moral principle to prevent me from deliberately stepping into the street, and methodically knocking people’s hats off—then, I account it high time to get to sea as soon as I can. This is my substitute for pistol and ball. With a philosophical flourish Cato throws himself upon his sword; I quietly take to the ship. There is nothing surprising in this. If they but knew it, almost all men in their degree, some time or other, cherish very nearly the same feelings towards the ocean with me.", f3: true}); } - }"##, + }"#, ); runtime.function("test", Vec::new()); @@ -228,7 +228,7 @@ fn string_abi_encode() { assert_eq!(runtime.output(), Ret3([ 120, 3, -127, 64], "Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. It is a way I have of driving off the spleen and regulating the circulation. Whenever I find myself growing grim about the mouth; whenever it is a damp, drizzly November in my soul; whenever I find myself involuntarily pausing before coffin warehouses, and bringing up the rear of every funeral I meet; and especially whenever my hypos get such an upper hand of me, that it requires a strong moral principle to prevent me from deliberately stepping into the street, and methodically knocking people’s hats off—then, I account it high time to get to sea as soon as I can. This is my substitute for pistol and ball. With a philosophical flourish Cato throws himself upon his sword; I quietly take to the ship. There is nothing surprising in this. If they but knew it, almost all men in their degree, some time or other, cherish very nearly the same feelings towards the ocean with me.".to_string(), true).encode()); let mut runtime = build_solidity( - r##" + r#" contract foo { function test() public returns (string[]) { string[] x = new string[](3); @@ -239,7 +239,7 @@ fn string_abi_encode() { return x; } - }"##, + }"#, ); runtime.function("test", Vec::new()); @@ -264,23 +264,23 @@ fn string_abi_decode() { struct ValB(Vec); let mut runtime = build_solidity( - r##"contract foo { + r#"contract foo { function test() public { string dec = abi.decode(hex"0c414141", (string)); assert(dec == "AAA"); } - }"##, + }"#, ); runtime.function("test", vec![]); // we should try lengths: 0 to 63, 64 to 0x800 let mut runtime = build_solidity( - r##" + r#" contract foo { function test(string s) public returns (string){ return " " + s + " "; } - }"##, + }"#, ); let moby_dick_first_para = "Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. It is a way I have of driving off the spleen and regulating the circulation. Whenever I find myself growing grim about the mouth; whenever it is a damp, drizzly November in my soul; whenever I find myself involuntarily pausing before coffin warehouses, and bringing up the rear of every funeral I meet; and especially whenever my hypos get such an upper hand of me, that it requires a strong moral principle to prevent me from deliberately stepping into the street, and methodically knocking people’s hats off—then, I account it high time to get to sea as soon as I can. This is my substitute for pistol and ball. With a philosophical flourish Cato throws himself upon his sword; I quietly take to the ship. There is nothing surprising in this. If they but knew it, almost all men in their degree, some time or other, cherish very nearly the same feelings towards the ocean with me."; @@ -305,12 +305,12 @@ fn string_abi_decode() { rng.fill(&mut s[..]); let mut runtime = build_solidity( - r##" + r#" contract foo { function test(bytes s) public returns (bytes){ return hex"fe" + s; } - }"##, + }"#, ); let arg = ValB(s.clone()).encode(); @@ -331,7 +331,7 @@ fn string_storage() { struct Val(String); let mut runtime = build_solidity( - r##" + r#" contract foo { string bar; @@ -343,7 +343,7 @@ fn string_storage() { return bar; } - }"##, + }"#, ); runtime.function("set_bar", Vec::new()); @@ -370,7 +370,7 @@ fn bytes_storage() { struct Arg64(u64); let mut runtime = build_solidity( - r##" + r#" contract foo { bytes bar = hex"aabbccddeeff"; @@ -381,7 +381,7 @@ fn bytes_storage() { function get_index64(uint64 index) public returns (bytes1) { return bar[index]; } - }"##, + }"#, ); runtime.constructor(0, Vec::new()); @@ -449,7 +449,7 @@ fn bytes_storage_subscript() { struct Arg(u32, u8); let mut runtime = build_solidity( - r##" + r#" contract foo { bytes bar = hex"aabbccddeeff"; @@ -460,7 +460,7 @@ fn bytes_storage_subscript() { function get_bar() public returns (bytes) { return bar; } - }"##, + }"#, ); runtime.constructor(0, Vec::new()); @@ -473,7 +473,7 @@ fn bytes_storage_subscript() { ); let mut runtime = build_solidity( - r##" + r#" contract foo { bytes bar = hex"deadcafe"; @@ -492,7 +492,7 @@ fn bytes_storage_subscript() { function get() public returns (bytes) { return bar; } - }"##, + }"#, ); runtime.constructor(0, Vec::new()); @@ -519,7 +519,7 @@ fn bytes_memory_subscript() { struct Ret(Vec); let mut runtime = build_solidity( - r##" + r#" contract foo { function set_index(uint32 index, bytes1 val) public returns (bytes) { bytes bar = hex"aabbccddeeff"; @@ -528,7 +528,7 @@ fn bytes_memory_subscript() { return bar; } - }"##, + }"#, ); runtime.constructor(0, Vec::new()); @@ -541,7 +541,7 @@ fn bytes_memory_subscript() { ); let mut runtime = build_solidity( - r##" + r#" contract foo { function or(uint32 index, bytes1 val) public returns (bytes) { bytes bar = hex"deadcafe"; @@ -566,7 +566,7 @@ fn bytes_memory_subscript() { return bar; } - }"##, + }"#, ); runtime.constructor(0, Vec::new()); @@ -587,12 +587,12 @@ fn bytes_memory_subscript() { #[test] fn string_escape() { let mut runtime = build_solidity( - r##" + r#" contract カラス { function カラス$() public { print(" \u20ac \x41 \f\b\r\n\v\\\'\"\t"); } - }"##, + }"#, ); runtime.constructor(0, Vec::new()); @@ -610,7 +610,7 @@ fn long_string() { // String used here (containing some UTF-8 chars, which is why bytes length != string length): // "Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. It is a way I have of driving off the spleen and regulating the circulation. Whenever I find myself growing grim about the mouth; whenever it is a damp, drizzly November in my soul; whenever I find myself involuntarily pausing before coffin warehouses, and bringing up the rear of every funeral I meet; and especially whenever my hypos get such an upper hand of me, that it requires a strong moral principle to prevent me from deliberately stepping into the street, and methodically knocking people’s hats off—then, I account it high time to get to sea as soon as I can. This is my substitute for pistol and ball. With a philosophical flourish Cato throws himself upon his sword; I quietly take to the ship. There is nothing surprising in this. If they but knew it, almost all men in their degree, some time or other, cherish very nearly the same feelings towards the ocean with me." let mut runtime = build_solidity( - r##" + r#" contract LongString { function decode() pure public { bytes enc = hex"6d1143616c6c206d65204973686d61656c2e20536f6d652079656172732061676fe280946e65766572206d696e6420686f77206c6f6e6720707265636973656c79e28094686176696e67206c6974746c65206f72206e6f206d6f6e657920696e206d792070757273652c20616e64206e6f7468696e6720706172746963756c617220746f20696e746572657374206d65206f6e2073686f72652c20492074686f75676874204920776f756c64207361696c2061626f75742061206c6974746c6520616e642073656520746865207761746572792070617274206f662074686520776f726c642e20497420697320612077617920492068617665206f662064726976696e67206f6666207468652073706c65656e20616e6420726567756c6174696e67207468652063697263756c6174696f6e2e205768656e6576657220492066696e64206d7973656c662067726f77696e67206772696d2061626f757420746865206d6f7574683b207768656e6576657220697420697320612064616d702c206472697a7a6c79204e6f76656d62657220696e206d7920736f756c3b207768656e6576657220492066696e64206d7973656c6620696e766f6c756e746172696c792070617573696e67206265666f726520636f6666696e2077617265686f757365732c20616e64206272696e67696e67207570207468652072656172206f662065766572792066756e6572616c2049206d6565743b20616e6420657370656369616c6c79207768656e65766572206d79206879706f7320676574207375636820616e2075707065722068616e64206f66206d652c20746861742069742072657175697265732061207374726f6e67206d6f72616c207072696e6369706c6520746f2070726576656e74206d652066726f6d2064656c696265726174656c79207374657070696e6720696e746f20746865207374726565742c20616e64206d6574686f646963616c6c79206b6e6f636b696e672070656f706c65e28099732068617473206f6666e280947468656e2c2049206163636f756e7420697420686967682074696d6520746f2067657420746f2073656120617320736f6f6e20617320492063616e2e2054686973206973206d79207375627374697475746520666f7220706973746f6c20616e642062616c6c2e20576974682061207068696c6f736f70686963616c20666c6f7572697368204361746f207468726f77732068696d73656c662075706f6e206869732073776f72643b20492071756965746c792074616b6520746f2074686520736869702e205468657265206973206e6f7468696e672073757270726973696e6720696e20746869732e204966207468657920627574206b6e65772069742c20616c6d6f737420616c6c206d656e20696e207468656972206465677265652c20736f6d652074696d65206f72206f746865722c20636865726973682076657279206e6561726c79207468652073616d65206665656c696e677320746f776172647320746865206f6365616e2077697468206d652e"; @@ -624,7 +624,7 @@ fn long_string() { assert(dec2 == "Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. It is a way I have of driving off the spleen and regulating the circulation. Whenever I find myself growing grim about the mouth; whenever it is a damp, drizzly November in my soul; whenever I find myself involuntarily pausing before coffin warehouses, and bringing up the rear of every funeral I meet; and especially whenever my hypos get such an upper hand of me, that it requires a strong moral principle to prevent me from deliberately stepping into the street, and methodically knocking people’s hats off—then, I account it high time to get to sea as soon as I can. This is my substitute for pistol and ball. With a philosophical flourish Cato throws himself upon his sword; I quietly take to the ship. There is nothing surprising in this. If they but knew it, almost all men in their degree, some time or other, cherish very nearly the same feelings towards the ocean with me.Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. It is a way I have of driving off the spleen and regulating the circulation. Whenever I find myself growing grim about the mouth; whenever it is a damp, drizzly November in my soul; whenever I find myself involuntarily pausing before coffin warehouses, and bringing up the rear of every funeral I meet; and especially whenever my hypos get such an upper hand of me, that it requires a strong moral principle to prevent me from deliberately stepping into the street, and methodically knocking people’s hats off—then, I account it high time to get to sea as soon as I can. This is my substitute for pistol and ball. With a philosophical flourish Cato throws himself upon his sword; I quietly take to the ship. There is nothing surprising in this. If they but knew it, almost all men in their degree, some time or other, cherish very nearly the same feelings towards the ocean with me.Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. It is a way I have of driving off the spleen and regulating the circulation. Whenever I find myself growing grim about the mouth; whenever it is a damp, drizzly November in my soul; whenever I find myself involuntarily pausing before coffin warehouses, and bringing up the rear of every funeral I meet; and especially whenever my hypos get such an upper hand of me, that it requires a strong moral principle to prevent me from deliberately stepping into the street, and methodically knocking people’s hats off—then, I account it high time to get to sea as soon as I can. This is my substitute for pistol and ball. With a philosophical flourish Cato throws himself upon his sword; I quietly take to the ship. There is nothing surprising in this. If they but knew it, almost all men in their degree, some time or other, cherish very nearly the same feelings towards the ocean with me.Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. It is a way I have of driving off the spleen and regulating the circulation. Whenever I find myself growing grim about the mouth; whenever it is a damp, drizzly November in my soul; whenever I find myself involuntarily pausing before coffin warehouses, and bringing up the rear of every funeral I meet; and especially whenever my hypos get such an upper hand of me, that it requires a strong moral principle to prevent me from deliberately stepping into the street, and methodically knocking people’s hats off—then, I account it high time to get to sea as soon as I can. This is my substitute for pistol and ball. With a philosophical flourish Cato throws himself upon his sword; I quietly take to the ship. There is nothing surprising in this. If they but knew it, almost all men in their degree, some time or other, cherish very nearly the same feelings towards the ocean with me."); } } - "##, + "#, ); runtime.constructor(0, vec![]); runtime.function("decode", vec![]); @@ -633,7 +633,7 @@ fn long_string() { #[test] fn string_encoded_length() { let mut runtime = build_solidity( - r##" + r#" contract StrLen { function strlen() public pure { // Length < 0x40 is expected to have 1 byte length width @@ -655,7 +655,7 @@ fn string_encoded_length() { assert(e16384[2] == 0x01); assert(e16384[3] == 0x00); } - }"##, + }"#, ); runtime.function("strlen", vec![]); } diff --git a/tests/polkadot_tests/structs.rs b/tests/polkadot_tests/structs.rs index cc378c768..d08ce5856 100644 --- a/tests/polkadot_tests/structs.rs +++ b/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![]); diff --git a/tests/polkadot_tests/value.rs b/tests/polkadot_tests/value.rs index a9f5f17c9..eba4b23a8 100644 --- a/tests/polkadot_tests/value.rs +++ b/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()); diff --git a/tests/polkadot_tests/variables.rs b/tests/polkadot_tests/variables.rs index f6eeb1caf..6dc088e01 100644 --- a/tests/polkadot_tests/variables.rs +++ b/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()); diff --git a/tests/solana_tests/hash.rs b/tests/solana_tests/hash.rs index 386853d7a..0c6892f46 100644 --- a/tests/solana_tests/hash.rs +++ b/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(&[]); diff --git a/tests/solana_tests/primitives.rs b/tests/solana_tests/primitives.rs index 3fa885d85..bc9c5a4b3 100644 --- a/tests/solana_tests/primitives.rs +++ b/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:?}");