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

Test nonce #20

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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)));
}
}
10 changes: 10 additions & 0 deletions integration_tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ def approve_proposal_legacy(node, rsp):
return amount


def test_random(cronos):
w3 = cronos.w3
contract = deploy_contract(
w3,
CONTRACTS["Random"],
key=KEYS["validator"],
)
print(contract.caller.randomTokenId())


def test_ica_enabled(cronos):
cli = cronos.cosmos_cli()
p = cli.query_icacontroller_params()
Expand Down
7 changes: 7 additions & 0 deletions integration_tests/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ def exec(c, tmp_path_factory, testnet=True):
assert rsp["code"] == 0, rsp["raw_log"]
approve_proposal(c, rsp, event_query_tx=testnet)

nonce_bf = c.w3.eth.get_transaction_count(ADDRS["validator"])
print("mm-nonce-bf", nonce_bf)

# update cli chain binary
c.chain_binary = (
Path(c.chain_binary).parent.parent.parent / f"{plan_name}/bin/cronosd"
Expand All @@ -170,6 +173,9 @@ def exec(c, tmp_path_factory, testnet=True):

# check basic tx works
wait_for_port(ports.evmrpc_port(c.base_port(0)))

nonce_af = c.w3.eth.get_transaction_count(ADDRS["validator"])
print("mm-nonce-af", nonce_af)
receipt = send_transaction(
c.w3,
{
Expand All @@ -180,6 +186,7 @@ def exec(c, tmp_path_factory, testnet=True):
},
)
assert receipt.status == 1
return

if not testnet:
# after upgrade, PUSH0 opcode is supported
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
17 changes: 9 additions & 8 deletions scripts/run-integration-tests
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ cd ../integration_tests/contracts
HUSKY_SKIP_INSTALL=1 npm install
npm run typechain
cd ..
TESTS_TO_RUN="${TESTS_TO_RUN:-all}"
if [[ "$TESTS_TO_RUN" == "all" ]]; then
echo "run all tests"
cmd="pytest -vv -s"
else
echo "run tests matching $TESTS_TO_RUN"
cmd="pytest -vv -s -m '$TESTS_TO_RUN'"
fi
# TESTS_TO_RUN="${TESTS_TO_RUN:-all}"
# if [[ "$TESTS_TO_RUN" == "all" ]]; then
# echo "run all tests"
# cmd="pytest -vv -s"
# else
# echo "run tests matching $TESTS_TO_RUN"
# cmd="pytest -vv -s -m '$TESTS_TO_RUN'"
# fi
cmd="pytest -v -s test_upgrade.py::test_cosmovisor_upgrade_mainnet"
nix-shell --run "$cmd"
Loading