diff --git a/tests/integration_tests/configs/cosmovisor.jsonnet b/tests/integration_tests/configs/cosmovisor.jsonnet index 1fbf075f05..dc3cb1a4a2 100644 --- a/tests/integration_tests/configs/cosmovisor.jsonnet +++ b/tests/integration_tests/configs/cosmovisor.jsonnet @@ -2,13 +2,14 @@ local config = import 'default.jsonnet'; config { 'ethermint_9000-1'+: { + 'app-config'+: { + 'minimum-gas-prices': '100000000000aphoton', + }, genesis+: { app_state+: { feemarket+: { params+: { - no_base_fee: false, base_fee:: super.base_fee, - initial_base_fee: super.base_fee, }, }, }, diff --git a/tests/integration_tests/configs/default.jsonnet b/tests/integration_tests/configs/default.jsonnet index deffe43c88..b181297d5b 100644 --- a/tests/integration_tests/configs/default.jsonnet +++ b/tests/integration_tests/configs/default.jsonnet @@ -4,10 +4,6 @@ cmd: 'ethermintd', 'start-flags': '--trace', config: { - consensus: { - // larger timeout for more stable mempool tests - timeout_commit: '10s', - }, mempool: { // use v1 mempool to enable tx prioritization version: 'v1', diff --git a/tests/integration_tests/configs/enable-indexer.jsonnet b/tests/integration_tests/configs/enable-indexer.jsonnet index c21c6a98c0..1a5b0d14dc 100644 --- a/tests/integration_tests/configs/enable-indexer.jsonnet +++ b/tests/integration_tests/configs/enable-indexer.jsonnet @@ -8,13 +8,18 @@ config { }, }, 'app-config'+: { - pruning: 'everything', - 'state-sync'+: { - 'snapshot-interval': 0, - }, 'json-rpc'+: { 'enable-indexer': true, }, }, + genesis+: { + app_state+: { + feemarket+: { + params+: { + min_gas_multiplier: '0', + }, + }, + }, + }, }, } diff --git a/tests/integration_tests/configs/long_timeout_commit.jsonnet b/tests/integration_tests/configs/long_timeout_commit.jsonnet new file mode 100644 index 0000000000..b54ad60e0e --- /dev/null +++ b/tests/integration_tests/configs/long_timeout_commit.jsonnet @@ -0,0 +1,11 @@ +local default = import 'default.jsonnet'; + +default { + 'ethermint_9000-1'+: { + config+: { + consensus+: { + timeout_commit: '5s', + }, + }, + }, +} diff --git a/tests/integration_tests/configs/pruned_node.jsonnet b/tests/integration_tests/configs/pruned_node.jsonnet index ffb6a83044..cd00fc0a7d 100644 --- a/tests/integration_tests/configs/pruned_node.jsonnet +++ b/tests/integration_tests/configs/pruned_node.jsonnet @@ -8,5 +8,14 @@ config { 'snapshot-interval': 0, }, }, + genesis+: { + app_state+: { + feemarket+: { + params+: { + min_gas_multiplier: '0', + }, + }, + }, + }, }, } diff --git a/tests/integration_tests/configs/rollback-test.jsonnet b/tests/integration_tests/configs/rollback-test.jsonnet index e39437ec58..0e6c3ffca3 100644 --- a/tests/integration_tests/configs/rollback-test.jsonnet +++ b/tests/integration_tests/configs/rollback-test.jsonnet @@ -2,7 +2,7 @@ local config = import 'default.jsonnet'; config { 'ethermint_9000-1'+: { - validators: super.validators + [{ + validators: super.validators[0:1] + [{ name: 'fullnode', }], }, diff --git a/tests/integration_tests/configs/upgrade-test-package.nix b/tests/integration_tests/configs/upgrade-test-package.nix index a703086f90..1863054dfb 100644 --- a/tests/integration_tests/configs/upgrade-test-package.nix +++ b/tests/integration_tests/configs/upgrade-test-package.nix @@ -3,10 +3,9 @@ let fetchEthermint = rev: builtins.fetchTarball "https://github.com/evmos/ethermint/archive/${rev}.tar.gz"; released = pkgs.buildGo118Module rec { name = "ethermintd"; - # the commit before https://github.com/evmos/ethermint/pull/943 - src = fetchEthermint "f21592ebfe74da7590eb42ed926dae970b2a9a3f"; + src = fetchEthermint "d29cdad6e667f6089dfecbedd36bb8d3a2a7d025"; subPackages = [ "cmd/ethermintd" ]; - vendorSha256 = "sha256-ABm5t6R/u2S6pThGrgdsqe8n3fH5tIWw7a57kxJPbYw="; + vendorSha256 = "sha256-cQAol54b6hNzsA4Q3MP9mTqFWM1MvR5uMPrYpaoj3SY="; doCheck = false; }; current = pkgs.callPackage ../../../. { }; diff --git a/tests/integration_tests/conftest.py b/tests/integration_tests/conftest.py index ea50d89071..bd3f66fddf 100644 --- a/tests/integration_tests/conftest.py +++ b/tests/integration_tests/conftest.py @@ -1,8 +1,6 @@ -from pathlib import Path - import pytest -from .network import setup_custom_ethermint, setup_ethermint, setup_geth +from .network import setup_ethermint, setup_geth @pytest.fixture(scope="session") @@ -11,42 +9,12 @@ def ethermint(tmp_path_factory): yield from setup_ethermint(path, 26650) -@pytest.fixture(scope="session") -def ethermint_indexer(tmp_path_factory): - path = tmp_path_factory.mktemp("indexer") - yield from setup_custom_ethermint( - path, 26660, Path(__file__).parent / "configs/enable-indexer.jsonnet" - ) - - @pytest.fixture(scope="session") def geth(tmp_path_factory): path = tmp_path_factory.mktemp("geth") yield from setup_geth(path, 8545) -@pytest.fixture( - scope="session", params=["ethermint", "geth", "ethermint-ws", "enable-indexer"] -) -def cluster(request, ethermint, ethermint_indexer, geth): - """ - run on both ethermint and geth - """ - provider = request.param - if provider == "ethermint": - yield ethermint - elif provider == "geth": - yield geth - elif provider == "ethermint-ws": - ethermint_ws = ethermint.copy() - ethermint_ws.use_websocket() - yield ethermint_ws - elif provider == "enable-indexer": - yield ethermint_indexer - else: - raise NotImplementedError - - @pytest.fixture( scope="session", params=["ethermint", "ethermint-ws"] ) diff --git a/tests/integration_tests/cosmoscli.py b/tests/integration_tests/cosmoscli.py index 7a1edbe631..41c24c91e7 100644 --- a/tests/integration_tests/cosmoscli.py +++ b/tests/integration_tests/cosmoscli.py @@ -6,6 +6,7 @@ from pystarport.utils import build_cli_args_safe, interact DEFAULT_GAS_PRICE = "5000000000000aphoton" +DEFAULT_GAS = "250000" class ChainCommand: @@ -636,13 +637,14 @@ def edit_validator( ) def gov_propose(self, proposer, kind, proposal, **kwargs): + method = "submit-proposal" kwargs.setdefault("gas_prices", DEFAULT_GAS_PRICE) if kind == "software-upgrade": return json.loads( self.raw( "tx", "gov", - "submit-proposal", + method, kind, proposal["name"], "-y", @@ -664,7 +666,7 @@ def gov_propose(self, proposer, kind, proposal, **kwargs): self.raw( "tx", "gov", - "submit-proposal", + method, kind, "-y", from_=proposer, @@ -685,7 +687,7 @@ def gov_propose(self, proposer, kind, proposal, **kwargs): self.raw( "tx", "gov", - "submit-proposal", + method, kind, fp.name, "-y", diff --git a/tests/integration_tests/expected_constants.py b/tests/integration_tests/expected_constants.py index 85bee9b6e0..4724b5df88 100644 --- a/tests/integration_tests/expected_constants.py +++ b/tests/integration_tests/expected_constants.py @@ -2,30 +2,47 @@ "0x00000000000000000000000000000000000000000000000000120a0b063499d4" ) +# curl https://mainnet.infura.io/v3/YOUR_KEY_HERE \ +# -X POST \ +# -H "Content-Type: application/json" \ +# -d '{"jsonrpc": "2.0","method": "eth_getProof","params": +# ["0x7F0d15C7FAae65896648C8273B6d7E43f58Fa842",["0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"], +# "latest"],"id": 1}' EXPECTED_GET_PROOF = { - "address": "0x4CB06C43fcdABeA22541fcF1F856A6a296448B6c", - "accountProof": [ - "0xf90211a03841a7ddd65c70c94b8efa79190d00f0ab134b26f18dcad508f60a7e74559d0ba0464b07429a05039e22931492d6c6251a860c018ea390045d596b1ac11b5c7aa7a011f4b89823a03c9c4b5a8ab079ee1bc0e2a83a508bb7a5dc7d7fb4f2e95d3186a0b5f7c51c3b2d51d97f171d2b38a4df1a7c0acc5eb0de46beeff4d07f5ed20e19a0b591a2ce02367eda31cf2d16eca7c27fd44dbf0864b64ea8259ad36696eb2a04a02b646a7552b8392ae94263757f699a27d6e9176b4c06b9fc0a722f893b964795a02df05d68bceb88eebf68aafde61d10ab942097afc1c58b8435ffd3895358a742a0c2f16143c4d1db03276c433696dddb3e9f3b113bcd854b127962262e98f43147a0828820316cc02bfefd899aba41340659fd06df1e0a0796287ec2a4110239f6d2a050496598670b04df7bbff3718887fa36437d6d8c7afb4eff86f76c5c7097dcc4a0c14e9060c6b3784e35b9e6ae2ad2984142a75910ccc89eb89dc1e2f44b6c58c2a009804db571d0ce07913e1cbacc4f1dc4fb8265c936f5c612e3a47e91c64d8e9fa063d96f38b3cb51b1665c6641e25ffe24803f2941e5df79942f6a53b7169647e4a0899f71abb18c6c956118bf567fac629b75f7e9526873e429d3d8abb6dbb58021a00fd717235298742623c0b3cafb3e4bd86c0b5ab1f71097b4dd19f3d6925d758da0096437146c16097f2ccc1d3e910d65a4132803baee2249e72c8bf0bcaaeb37e580", # noqa: E501 - "0xf90151a097b17a89fd2c03ee98cb6459c08f51b269da5cee46650e84470f62bf83b43efe80a03b269d284a4c3cf8f8deacafb637c6d77f607eec8d75e8548d778e629612310480a01403217a7f1416830c870087c524dabade3985271f6f369a12b010883c71927aa0f592ac54c879817389663be677166f5022943e2fe1b52617a1d15c2f353f27dda0ac8d015a9e668f5877fcc391fae33981c00577096f0455b42df4f8e8089ece24a003ba34a13e2f2fb4bf7096540b42d4955c5269875b9cf0f7b87632585d44c9a580a0b179e3230b07db294473ae57f0170262798f8c551c755b5665ace1215cee10ca80a0552d24252639a6ae775aa1df700ffb92c2411daea7286f158d44081c8172d072a0772a87d08cf38c4c68bfde770968571abd16fd3835cb902486bd2e515d53c12d80a0413774f3d900d2d2be7a3ad999ffa859a471dc03a74fb9a6d8275455f5496a548080", # noqa: E501 - "0xf869a020d13b52a61d3c1325ce3626a51418adebd6323d4840f1bdd93906359d11c933b846f8440180a01ab7c0b0a2a4bbb5a1495da8c142150891fc64e0c321e1feb70bd5f881951f7ea0551332d96d085185ab4019ad8bcf89c45321e136c261eb6271e574a2edf1461f", # noqa: E501 - ], - "balance": 0, - "codeHash": "0x551332d96d085185ab4019ad8bcf89c45321e136c261eb6271e574a2edf1461f", # noqa: E501 - "nonce": 1, - "storageHash": "0x1ab7c0b0a2a4bbb5a1495da8c142150891fc64e0c321e1feb70bd5f881951f7e", # noqa: E501 - "storageProof": [ - { - "key": "0x00", - "value": "0x48656c6c6f00000000000000000000000000000000000000000000000000000a", # noqa: E501 - "proof": [ - "0xf9019180a01ace80e7bed79fbadbe390876bd1a7d9770edf9462049ef8f4b555d05715d53ea049347a3c2eac6525a3fd7e3454dab19d73b4adeb9aa27d29493b9843f3f88814a085079b4abcd07fd4a5d6c52d35f4c4574aecc85830e90c478ca8c18fcbe590de80a02e3f8ad7ea29e784007f51852b9c3e470aef06b11bac32586a8b691134e4c27da064d2157a14bc31f195f73296ea4dcdbe7698edbf3ca81c44bf7730179d98d94ca09e7dc2597c9b7f72ddf84d7eebb0fe2a2fa2ab54fe668cd14fee44d9b40b1a53a0aa5d4acc7ac636d16bc9655556770bc325e1901fb62dc53770ef9110009e080380a0d5fde962bd2fb5326ddc7a9ca7fe0ee47c5bb3227f838b6d73d3299c22457596a08691410eff46b88f929ef649ea25025f62a5362ca8dc8876e5e1f4fc8e79256d80a0673e88d3a8a4616f676793096b5ae87cff931bd20fb8dd466f97809a1126aad8a08b774a45c2273553e2daf4bbc3a8d44fb542ea29b6f125098f79a4d211b3309ca02fed3139c1791269acb9365eddece93e743900eba6b42a6a8614747752ba268f80", # noqa: E501 - "0xf891808080a0c7d094301e0c54da37b696d85f72de5520b224ab2cf4f045d8db1a3374caf0488080a0fc5581783bfe27fab9423602e1914d719fd71433e9d7dd63c95fe7e58d10c9c38080a0c64f346fc7a21f6679cba8abdf37ca2de8c4fcd8f8bcaedb261b5f77627c93908080808080a0ddef2936a67a3ac7d3d4ff15a935a45f2cc4976c8f0310aed85daf763780e2b480", # noqa: E501 - "0xf843a0200decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563a1a048656c6c6f00000000000000000000000000000000000000000000000000000a", # noqa: E501 - ], - } - ], + "jsonrpc": "2.0", + "id": 1, + "result": { + "accountProof": [ + "0xf90211a0d308f98795cbcc61d0520723e3361adc5513705272d90ee48ccd247246f7c349a010139d8b72e8086a732523b8905eabf1172c5202efc588a3c7cd22d86c01ccbda0faa34953c5e42eba596c0085082e7969a0fba937de89a482882f56c60eb61fbda00bb6a0aae1af594fabf4bb4be474fe7c99a3936b27b3ae838341d7ea31988df0a000fd250e61c6c9944d981d9ac2d1d3265239349bd82fd06ac5635fb3026ea3dea064625348caa521add14ff55a3efb5335d70c3a57c89ca74381b29c5e44bba22ca07c87aeff8d60769087900486cee0f400d4c73ac5f75e80ea7e419e3222493c61a0a85a1e93809071ab62ef124c05f71b33b5f3beb29a40d3362449589ad069f6c7a01e44cbe03b61463da0738947c35bfd6224f1a09c3c41da47f31d779b2c6a992fa0828a75c8da3f71e2df63ac7c0f19bb4b1c9dd861fc403823f189b588dd29eb75a0c0dfa1e4be056540e1a9524e3b060ab8f6d51bc688d84b7fcf7289cfaba1ceaba00865239fb25a3a83889326e8bc21f050b33c5181681c33b89e1d7ab883b3f3c5a0e148cdb3af3c738c1e53d1f85913b0accd46c45b34e3873abd6c98d5995d5f83a0044064693ce7d1a5888a1aca785ff1126c09cf83a00c4a3b386cb3da056eb432a0b5711def31905c703d958ae996321c9f8aefb12107acfa2dc20311801eb2558fa04005fcc01439852c004a84c6542d139b20ddac8c6e1e9684821d10e07cb4e33a80", # noqa: E501 + "0xf90211a0051fd734a1442d85238b82a7fd9ab58cac3b56728e0d07141ca30ea09c502fd4a03537903e89b73f84f80346827ccb523c9658a478e4fac51269c1064d5b74dccea0fa27fc86a7025b9928cbc55d7fc4ad42fc4974f8f69e6e2c780360510398a28da0752a52276798a12b712b0edde30a8308da6618b0f58b3199c78d0654561541caa09e64d6fa19e6dadf9b107059d5e9e1ba0f8dade4605e31d36d84a8661a18b9c1a06f724081c76cdb3eeba6c164c16eecc7ca85ab6d38bc3bce4983feead3df67f9a02c66343b11b10ba25c84e2f75dc1e2a995c32929312ff9a347536138162be1d7a0994e90111ec6af30851974a047dd7a227d235b2c6d0643199a5c3f6a685bf77aa0f844ea047a6e348f4cd8d0845e5e48b06ea033c6fd4d82eb534a8bfac990be83a0db9d470d492623fd2157320e0d658e4a46ee37c12211db9356b977e09aa01551a062efa94455c86e0e45691054225aa509acf08d97ab1253c6589b9a9f7f210f0aa057a857a358c0f0b4363ee793dc7393efdc19271ffe1dfec2650aac0b867d9729a0fc714453737c12b3b20f3ca7be1a2c4e56ba75806677a3b5a75922d54637127aa00580bfa435f851327f608f21dabab8b74658fb80dfa4ae090de30e4134a652c0a080a7b5f559e6941f1e29a3dbbdc1bd41aac866845366e9435c2048233e185816a093d7ddf2501324e5f3c0b64b41829b9c929743f5db178809b01a0b513d66ab0380", # noqa: E501 + "0xf90211a03ee5370675726aa9f895944a635a812819cd90853e34807e3763882b2f0dd978a03dcdfe595fb5b1c036e8c5618e75dc5dfbd20f4093b18f423d0c546a8841784fa0d181704ea7bcced784d9480abd6360e885657957e1eb596512b162cce3512433a0c75c61390552448a12958fd0fd51a88f7e5e6badd2c16b05f4c949f604b209e2a0bb24e0cc45c91c5d3f14c0a6eeb459db9447260696ba65e8a79f86170e2997e5a00870addc6060c3f528eacfabd6c52480f45f8e28ed3c7e58306daa37f7752205a0d9b904889003012fdafbfd6cae526bd627e6d6a8ccd0e1cecba8500649c9efcba0890f7bb42d79b87940acd735c61e6b8fe12b64c2aa7c162f62dfcb40b2a6bb26a09f8bb0d80d7f51b8803b12dd01bc77281f7d0746ae6d7331705d79be9ee676faa059f3d816f66dedd5ca93d54845d9fcbcd8a3b110c78c35629db79de7736d6181a0171aa28493b4a16cdaffb06ecdfc06f73bb5b2548426fdc0d1fc807fa734f219a0eedf3bd8db8007a360cb7ca38e7718e6c7de81244883caa3a276da03174e1697a086b32111c6000e06ae1d691588f96e589e00768aa3f8337633546ba3c5069694a06992a01de330340dba82add8897bf7bd9d1a4d89ee4f2c2e87407d5cd80b0a22a0a9aca4be841d84dfc3cfbcb492166d0a6a1bdf1bcd471c772eea60906da58da7a048439b7d9637e613a26f80ea269865dda9ceca2c5eea80e9a5acfb8ba83b1b7e80", # noqa: E501 + "0xf90211a07e164dfd7f1ae0e9c7a5276c54f44dde92965a6c2f33a6ab70f15837e7334846a08d1f58f0b8113267e9ae0b00cc2814bafd7abdf64ef092da4022252723ec4009a08e4bd9b065fa8dab94bac469f47a04f2c6cd269c5345de50566a54ec34ef21dba0f9a8d5511d60abf59d66a80a252ea86e3f3b6c325eeac5d861fca7e16c4e4111a006ad844c311fe3730f814ed96a75dd268f609c30bd4476c7842d877cb2baa0aaa076e6eedf4846cb47b5343708159de812ab27f6ad350e68ed70a936bcad30401fa0aa867723f3f21a5eb867ed5c5b99609ea535b967f710e547945e3ec2a212c68fa09d3e7fd8cd22ab508d079b58b40f75c3242f7c7704a82ec1c573f682e2168824a0aba33ff032dc7e10fc3a228adbcff47480580b292c4afee754394c6017872d5ca0ec2cd81c2048e35a4bedee1b27e077129edab50a40972c0f6ccd25bd864bedf2a0371c03a000f78dff313551c7afbf52a1348127ab17b737732191dbd64e68b700a0df0aad31c4c0887c6109cadb0d2341a65f18bc35f6e5583ebd417853b9f56329a07c6437031b7543922a3e6a74ae237a844226db3f632a16dffbedd8679b03b018a0538592d2b6933ab7f0d276e7509151632fbca90c10079ee0c9cce87925b19abaa0d79a8e5a546626e60d5d5c7bb839612a42b5724e880deae4bc282f42496a1ef4a03d172648e5e01d32748c96362e197e37a13aeffa0ae213a23b8898e6508bb6a380", # noqa: E501 + "0xf90211a07f77a654bce6a83ce5674a2936de6ea0768f4f11e19039c8b83ef62956d2ac15a0854518c708b71c9dfb97eaf4c300c0951108dc96ba9877e565cffced4224fbfca0d60083a3e2bdd537e16b3e2a6e62812fad9b7fbec0e56cb76676007fc1ac44eba0105b6a16896fc82d33f9c742890700b9a0312e37d15c7eb12dde2e015ce8920ea0f127c635dcde1f4898e8abcb45a1a8c07a32cc4d78f2f1fdc7386d26f41dc4aea06916ed562e2b84c6a4145a9a3c5716b5493db0637023347a883a3753522a57fea021b88faa7e7af0a40d03950f42abece8892452c3ce5d94266a36d444c8e84d73a0216e4a004f60aa058d227553b404ee93b5758f28d5bed24d6f3a34157b9a18bba0326b9ef2f85defffc61fc3561349969ff8aef23759ab4a4bd49b8dcd1453ee58a0649731f153d117e5ad56b07e3edfb911b3592009da413d952ff7fc2c1e0c8a25a077edfe281169e6425d0795670d9a33ea32ae11ee71896f9064d5a6189ed6693fa0f986846a0fff0ab469ae226de91e3f350757f49e21f48a57fc7c1e4142fa0c3aa0aae0a489f6e8142bce91638db238a1a2d32cc2c31d82eab86d20c89edca5ac3da04a789fc4610da58da2204e3c9f21e351b574b72c7a4194c996e2bc05d3086376a0184a75c2da01cbc27c48a0335318a60c9535ecd54a79bf96a9f821d8202a2080a0c22686c5baef46ef1364919c08a2cfe113cbc2ac0854d2a890df938538a5c36d80", # noqa: E501 + "0xf90211a00b5b38caa0b8e500946e01b36441c04b3932af0af937866756aea01208e630e5a0347a4bd5d736dc5dd178c724de94ca9f3cf351d6cc697f547e115ac955c12762a0fc12087179e3debe3505a5da9cb133650322b5846644289211785ad3ec8c2400a001ef26f67f5ff67e0480d40e9822329c834f2683cc4973d11276c1d252c67d07a0dab8a89872ab8887433393a58c6838f56dd33598c17bc65b67b3975909a1d7d9a0d8e72a6583ec2542c5153d46ff671efcf0e86d3dd6594148be6c8f45b962372aa05d3dfc9d0271fa2e17f1af8a36a105755d7c8ffcd75b523bc9e508d1e4a7f9c5a0367b15490f03ee256758187c63bff678de58c716b94fcee3c68de9b88d4d6d8da0557dd25a49b199b78d194b2c418afcf654415b2db9354b9836490117ac9d768ea0a58e109994f8dccbc777bdf9af2b756c62a1102aba71513f3cbd9aab76fe5d99a034bfcb38403a1a9f3409ea13cb8139f820b702ee757cf87d229949825180a89ea0e3f8b04c275387c6222b6536967f2f1e6fc76dc6ee0e705d3e505f3d07e8bdd4a0deaf89533b13c20ff50ff3f03ff3a2daa8d1329a6a6d17a58c422cbe5ee2f80aa0d0754b6fa85d507289806f64b5ce973e4ded8ec2afb631c2ee13b007eba090cda0a762a467cda2fb000a163abbde837a5d22dc526c8101ad9f32d93dfde1c67765a0508c8133b154fa93189918d82e1048ee0e4094064ddbcee9cfbecf6867546c2380", # noqa: E501 + "0xf90151a000595129cf1c67ce97ed615df7184fb47a0d018d9147a2a7952a639e464cdfd380a052081f67d885b439bee62a1c4e09c02a1ec729aef4d92be6584a29141a79c5c7a0d99cae2bc3b6fc3e8e2767b4d7a5884b9b2d9d20da7890318beefcdb9c7346d58080a0f63571735d99e763dafadb03d1abe3a93a98740ecddc8514d13df46a35a8d94680a081870f4697e57436ccdd8bdc1d624d7bc07861748ff8b3a352334df68f2c03ada0f0252504ee8753335ecf0ca1f73cf13d4505783ed5110bf4e9b384a68ad88f69a0d38a18ef7b993c9ad2d848453e7722c26998ff3d63e243b99cdab0dabf84157ea06e5ad479dbda7f1647ed613e35d837f5d2c697ef34160f3665173186553ee9c280a0bf8371cac505b6ea0cb0f67ef744713f306a2455f3f8844cfa527c62db59c69980a0d6d689405b1cf73786c5fdabb55ec22f9b5712d1ba9c0bfcd46d4b93721fcac780", # noqa: E501 + "0xf8669d37f29e142d49f8824d4e7f1735ec3da219687387629b5fccd86812df84b846f8440180a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a01d93f60f105899172f7255c030301c3af4564edd4a48577dbdc448aec7ddb0ac", # noqa: E501 + ], + "address": "0x7f0d15c7faae65896648c8273b6d7e43f58fa842", + "balance": "0x0", + "codeHash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", # noqa: E501 + "nonce": "0x0", + "storageHash": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", # noqa: E501 + "storageProof": [ + { + "key": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", # noqa: E501 + "proof": [], + "value": "0x0", + } + ], + }, } +# curl https://mainnet.infura.io/v3/YOUR_KEY_HERE \ +# -X POST \ +# -H "Content-Type: application/json" \ +# --data '{"method": "eth_getTransactionReceipt", +# "params": ["0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b"], +# "id": 1,"jsonrpc": "2.0"}' EXPECTED_ACCOUNT_PROOF = [ "0x0ac1030a150157f96e6b86cdefdb3d412547816a82e3e0ebf9d212e8010a1e2f65746865726d696e742e74797065732e76312e4574684163636f756e7412c5010a7f0a2a63726331326c756b75367578656868616b303270793472637a36357a753073776837776a737277307070124f0a282f65746865726d696e742e63727970746f2e76312e657468736563703235366b312e5075624b657912230a21026e710a62a342de0ed4d7c4532dcbcbbafbf19652ed67b237efab70e8b207efac200112423078633564323436303138366637323333633932376537646232646363373033633065353030623635336361383232373362376266616438303435643835613437301a0b0801180120012a03000202222b08011204020402201a2120e2a580b805b8b4d1f80793092cefe57965d9582ba8e31505a72cf31a55fa173d222b08011204040802201a21206c0bd60f0d887a5f99dd023f133dfd12412b074c0c442ab8a25b17048ff34ae022290801122506100220a66ec49c8058aef1eabb21a9610e16227d95982482db0ab5b032f823d457c2b920222b080112040a2e02201a2120af3944b847407590f1b2a95edcd1c2c5408e27a404e0b22267bcc2d46df700ed", # noqa: E501 "0x0aff010a0361636312205632d1620b29d277324e7473898ac9e587a99a62022931b33ce6d0be3b19137b1a090801180120012a0100222708011201011a20f5b8da7f66d134e34242575499b1f125c07af21b36685c31f9a8999c71a21daf222708011201011a20b8ef619094b2b40ae87dd1d3413c5af70d9c43256dfea123ca835baa53ad54a4222708011201011a20b7d06a60784c017041761d99ed17a2d2d68ceb4eccf39bd9a527773f21e5b688222708011201011a20a54531b68a71accb459f478724bde077a82c9079ef2be7e0b8dc47764f1b96d2222708011201011a204f83dd3fed3f48e1dff2fe125c5d22f578b613ddb45bdc12d4bc1841232d9a8b", # noqa: E501 @@ -40,47 +57,77 @@ "jsonrpc": "2.0", "id": 0, "result": { - "hash": "0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b", # noqa: E501 "blockHash": "0x1d59ff54b1eb26b013ce3cb5fc9dab3705b415a67127a003c3e61eb445bb8df2", # noqa: E501 "blockNumber": "0x5daf3b", + "chainId": "0x1", "from": "0xa7d9ddbe1f17865597fbd27ec712455208b6b76d", "gas": "0xc350", "gasPrice": "0x4a817c800", + "hash": "0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b", # noqa: E501 "input": "0x68656c6c6f21", "nonce": "0x15", "r": "0x1b5e176d927f8e9ab405058b2d2457392da3e20f328b16ddabcebc33eaac5fea", "s": "0x4ba69724e8f69de52f0125ad8b3c5c2cef33019bac3249e2c0a2192766d1721c", "to": "0xf02c1c8e6114b1dbe8937a39260b5b0a374432bb", "transactionIndex": "0x41", + "type": "0x0", "v": "0x25", "value": "0xf3dbb76162000", }, } +# curl https://mainnet.infura.io/v3/YOUR_KEY_HERE \ +# -X POST \ +# -H "Content-Type: application/json" \ +# -d '{"jsonrpc": "2.0","method": "eth_feeHistory", +# "params": [4, "latest", [25, 75]],"id": 1}' + EXPECTED_FEE_HISTORY = { - "oldestBlock": 3, - "reward": [[220, 7145389], [1000000, 6000213], [550, 550], [125, 12345678]], - "baseFeePerGas": [202583058, 177634473, 155594425, 136217133, 119442408], - "gasUsedRatio": [ - 0.007390479689642084, - 0.0036988514889990873, - 0.0018512333048507866, - 0.00741217041320997, - ], + "jsonrpc": "2.0", + "id": 1, + "result": { + "baseFeePerGas": [ + "0x3043e3967", + "0x2ffe341bf", + "0x309363803", + "0x2b09095a4", + "0x2994cf12a", + ], + "gasUsedRatio": [0.4774405666666667, 0.5485699666666667, 0.0437691, 0.3648538], + "oldestBlock": "0xf15b41", + "reward": [ + ["0x3b9aca00", "0x77359400"], + ["0x59682f00", "0x9502f900"], + ["0x59682f00", "0x59682f00"], + ["0x21797ced", "0x59682f00"], + ], + }, } +# curl https://mainnet.infura.io/v3/YOUR_KEY_HERE \ +# -X POST \ +# -H "Content-Type: application/json" \ +# --data '{"method": "eth_getTransactionReceipt", +# "params": ["0xe25a4c707d3f981afa8ec103b1bc0bee9c6b7bea75e76ffa0a221d5239a7066a"]," +# id": 1,"jsonrpc": "2.0"}' EXPECTED_GET_TRANSACTION_RECEIPT = { - "blockHash": "0x4e3a3754410177e6937ef1f84bba68ea139e8d1a2258c5f85db9f1cd715a1bdd", - "blockNumber": 46147, - "contractAddress": None, - "cumulativeGasUsed": 21000, - "from": "0xA1E4380A3B1f749673E270229993eE55F35663b4", - "gasUsed": 21000, - "logs": [], - "logsBloom": "0x000000000000000000000000000000000000000000000000...0000", - "status": 1, # 0 or 1 - "to": "0x5DF9B87991262F6BA471F09758CDE1c0FC1De734", - "transactionHash": "0x5c504ed432cb51138bcf09aa5e8a410dd4a1e204ef84bfed1be16dfba1b22060", # noqa: E501 - "transactionIndex": 0, + "jsonrpc": "2.0", + "result": { + "blockHash": "0x42aa557e22141e0eba2d42258c010820ef080f2c7ecd0ad18cb53047b7e0421f", # noqa: E501 + "blockNumber": "0xa50131", + "contractAddress": None, + "cumulativeGasUsed": "0xb72e24", + # "effectiveGasPrice": "0x147d357000", + "from": "0x56ac35db407fe1fb4977edd41f712aa5d8e7eb08", + "gasUsed": "0x5208", + "logs": [], + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", # noqa: E501 + "status": "0x1", + "to": "0x56ac35db407fe1fb4977edd41f712aa5d8e7eb08", + "transactionHash": "0xe25a4c707d3f981afa8ec103b1bc0bee9c6b7bea75e76ffa0a221d5239a7066a", # noqa: E501 + "transactionIndex": "0x9a", + "type": "0x0", + }, + "id": 1, } diff --git a/tests/integration_tests/network.py b/tests/integration_tests/network.py index 3134151524..c638e2a563 100644 --- a/tests/integration_tests/network.py +++ b/tests/integration_tests/network.py @@ -68,8 +68,12 @@ def __init__(self, w3): self.w3 = w3 -def setup_ethermint(path, base_port): - cfg = Path(__file__).parent / "configs/default.jsonnet" +def setup_ethermint(path, base_port, long_timeout_commit=False): + cfg = Path(__file__).parent / ( + "configs/default.jsonnet" + if long_timeout_commit + else "configs/long_timeout_commit.jsonnet" + ) yield from setup_custom_ethermint(path, base_port, cfg) diff --git a/tests/integration_tests/test_basic.py b/tests/integration_tests/test_basic.py deleted file mode 100644 index ed2b19fec1..0000000000 --- a/tests/integration_tests/test_basic.py +++ /dev/null @@ -1,3 +0,0 @@ -def test_basic(cluster): - w3 = cluster.w3 - assert w3.eth.chain_id == 9000 diff --git a/tests/integration_tests/test_filters.py b/tests/integration_tests/test_filters.py index 8a10e5b9e1..bf114eb82c 100644 --- a/tests/integration_tests/test_filters.py +++ b/tests/integration_tests/test_filters.py @@ -1,13 +1,97 @@ +from pathlib import Path + import pytest from web3 import Web3 +from .network import setup_custom_ethermint, setup_ethermint from .utils import ( ADDRS, CONTRACTS, deploy_contract, send_successful_transaction, send_transaction, + w3_wait_for_new_blocks, +) + + +@pytest.fixture(scope="module") +def custom_ethermint(tmp_path_factory): + path = tmp_path_factory.mktemp("filters") + yield from setup_ethermint(path, 26200, long_timeout_commit=True) + + +@pytest.fixture(scope="module") +def ethermint_indexer(tmp_path_factory): + path = tmp_path_factory.mktemp("indexer") + yield from setup_custom_ethermint( + path, 26660, Path(__file__).parent / "configs/enable-indexer.jsonnet" + ) + + +@pytest.fixture( + scope="module", params=["ethermint", "geth", "ethermint-ws", "enable-indexer"] ) +def cluster(request, custom_ethermint, ethermint_indexer, geth): + """ + run on both ethermint and geth + """ + provider = request.param + if provider == "ethermint": + yield custom_ethermint + elif provider == "geth": + yield geth + elif provider == "ethermint-ws": + ethermint_ws = custom_ethermint.copy() + ethermint_ws.use_websocket() + yield ethermint_ws + elif provider == "enable-indexer": + yield ethermint_indexer + else: + raise NotImplementedError + + +def test_basic(cluster): + w3 = cluster.w3 + assert w3.eth.chain_id == 9000 + + +# Smart contract names +GREETER_CONTRACT = "Greeter" +ERC20_CONTRACT = "TestERC20A" + +# ChangeGreeting topic from Greeter contract calculated from event signature +CHANGE_GREETING_TOPIC = Web3.keccak(text="ChangeGreeting(address,string)") +# ERC-20 Transfer event topic +TRANSFER_TOPIC = Web3.keccak(text="Transfer(address,address,uint256)") + + +def test_get_logs_by_topic(cluster): + w3: Web3 = cluster.w3 + + contract = deploy_contract(w3, CONTRACTS["Greeter"]) + + topic = Web3.keccak(text="ChangeGreeting(address,string)") + + # with tx + tx = contract.functions.setGreeting("world").build_transaction() + receipt = send_transaction(w3, tx) + assert receipt.status == 1 + + # The getLogs method under the hood works as a filter + # with the specified topics and a block range. + # If the block range is not specified, it defaults + # to fromBlock: "latest", toBlock: "latest". + # Then, if we make a getLogs call within the same block that the tx + # happened, we will get a log in the result. However, if we make the call + # one or more blocks later, the result will be an empty array. + logs = w3.eth.get_logs({"topics": [topic.hex()]}) + + assert len(logs) == 1 + assert logs[0]["address"] == contract.address + + w3_wait_for_new_blocks(w3, 2) + logs = w3.eth.get_logs({"topics": [topic.hex()]}) + assert len(logs) == 0 def test_pending_transaction_filter(cluster): @@ -17,6 +101,7 @@ def test_pending_transaction_filter(cluster): # without tx assert flt.get_new_entries() == [] # GetFilterChanges + w3_wait_for_new_blocks(w3, 1, sleep=0.1) # with tx txhash = send_successful_transaction(w3) assert txhash in flt.get_new_entries() diff --git a/tests/integration_tests/test_grpc_only.py b/tests/integration_tests/test_grpc_only.py index 71e8de4f7f..988aa87ba5 100644 --- a/tests/integration_tests/test_grpc_only.py +++ b/tests/integration_tests/test_grpc_only.py @@ -1,6 +1,7 @@ import base64 import json import subprocess +import time from pathlib import Path import pytest @@ -13,6 +14,7 @@ decode_bech32, deploy_contract, supervisorctl, + wait_for_block, wait_for_port, ) @@ -58,33 +60,43 @@ def test_grpc_mode(custom_ethermint): "to": contract.address, "data": contract.encodeABI(fn_name="currentChainID"), } - api_port = ports.api_port(custom_ethermint.base_port(2)) + api_port = ports.api_port(custom_ethermint.base_port(1)) # in normal mode, grpc query works even if we don't pass chain_id explicitly - rsp = grpc_eth_call(api_port, msg) - print(rsp) - assert "code" not in rsp, str(rsp) - assert 9000 == int.from_bytes(base64.b64decode(rsp["ret"].encode()), "big") - + success = False + max_retry = 3 + sleep = 1 + for i in range(max_retry): + rsp = grpc_eth_call(api_port, msg) + ret = rsp["ret"] + valid = ret is not None + if valid and 9000 == int.from_bytes(base64.b64decode(ret.encode()), "big"): + success = True + break + time.sleep(sleep) + assert success + # wait 1 more block for both nodes to avoid node stopped before tnx get included + for i in range(2): + wait_for_block(custom_ethermint.cosmos_cli(i), 1) supervisorctl( - custom_ethermint.base_dir / "../tasks.ini", "stop", "ethermint_9000-1-node2" + custom_ethermint.base_dir / "../tasks.ini", "stop", "ethermint_9000-1-node1" ) # run grpc-only mode directly with existing chain state - with (custom_ethermint.base_dir / "node2.log").open("w") as logfile: + with (custom_ethermint.base_dir / "node1.log").open("a") as logfile: proc = subprocess.Popen( [ "ethermintd", "start", "--grpc-only", "--home", - custom_ethermint.base_dir / "node2", + custom_ethermint.base_dir / "node1", ], stdout=logfile, stderr=subprocess.STDOUT, ) try: # wait for grpc and rest api ports - grpc_port = ports.grpc_port(custom_ethermint.base_port(2)) + grpc_port = ports.grpc_port(custom_ethermint.base_port(1)) wait_for_port(grpc_port) wait_for_port(api_port) @@ -99,9 +111,8 @@ def test_grpc_mode(custom_ethermint): assert "validator does not exist" in rsp["message"] # pass the first validator's consensus address to grpc query - cons_addr = decode_bech32( - custom_ethermint.cosmos_cli(0).consensus_address() - ) + addr = custom_ethermint.cosmos_cli(0).consensus_address() + cons_addr = decode_bech32(addr) # should work with both chain_id and proposer_address set rsp = grpc_eth_call( diff --git a/tests/integration_tests/test_priority.py b/tests/integration_tests/test_priority.py index c3de9cec0f..c505f7a589 100644 --- a/tests/integration_tests/test_priority.py +++ b/tests/integration_tests/test_priority.py @@ -1,11 +1,19 @@ import sys -from .network import Ethermint +import pytest + +from .network import setup_ethermint from .utils import ADDRS, KEYS, eth_to_bech32, sign_transaction, wait_for_new_blocks PRIORITY_REDUCTION = 1000000 +@pytest.fixture(scope="module") +def custom_ethermint(tmp_path_factory): + path = tmp_path_factory.mktemp("priority") + yield from setup_ethermint(path, 26800, long_timeout_commit=True) + + def effective_gas_price(tx, base_fee): if "maxFeePerGas" in tx: # dynamic fee tx @@ -27,7 +35,7 @@ def tx_priority(tx, base_fee): return (tx["gasPrice"] - base_fee) // PRIORITY_REDUCTION -def test_priority(ethermint: Ethermint): +def test_priority(ethermint): """ test priorities of different tx types @@ -112,7 +120,7 @@ def test_priority(ethermint: Ethermint): assert all(i1 > i2 for i1, i2 in zip(tx_indexes, tx_indexes[1:])) -def test_native_tx_priority(ethermint: Ethermint): +def test_native_tx_priority(ethermint): cli = ethermint.cosmos_cli() base_fee = cli.query_base_fee() print("base_fee", base_fee) diff --git a/tests/integration_tests/test_rollback.py b/tests/integration_tests/test_rollback.py index 1fbe316356..f6dd656a71 100644 --- a/tests/integration_tests/test_rollback.py +++ b/tests/integration_tests/test_rollback.py @@ -10,7 +10,7 @@ from .utils import supervisorctl, wait_for_block, wait_for_port -def update_node2_cmd(path, cmd, i): +def update_node_cmd(path, cmd, i): ini_path = path / SUPERVISOR_CONFIG_FILE ini = configparser.RawConfigParser() ini.read(ini_path) @@ -29,7 +29,7 @@ def update_node2_cmd(path, cmd, i): def post_init(broken_binary): def inner(path, base_port, config): chain_id = "ethermint_9000-1" - update_node2_cmd(path / chain_id, broken_binary, 2) + update_node_cmd(path / chain_id, broken_binary, 1) return inner @@ -66,33 +66,33 @@ def test_rollback(custom_ethermint): - use rollback command to rollback the db. - switch to correct binary should make the node syncing again. """ - wait_for_port(ports.rpc_port(custom_ethermint.base_port(2))) + target_port = ports.rpc_port(custom_ethermint.base_port(1)) + wait_for_port(target_port) - print("wait for node2 to sync the first 10 blocks") - cli2 = custom_ethermint.cosmos_cli(2) - wait_for_block(cli2, 10) + print("wait for node1 to sync the first 10 blocks") + cli1 = custom_ethermint.cosmos_cli(1) + wait_for_block(cli1, 10) print("wait for a few more blocks on the healthy nodes") - cli = custom_ethermint.cosmos_cli(0) - wait_for_block(cli, 13) + cli0 = custom_ethermint.cosmos_cli(0) + wait_for_block(cli0, 13) # (app hash mismatch happens after the 10th block, detected in the 11th block) - print("check node2 get stuck at block 10") - assert cli2.block_height() == 10 + print("check node1 get stuck at block 10") + assert cli1.block_height() == 10 - print("stop node2") + print("stop node1") supervisorctl( - custom_ethermint.base_dir / "../tasks.ini", "stop", "ethermint_9000-1-node2" + custom_ethermint.base_dir / "../tasks.ini", "stop", "ethermint_9000-1-node1" ) - print("do rollback on node2") - cli2.rollback() + print("do rollback on node1") + cli1.rollback() print("switch to normal binary") - update_node2_cmd(custom_ethermint.base_dir, "ethermintd", 2) + update_node_cmd(custom_ethermint.base_dir, "ethermintd", 1) supervisorctl(custom_ethermint.base_dir / "../tasks.ini", "update") - wait_for_port(ports.rpc_port(custom_ethermint.base_port(2))) + wait_for_port(target_port) - print("check node2 sync again") - cli2 = custom_ethermint.cosmos_cli(2) - wait_for_block(cli2, 15) + print("check node1 sync again") + wait_for_block(cli1, 15) diff --git a/tests/integration_tests/test_types.py b/tests/integration_tests/test_types.py index 2f41c66c03..f4452360a2 100644 --- a/tests/integration_tests/test_types.py +++ b/tests/integration_tests/test_types.py @@ -49,8 +49,7 @@ def get_blocks(ethermint_rpc_ws, geth, with_transactions): with_transactions, ], ) - res, err = same_types(eth_rsp, geth_rsp) - assert res, err + compare_types(eth_rsp, geth_rsp) # Get not existing block make_same_rpc_calls( @@ -179,8 +178,7 @@ def test_get_storage_at(ethermint_rpc_ws, geth): contract = deploy_and_wait(w3) res = eth_rpc.make_request("eth_getStorageAt", [contract.address, "0x0", "latest"]) - res, err = same_types(res["result"], EXPECTED_GET_STORAGE_AT) - assert res, err + compare_types(res["result"], EXPECTED_GET_STORAGE_AT) def send_tnx(w3, tx_value=10): @@ -215,16 +213,15 @@ def test_get_proof(ethermint_rpc_ws, geth): proof = (eth_rpc.make_request( method, [validator, ["0x0"], hex(res["blockNumber"])] ))["result"] - res, err = same_types(proof, EXPECTED_GET_PROOF) - assert res, err + compare_types(proof, EXPECTED_GET_PROOF["result"]) assert proof["accountProof"], EXPECTED_ACCOUNT_PROOF assert proof["storageProof"][0]["proof"], EXPECTED_STORAGE_PROOF - proof = (geth_rpc.make_request( + _ = send_and_get_hash(w3) + proof = eth_rpc.make_request( method, [validator, ["0x0"], "latest"] - ))["result"] - res, err = same_types(proof, EXPECTED_GET_PROOF) - assert res, err + ) + compare_types(proof, EXPECTED_GET_PROOF) def test_get_code(ethermint_rpc_ws, geth): @@ -241,9 +238,8 @@ def test_get_code(ethermint_rpc_ws, geth): # Do an ethereum transfer contract = deploy_and_wait(w3) code = eth_rpc.make_request("eth_getCode", [contract.address, "latest"]) - expected = {"id": "4", "jsonrpc": "2.0", "result": "0x"} - res, err = same_types(code, expected) - assert res, err + expected = {"id": 4, "jsonrpc": "2.0", "result": "0x"} + compare_types(code, expected) def test_get_block_transaction_count(ethermint_rpc_ws, geth): @@ -255,7 +251,7 @@ def test_get_block_transaction_count(ethermint_rpc_ws, geth): ) make_same_rpc_calls( - eth_rpc, geth_rpc, "eth_getBlockTransactionCountByNumber", ["0x100"] + eth_rpc, geth_rpc, "eth_getBlockTransactionCountByNumber", ["0x1000"] ) tx_hash = send_and_get_hash(w3) @@ -267,9 +263,8 @@ def test_get_block_transaction_count(ethermint_rpc_ws, geth): "eth_getBlockTransactionCountByNumber", [block_number] ) - expected = {"id": "1", "jsonrpc": "2.0", "result": "0x1"} - res, err = same_types(block_res, expected) - assert res, err + expected = {"id": 1, "jsonrpc": "2.0", "result": "0x1"} + compare_types(block_res, expected) make_same_rpc_calls( eth_rpc, @@ -278,9 +273,8 @@ def test_get_block_transaction_count(ethermint_rpc_ws, geth): ["0x4e3a3754410177e6937ef1f84bba68ea139e8d1a2258c5f85db9f1cd715a1bdd"], ) block_res = eth_rpc.make_request("eth_getBlockTransactionCountByHash", [block_hash]) - expected = {"id": "1", "jsonrpc": "2.0", "result": "0x1"} - res, err = same_types(block_res, expected) - assert res, err + expected = {"id": 1, "jsonrpc": "2.0", "result": "0x1"} + compare_types(block_res, expected) def test_get_transaction(ethermint_rpc_ws, geth): @@ -297,8 +291,8 @@ def test_get_transaction(ethermint_rpc_ws, geth): tx_hash = send_and_get_hash(w3) tx_res = eth_rpc.make_request("eth_getTransactionByHash", [tx_hash]) - res, err = same_types(tx_res, EXPECTED_GET_TRANSACTION) - assert res, err + + compare_types(EXPECTED_GET_TRANSACTION, tx_res) def test_get_transaction_receipt(ethermint_rpc_ws, geth): @@ -315,8 +309,7 @@ def test_get_transaction_receipt(ethermint_rpc_ws, geth): tx_hash = send_and_get_hash(w3) tx_res = eth_rpc.make_request("eth_getTransactionReceipt", [tx_hash]) - res, err = same_types(tx_res["result"], EXPECTED_GET_TRANSACTION_RECEIPT) - assert res, err + compare_types(tx_res, EXPECTED_GET_TRANSACTION_RECEIPT) def test_fee_history(ethermint_rpc_ws, geth): @@ -327,10 +320,10 @@ def test_fee_history(ethermint_rpc_ws, geth): make_same_rpc_calls(eth_rpc, geth_rpc, "eth_feeHistory", [4, "0x5000", [10, 90]]) - fee_history = eth_rpc.make_request("eth_feeHistory", [4, "latest", [10, 90]]) + _ = send_and_get_hash(w3) + fee_history = eth_rpc.make_request("eth_feeHistory", [4, "latest", [100]]) - res, err = same_types(fee_history["result"], EXPECTED_FEE_HISTORY) - assert res, err + compare_types(fee_history, EXPECTED_FEE_HISTORY) def test_estimate_gas(ethermint_rpc_ws, geth): @@ -345,11 +338,19 @@ def test_estimate_gas(ethermint_rpc_ws, geth): make_same_rpc_calls(eth_rpc, geth_rpc, "eth_estimateGas", [{}]) +def compare_types(actual, expected): + res, err = same_types(actual, expected) + if not res: + print(err) + print(actual) + print(expected) + assert res, err + + def make_same_rpc_calls(rpc1, rpc2, method, params): res1 = rpc1.make_request(method, params) res2 = rpc2.make_request(method, params) - res, err = same_types(res1, res2) - assert res, err + compare_types(res1, res2) def test_incomplete_send_transaction(ethermint_rpc_ws, geth): @@ -363,7 +364,6 @@ def test_incomplete_send_transaction(ethermint_rpc_ws, geth): def same_types(object_a, object_b): - if isinstance(object_a, dict): if not isinstance(object_b, dict): return False, "A is dict, B is not" @@ -396,3 +396,4 @@ def same_types(object_a, object_b): + " B is type " + type(object_b).__name__, ) + diff --git a/tests/integration_tests/test_upgrade.py b/tests/integration_tests/test_upgrade.py index ce830e4130..3490f87888 100644 --- a/tests/integration_tests/test_upgrade.py +++ b/tests/integration_tests/test_upgrade.py @@ -92,9 +92,6 @@ def test_cosmovisor_upgrade(custom_ethermint: Ethermint): - check that queries on legacy blocks still works after upgrade. """ cli = custom_ethermint.cosmos_cli() - height = cli.block_height() - target_height = height + 5 - print("upgrade height", target_height) w3 = custom_ethermint.w3 contract = deploy_contract(w3, CONTRACTS["TestERC20A"]) @@ -104,6 +101,9 @@ def test_cosmovisor_upgrade(custom_ethermint: Ethermint): old_erc20_balance = contract.caller.balanceOf(ADDRS["validator"]) print("old values", old_height, old_balance, old_base_fee) + target_height = w3.eth.block_number + 10 + print("upgrade height", target_height) + plan_name = "integration-test-upgrade" rsp = cli.gov_propose( "community", @@ -120,7 +120,6 @@ def test_cosmovisor_upgrade(custom_ethermint: Ethermint): # get proposal_id ev = parse_events(rsp["logs"])["submit_proposal"] - assert ev["proposal_type"] == "SoftwareUpgrade", rsp proposal_id = ev["proposal_id"] rsp = cli.gov_vote("validator", proposal_id, "yes") diff --git a/tests/integration_tests/utils.py b/tests/integration_tests/utils.py index 6c718d99ab..379b78be80 100644 --- a/tests/integration_tests/utils.py +++ b/tests/integration_tests/utils.py @@ -64,22 +64,21 @@ def wait_for_port(port, host="127.0.0.1", timeout=40.0): ) from ex -def w3_wait_for_new_blocks(w3, n): +def w3_wait_for_new_blocks(w3, n, sleep=0.5): begin_height = w3.eth.block_number while True: - time.sleep(0.5) + time.sleep(sleep) cur_height = w3.eth.block_number if cur_height - begin_height >= n: break -def wait_for_new_blocks(cli, n): - begin_height = int((cli.status())["SyncInfo"]["latest_block_height"]) - while True: - time.sleep(0.5) +def wait_for_new_blocks(cli, n, sleep=0.5): + cur_height = begin_height = int((cli.status())["SyncInfo"]["latest_block_height"]) + while cur_height - begin_height < n: + time.sleep(sleep) cur_height = int((cli.status())["SyncInfo"]["latest_block_height"]) - if cur_height - begin_height >= n: - break + return cur_height def wait_for_block(cli, height, timeout=240):