Skip to content

Commit 99a82ea

Browse files
committed
Add test of msg_value and emit_log
1 parent cdd305f commit 99a82ea

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

integration/stylus/milestone_2.sol

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,19 @@ contract C {
7474
print("greeter1 = {}".format(address(greeter1)));
7575
greeter1.greet();
7676
}
77+
78+
function test_value_sender() public payable returns (uint256) {
79+
return this.test_value_receiver{value: msg.value}();
80+
}
81+
82+
event Received(uint256 value);
83+
84+
function test_value_receiver() public payable returns (uint256) {
85+
uint256 value = msg.value;
86+
emit Received(value);
87+
assert(value == 1000000000000000000);
88+
return value;
89+
}
7790
}
7891

7992
contract Greeter {

tests/stylus_tests/milestone_2.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,22 @@ fn milestone_2() {
5353
)
5454
.unwrap();
5555
println!("{}", stdout);
56+
57+
stdout = send(
58+
dir,
59+
&address,
60+
["test_value_sender()", "--value=1000000000000000000"],
61+
)
62+
.unwrap();
63+
println!("{}", stdout);
64+
65+
let line = stdout
66+
.lines()
67+
.find(|line| line.starts_with("logs"))
68+
.unwrap();
69+
// smoelius: keccak256("Reason(uint256)") = 0xa8142743f8f70a4c26f3691cf4ed59718381fb2f18070ec52be1f1022d855557
70+
// 0x0de0b6b3a7640000 = 1000000000000000000
71+
assert!(line.contains(r#""topics":["0xa8142743f8f70a4c26f3691cf4ed59718381fb2f18070ec52be1f1022d855557"],"data":"0x0000000000000000000000000000000000000000000000000de0b6b3a7640000""#));
5672
}
5773

5874
fn label_test_block_output(stdout: &str) -> String {

0 commit comments

Comments
 (0)