forked from evmos/ethermint
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
30 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,34 @@ | ||
from web3 import Web3 | ||
import json | ||
from web3 import Web3 | ||
from web3._utils.contracts import encode_transaction_data | ||
from hexbytes import HexBytes | ||
|
||
from .utils import CONTRACTS | ||
|
||
|
||
def test_state_override(ethermint): | ||
w3: Web3 = ethermint.w3 | ||
info = json.loads(CONTRACTS['Greeter'].read_text()) | ||
address = "0x0000000000000000000000000000ffffffffffff" | ||
def test_state_override(cronos): | ||
state = 100 | ||
w3: Web3 = cronos.w3 | ||
info = json.loads(CONTRACTS["Greeter"].read_text()) | ||
data = encode_transaction_data(w3, "intValue", info["abi"]) | ||
# call an arbitrary address | ||
address = w3.toChecksumAddress("0x0000000000000000000000000000ffffffffffff") | ||
overrides = { | ||
address: { | ||
"code": info['deployedBytecode'], | ||
"code": info["deployedBytecode"], | ||
"state": { | ||
("0x" + "0" * 64): HexBytes( | ||
w3.codec.encode(("uint256",), (state,)) | ||
).hex(), | ||
}, | ||
}, | ||
} | ||
contract = w3.eth.contract(abi=info['abi'], address=address) | ||
print(contract.greet().call("latest", overrides)) | ||
result = w3.eth.call( | ||
{ | ||
"to": address, | ||
"data": data, | ||
}, | ||
"latest", | ||
overrides, | ||
) | ||
assert (state,) == w3.codec.decode(("uint256",), result) |