Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: can't support prevrando opcode #1366

Merged
merged 6 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions integration_tests/contracts/contracts/Random.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;

contract Random {
function randomTokenId() public returns (uint256) {
return uint256(keccak256(abi.encodePacked(block.prevrandao)));
}
}
46 changes: 45 additions & 1 deletion integration_tests/test_gov_update_params.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,56 @@
import hashlib
import json

import pytest

from .utils import approve_proposal
from .utils import CONTRACTS, approve_proposal, deploy_contract, eth_to_bech32

pytestmark = pytest.mark.gov


def test_evm_update_param(cronos, tmp_path):
contract = deploy_contract(
cronos.w3,
CONTRACTS["Random"],
)
with pytest.raises(ValueError) as e_info:
contract.caller.randomTokenId()
assert "invalid memory address or nil pointer dereference" in str(e_info.value)
deploy_contract(cronos.w3, CONTRACTS["Greeter"])
cli = cronos.cosmos_cli()
p = cli.query_params("evm")["params"]
del p["chain_config"]["shanghai_time"]
proposal = tmp_path / "proposal.json"
# governance module account as signer
data = hashlib.sha256("gov".encode()).digest()[:20]
signer = eth_to_bech32(data)
proposal_src = {
"messages": [
{
"@type": "/ethermint.evm.v1.MsgUpdateParams",
"authority": signer,
"params": p,
}
],
"deposit": "1basetcro",
"title": "title",
"summary": "summary",
}
proposal.write_text(json.dumps(proposal_src))
rsp = cli.submit_gov_proposal(proposal, from_="community")
assert rsp["code"] == 0, rsp["raw_log"]
approve_proposal(cronos, rsp)
print("check params have been updated now")
p = cli.query_params("evm")["params"]
invalid_msg = "invalid opcode: PUSH0"
with pytest.raises(ValueError) as e_info:
contract.caller.randomTokenId()
assert invalid_msg in str(e_info.value)
with pytest.raises(ValueError) as e_info:
deploy_contract(cronos.w3, CONTRACTS["Greeter"])
assert invalid_msg in str(e_info.value)


def test_gov_update_params(cronos, tmp_path):
cli = cronos.cosmos_cli()

Expand Down
1 change: 1 addition & 0 deletions integration_tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"CosmosERC20": "CosmosToken.sol",
"TestBank": "TestBank.sol",
"TestICA": "TestICA.sol",
"Random": "Random.sol",
}


Expand Down
Loading