mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-04-22 17:18:01 +00:00
enable call context address tests
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
This commit is contained in:
@@ -2,6 +2,39 @@
|
||||
|
||||
pragma solidity ^0.8;
|
||||
|
||||
/* runner.json
|
||||
{
|
||||
"differential": true,
|
||||
"actions": [
|
||||
{
|
||||
"Instantiate": {
|
||||
"code": {
|
||||
"Solidity": {
|
||||
"contract": "Context"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"Call": {
|
||||
"dest": {
|
||||
"Instantiated": 0
|
||||
},
|
||||
"data": "846a1ee1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Call": {
|
||||
"dest": {
|
||||
"Instantiated": 0
|
||||
},
|
||||
"data": "fc9c8d39"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
*/
|
||||
|
||||
contract Context {
|
||||
function address_this() public view returns (address ret) {
|
||||
ret = address(this);
|
||||
|
||||
@@ -33,6 +33,7 @@ test_spec!(mcopy, "MCopy", "MCopy.sol");
|
||||
test_spec!(events, "Events", "Events.sol");
|
||||
test_spec!(storage, "Storage", "Storage.sol");
|
||||
test_spec!(mstore8, "MStore8", "MStore8.sol");
|
||||
test_spec!(address, "Context", "Context.sol");
|
||||
|
||||
fn instantiate(path: &str, contract: &str) -> Vec<SpecsAction> {
|
||||
vec![Instantiate {
|
||||
@@ -254,23 +255,6 @@ fn balance() {
|
||||
assert_eq!(expected, received)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn address() {
|
||||
let contract = Contract::context_address();
|
||||
let (_, output) = assert_success(&contract, true);
|
||||
let received = Address::from_slice(&output.data[12..]);
|
||||
let expected = Transaction::default_address();
|
||||
assert_eq!(received, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn caller() {
|
||||
let (_, output) = assert_success(&Contract::context_caller(), true);
|
||||
let received = Address::from_slice(&output.data[12..]);
|
||||
let expected = Transaction::default_address();
|
||||
assert_eq!(received, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create2() {
|
||||
let mut state = State::default();
|
||||
|
||||
@@ -279,7 +279,7 @@ impl Specs {
|
||||
),
|
||||
};
|
||||
let deploy_code = hex::encode(deploy_code);
|
||||
let mut vm = evm.code_blob(deploy_code.as_bytes().to_vec()).sender(Address::default()).deploy(true);
|
||||
let mut vm = evm.code_blob(deploy_code.as_bytes().to_vec()).sender(origin.to_eth_addr(&[]).0.into()).deploy(true);
|
||||
if !data.is_empty() {
|
||||
vm = vm.input(data.into());
|
||||
}
|
||||
@@ -311,7 +311,7 @@ impl Specs {
|
||||
panic!("the differential runner requires TestAccountId::Instantiated(n) as dest");
|
||||
};
|
||||
let address = deployed_accounts.get(n).unwrap_or_else(|| panic!("no account at index {n} "));
|
||||
let mut vm = evm.receiver(*address).sender(Address::default());
|
||||
let mut vm = evm.receiver(*address).sender(origin.to_eth_addr(&[]).0.into());
|
||||
if !data.is_empty() {
|
||||
vm = vm.input(data.into());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user