implement address and msg.sender

Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
This commit is contained in:
Cyrill Leutwiler
2024-05-08 16:09:23 +02:00
parent f80a96059d
commit ea63991617
14 changed files with 114 additions and 11 deletions
+17 -1
View File
@@ -1,4 +1,4 @@
use alloy_primitives::{FixedBytes, Keccak256, I256, U256};
use alloy_primitives::{Address, FixedBytes, Keccak256, I256, U256};
use alloy_sol_types::{sol, SolCall};
use sha1::Digest;
@@ -280,3 +280,19 @@ fn block_timestamp() {
let expected = U256::from(mock_runtime::State::BLOCK_TIMESTAMP);
assert_eq!(received, expected);
}
#[test]
fn address() {
let state = assert_success(Contract::context_address(), true);
let received = Address::from_slice(&state.output.data[12..]);
let expected = Address::from(&mock_runtime::State::ADDRESS);
assert_eq!(received, expected);
}
#[test]
fn caller() {
let state = assert_success(Contract::context_caller(), true);
let received = Address::from_slice(&state.output.data[12..]);
let expected = Address::from(&mock_runtime::State::CALLER);
assert_eq!(received, expected);
}