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