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

fix(tests): fix failing tests #2085

Merged
merged 54 commits into from Apr 15, 2024
Merged

fix(tests): fix failing tests #2085

merged 54 commits into from Apr 15, 2024

Conversation

mariocynicys
Copy link
Collaborator

@mariocynicys mariocynicys commented Mar 11, 2024

This PR fixes failing unit and integration tests.

The tests were failing for various reasons:

  • Apparently one CI test (test_nonce_lock) didn't have a fund provider on MacOs and Windows (there is the possibility this might flaky instead, will be known from the logs of multiple CI runs when they are available) has a flaky nonce locking (doesn't work all the time).
  • One test (test_process_price_request) used an outdated URL.
  • Other unit tests were using RICK and MORTY RPCs which are disabled (and replaced by DOC and MARTY).
  • tendermint tests fail because the RPC we are using returns an extra field index: bool which we fail to parse since we use tendermint-rpc = 23.7 (old tendermint version). was also because some low balance test addresses and failing IBC channels.
  • Many other tests are failing because JST token on ETH can't be enabled (contract address not found), probably because the used ETH_DEV_NODE changed or something. Should be updated to use a local geth node instead.

Deps changes:

Deps updated (coins):

  • tendermint-rpc = { version = "=0.23.7", default-features = false } -> tendermint-rpc = { version = "0.32.0", default-features = false }

  • cosmrs = { version = "0.7", default-features = false } -> cosmrs = { version = "0.14.0", default-features = false }

  • prost = { version = "0.10" } -> prost = { version = "0.11" }

  • tonic = { version = "0.7", default-features = false, features = ["prost", "codegen", "compression"] } -> tonic = { version = "0.9", default-features = false, features = ["prost", "codegen", "gzip"] }

  • prost-build = { version = "0.10.4", default-features = false } -> prost-build = { version = "0.11", default-features = false }

  • tonic-build = { version = "0.7", default-features = false, features = ["prost", "compression"] } -> tonic-build = { version = "0.9", default-features = false, features = ["prost"] }

Deps removed (coins):

  • tendermint-config = { version = "0.23.7", default-features = false } - didn't seem to be used

Deps updated (mm2_net):

  • prost = { version = "0.10" } -> prost = { version = "0.11" }
  • tonic = { version = "0.7", default-features = false, features = ["prost", "codegen"] } -> tonic = { version = "0.9", default-features = false, features = ["prost", "codegen"] }

#2085 (comment)

@mariocynicys mariocynicys added in progress Changes will be made from the author testing labels Mar 11, 2024
@mariocynicys mariocynicys force-pushed the fix-failing-tests branch 2 times, most recently from 3210807 to 7c83003 Compare March 13, 2024 07:14
@borngraced
Copy link
Member

borngraced commented Mar 13, 2024

@mariocynicys please don't forget to remove register_wasm_log from any WASM unit tests that uses it to prevent unnecessary spamming of CI build logs..so we can focus more on test that are passing/failing. thanks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fixes!
I have just a note for now.
Please add dependency changes info in PR description (when PR is r2r, or now if you wana). What was deleted/added/version changes and the reason of it.

Something like this:

Deps changes:

Needed to upgrade version of cosmrs due to breaking changes in tendermint-rpc which fail our tests.
cosmrs = { version = "0.7", default-features = false } -> cosmrs = { version = "0.14.0", default-features = false }

etc.

We have established this rule for PRs to simplify the security team's process of conducting code security checks.

@laruh
Copy link
Member

laruh commented Mar 14, 2024

PS: branch started to have conflicts

@mariocynicys mariocynicys force-pushed the fix-failing-tests branch 3 times, most recently from bc20355 to a74eb1c Compare March 14, 2024 08:22
@mariocynicys
Copy link
Collaborator Author

Deps changes:

Deps updated (coins):

  • tendermint-rpc = { version = "=0.23.7", default-features = false } -> tendermint-rpc = { version = "0.32.0", default-features = false }

  • cosmrs = { version = "0.7", default-features = false } -> cosmrs = { version = "0.14.0", default-features = false }

  • prost = { version = "0.10" } -> prost = { version = "0.11" }

  • tonic = { version = "0.7", default-features = false, features = ["prost", "codegen", "compression"] } -> tonic = { version = "0.9", default-features = false, features = ["prost", "codegen", "gzip"] }

  • prost-build = { version = "0.10.4", default-features = false } -> prost-build = { version = "0.11", default-features = false }

  • tonic-build = { version = "0.7", default-features = false, features = ["prost", "compression"] } -> tonic-build = { version = "0.9", default-features = false, features = ["prost"] }

Deps removed (coins):

  • tendermint-config = { version = "0.23.7", default-features = false } - didn't seem to be used

Deps updated (mm2_net):

  • prost = { version = "0.10" } -> prost = { version = "0.11" }
  • tonic = { version = "0.7", default-features = false, features = ["prost", "codegen"] } -> tonic = { version = "0.9", default-features = false, features = ["prost", "codegen"] }

CI has been updated to install protoc since it's now a build dependency (why?)


The latest tendermint version is 0.34 (cosmrs 0.15) but we couldn't use it since they updated their prost version to 0.12 and tonic never updated to that version. I picked the latest versions of both tendermint-rpc and tonic where they have a matching prost version.

This could have be solved by depending on different versions of prost at the same time (cosmrs & tendermint on prost 0.12 while tonic on prost 0.11) but this is not really feasible since prost's derive macro #[derive(prost::Message)] uses a hard coded absolute path to trait (::prost::Message) that makes us not able to patch some specific message to use prost 0.10 while other uses prost 0.11 (similar to the issue with futures03/select!)

@mariocynicys mariocynicys force-pushed the fix-failing-tests branch 2 times, most recently from 0b99ca9 to d6f127a Compare March 14, 2024 14:59
@shamardy
Copy link
Collaborator

@mariocynicys please push cargo.lock changes so that I can review it too

@mariocynicys mariocynicys force-pushed the fix-failing-tests branch 3 times, most recently from 7415507 to 13bf572 Compare March 19, 2024 16:08
@mariocynicys
Copy link
Collaborator Author

These are logs of flaky tests since github will purge these logs soon:

set_price_with_cancel_previous_should_broadcast_cancelled_message is flaky. This has been observed on windows and macos so far:

mm2_tests::mm2_tests_inner::set_price_with_cancel_previous_should_broadcast_cancelled_message (windows)
2024-03-23T10:06:08.4848840Z failures:
2024-03-23T10:06:08.4851952Z 
2024-03-23T10:06:08.4853792Z ---- mm2_tests::mm2_tests_inner::set_price_with_cancel_previous_should_broadcast_cancelled_message stdout ----
2024-03-23T10:06:08.4856398Z 23 10:03:15, mm2_tests_inner:2292] Bob log path: C:\Users\RUNNER~1\AppData\Local\Temp\mm2_2024-03-23_10-03-14-788_127.0.0.224\mm2.log
2024-03-23T10:06:08.4892782Z 23 10:03:15, for_tests:1375] sending rpc request {"userpass":"pass","method":"electrum","coin":"RICK","servers":[{"url":"electrum1.cipig.net:10020"},{"url":"electrum2.cipig.net:10020"},{"url":"electrum3.cipig.net:10020"}],"mm2":1,"tx_history":false,"path_to_address":{"account":0,"is_change":false,"address_index":0}} to http://127.0.0.224:7783
2024-03-23T10:06:08.4896980Z 23 10:03:16, for_tests:1375] sending rpc request {"userpass":"pass","method":"electrum","coin":"MORTY","servers":[{"url":"electrum1.cipig.net:10021"},{"url":"electrum2.cipig.net:10021"},{"url":"electrum3.cipig.net:10021"}],"mm2":1,"tx_history":false,"path_to_address":{"account":0,"is_change":false,"address_index":0}} to http://127.0.0.224:7783
2024-03-23T10:06:08.4903163Z 23 10:03:15, mm2_tests_inner:2294] enable_coins (bob): {"RICK": CoinInitResponse { result: "success", address: "RRnMcSeKiLrNdbp91qNVQwwXx5azD4S4CD", balance: BigDecimal("7.777"), unspendable_balance: BigDecimal("0"), coin: "RICK", required_confirmations: 1, requires_notarization: false, mature_confirmations: Some(100) }, "MORTY": CoinInitResponse { result: "success", address: "RRnMcSeKiLrNdbp91qNVQwwXx5azD4S4CD", balance: BigDecimal("7.777"), unspendable_balance: BigDecimal("0"), coin: "MORTY", required_confirmations: 1, requires_notarization: false, mature_confirmations: Some(100) }}
2024-03-23T10:06:08.4909011Z 23 10:03:17, mm2_tests_inner:2307] Issue sell request on Bob side by setting base/rel price…
2024-03-23T10:06:08.4911193Z 23 10:03:17, for_tests:1375] sending rpc request {"userpass":"pass","method":"setprice","base":"RICK","rel":"MORTY","price":0.9,"volume":"0.9"} to http://127.0.0.224:7783
2024-03-23T10:06:08.4913474Z 23 10:03:18, mm2_tests_inner:2329] Alice log path: C:\Users\RUNNER~1\AppData\Local\Temp\mm2_2024-03-23_10-03-17-697_127.0.0.29\mm2.log
2024-03-23T10:06:08.4916653Z 23 10:03:18, for_tests:1375] sending rpc request {"userpass":"pass","method":"electrum","coin":"RICK","servers":[{"url":"electrum1.cipig.net:10020"},{"url":"electrum2.cipig.net:10020"},{"url":"electrum3.cipig.net:10020"}],"mm2":1,"tx_history":false,"path_to_address":{"account":0,"is_change":false,"address_index":0}} to http://127.0.0.29:7783
2024-03-23T10:06:08.4921189Z 23 10:03:19, for_tests:1375] sending rpc request {"userpass":"pass","method":"electrum","coin":"MORTY","servers":[{"url":"electrum1.cipig.net:10021"},{"url":"electrum2.cipig.net:10021"},{"url":"electrum3.cipig.net:10021"}],"mm2":1,"tx_history":false,"path_to_address":{"account":0,"is_change":false,"address_index":0}} to http://127.0.0.29:7783
2024-03-23T10:06:08.4927371Z 23 10:03:18, mm2_tests_inner:2332] enable_coins (alice): {"RICK": CoinInitResponse { result: "success", address: "RJgqmztdrC2ezyoqTXhnRfifcmDhfNPKFH", balance: BigDecimal("7.777"), unspendable_balance: BigDecimal("0"), coin: "RICK", required_confirmations: 1, requires_notarization: false, mature_confirmations: Some(100) }, "MORTY": CoinInitResponse { result: "success", address: "RJgqmztdrC2ezyoqTXhnRfifcmDhfNPKFH", balance: BigDecimal("7.777"), unspendable_balance: BigDecimal("0"), coin: "MORTY", required_confirmations: 1, requires_notarization: false, mature_confirmations: Some(100) }}
2024-03-23T10:06:08.4931882Z 23 10:03:20, mm2_tests_inner:2337] Get RICK/MORTY orderbook on Alice side
2024-03-23T10:06:08.4933380Z 23 10:03:20, for_tests:1375] sending rpc request {"userpass":"pass","method":"orderbook","base":"RICK","rel":"MORTY"} to http://127.0.0.29:7783
2024-03-23T10:06:08.4956369Z 23 10:03:20, mm2_tests_inner:2348] Alice orderbook Object({"askdepth": Number(0), "asks": Array([Object({"coin": String("RICK"), "address": String("RRnMcSeKiLrNdbp91qNVQwwXx5azD4S4CD"), "price": String("0.9"), "price_rat": Array([Array([Number(1), Array([Number(9)])]), Array([Number(1), Array([Number(10)])])]), "price_fraction": Object({"numer": String("9"), "denom": String("10")}), "maxvolume": String("0.9"), "max_volume_rat": Array([Array([Number(1), Array([Number(9)])]), Array([Number(1), Array([Number(10)])])]), "max_volume_fraction": Object({"numer": String("9"), "denom": String("10")}), "min_volume": String("0.0001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"), "min_volume_rat": Array([Array([Number(1), Array([Number(1)])]), Array([Number(1), Array([Number(9000)])])]), "min_volume_fraction": Object({"numer": String("1"), "denom": String("9000")}), "pubkey": String("022cd3021a2197361fb70b862c412bc8e44cff6951fa1de45ceabfdd9b4c520420"), "age": Number(3), "uuid": String("64745178-caa6-40e5-b87e-bec45c4e20c3"), "is_mine": Bool(false), "base_max_volume": String("0.9"), "base_max_volume_fraction": Object({"numer": String("9"), "denom": String("10")}), "base_max_volume_rat": Array([Array([Number(1), Array([Number(9)])]), Array([Number(1), Array([Number(10)])])]), "base_min_volume": String("0.0001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"), "base_min_volume_fraction": Object({"numer": String("1"), "denom": String("9000")}), "base_min_volume_rat": Array([Array([Number(1), Array([Number(1)])]), Array([Number(1), Array([Number(9000)])])]), "rel_max_volume": String("0.81"), "rel_max_volume_fraction": Object({"numer": String("81"), "denom": String("100")}), "rel_max_volume_rat": Array([Array([Number(1), Array([Number(81)])]), Array([Number(1), Array([Number(100)])])]), "rel_min_volume": String("0.0001"), "rel_min_volume_fraction": Object({"numer": String("1"), "denom": String("10000")}), "rel_min_volume_rat": Array([Array([Number(1), Array([Number(1)])]), Array([Number(1), Array([Number(10000)])])]), "base_confs": Number(1), "base_nota": Bool(false), "rel_confs": Number(1), "rel_nota": Bool(false), "base_max_volume_aggr": String("0.9"), "base_max_volume_aggr_fraction": Object({"numer": String("9"), "denom": String("10")}), "base_max_volume_aggr_rat": Array([Array([Number(1), Array([Number(9)])]), Array([Number(1), Array([Number(10)])])]), "rel_max_volume_aggr": String("0.81"), "rel_max_volume_aggr_fraction": Object({"numer": String("81"), "denom": String("100")}), "rel_max_volume_aggr_rat": Array([Array([Number(1), Array([Number(81)])]), Array([Number(1), Array([Number(100)])])])})]), "base": String("RICK"), "biddepth": Number(0), "bids": Array([]), "netid": Number(9998), "numasks": Number(1), "numbids": Number(0), "rel": String("MORTY"), "timestamp": Number(1711188200), "total_asks_base_vol": String("0.9"), "total_asks_base_vol_fraction": Object({"numer": String("9"), "denom": String("10")}), "total_asks_base_vol_rat": Array([Array([Number(1), Array([Number(9)])]), Array([Number(1), Array([Number(10)])])]), "total_asks_rel_vol": String("0.81"), "total_asks_rel_vol_fraction": Object({"numer": String("81"), "denom": String("100")}), "total_asks_rel_vol_rat": Array([Array([Number(1), Array([Number(81)])]), Array([Number(1), Array([Number(100)])])]), "total_bids_base_vol": String("0"), "total_bids_base_vol_fraction": Object({"numer": String("0"), "denom": String("1")}), "total_bids_base_vol_rat": Array([Array([Number(0), Array([])]), Array([Number(1), Array([Number(1)])])]), "total_bids_rel_vol": String("0"), "total_bids_rel_vol_fraction": Object({"numer": String("0"), "denom": String("1")}), "total_bids_rel_vol_rat": Array([Array([Number(0), Array([])]), Array([Number(1), Array([Number(1)])])])})
2024-03-23T10:06:08.4975313Z 23 10:03:20, mm2_tests_inner:2352] Issue sell request again on Bob side by setting base/rel price…
2024-03-23T10:06:08.4976572Z 23 10:03:20, for_tests:1375] sending rpc request {"userpass":"pass","method":"setprice","base":"RICK","rel":"MORTY","price":0.9,"volume":"0.9"} to http://127.0.0.224:7783
2024-03-23T10:06:08.4978097Z 23 10:03:20, mm2_tests_inner:2357] Waiting (2 seconds) for Bob to broadcast messages…
2024-03-23T10:06:08.4979900Z 23 10:03:22, mm2_tests_inner:2361] Get RICK/MORTY orderbook on Bob side
2024-03-23T10:06:08.4981523Z 23 10:03:22, for_tests:1375] sending rpc request {"userpass":"pass","method":"orderbook","base":"RICK","rel":"MORTY"} to http://127.0.0.224:7783
2024-03-23T10:06:08.4997677Z 23 10:03:22, mm2_tests_inner:2372] Bob orderbook Object({"askdepth": Number(0), "asks": Array([Object({"coin": String("RICK"), "address": String("RRnMcSeKiLrNdbp91qNVQwwXx5azD4S4CD"), "price": String("0.9"), "price_rat": Array([Array([Number(1), Array([Number(9)])]), Array([Number(1), Array([Number(10)])])]), "price_fraction": Object({"numer": String("9"), "denom": String("10")}), "maxvolume": String("0.9"), "max_volume_rat": Array([Array([Number(1), Array([Number(9)])]), Array([Number(1), Array([Number(10)])])]), "max_volume_fraction": Object({"numer": String("9"), "denom": String("10")}), "min_volume": String("0.0001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"), "min_volume_rat": Array([Array([Number(1), Array([Number(1)])]), Array([Number(1), Array([Number(9000)])])]), "min_volume_fraction": Object({"numer": String("1"), "denom": String("9000")}), "pubkey": String("022cd3021a2197361fb70b862c412bc8e44cff6951fa1de45ceabfdd9b4c520420"), "age": Number(2), "uuid": String("e4bef2c2-9332-4d4e-adc9-914ddee124f8"), "is_mine": Bool(true), "base_max_volume": String("0.9"), "base_max_volume_fraction": Object({"numer": String("9"), "denom": String("10")}), "base_max_volume_rat": Array([Array([Number(1), Array([Number(9)])]), Array([Number(1), Array([Number(10)])])]), "base_min_volume": String("0.0001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"), "base_min_volume_fraction": Object({"numer": String("1"), "denom": String("9000")}), "base_min_volume_rat": Array([Array([Number(1), Array([Number(1)])]), Array([Number(1), Array([Number(9000)])])]), "rel_max_volume": String("0.81"), "rel_max_volume_fraction": Object({"numer": String("81"), "denom": String("100")}), "rel_max_volume_rat": Array([Array([Number(1), Array([Number(81)])]), Array([Number(1), Array([Number(100)])])]), "rel_min_volume": String("0.0001"), "rel_min_volume_fraction": Object({"numer": String("1"), "denom": String("10000")}), "rel_min_volume_rat": Array([Array([Number(1), Array([Number(1)])]), Array([Number(1), Array([Number(10000)])])]), "base_confs": Number(1), "base_nota": Bool(false), "rel_confs": Number(1), "rel_nota": Bool(false), "base_max_volume_aggr": String("0.9"), "base_max_volume_aggr_fraction": Object({"numer": String("9"), "denom": String("10")}), "base_max_volume_aggr_rat": Array([Array([Number(1), Array([Number(9)])]), Array([Number(1), Array([Number(10)])])]), "rel_max_volume_aggr": String("0.81"), "rel_max_volume_aggr_fraction": Object({"numer": String("81"), "denom": String("100")}), "rel_max_volume_aggr_rat": Array([Array([Number(1), Array([Number(81)])]), Array([Number(1), Array([Number(100)])])])})]), "base": String("RICK"), "biddepth": Number(0), "bids": Array([]), "netid": Number(9998), "numasks": Number(1), "numbids": Number(0), "rel": String("MORTY"), "timestamp": Number(1711188202), "total_asks_base_vol": String("0.9"), "total_asks_base_vol_fraction": Object({"numer": String("9"), "denom": String("10")}), "total_asks_base_vol_rat": Array([Array([Number(1), Array([Number(9)])]), Array([Number(1), Array([Number(10)])])]), "total_asks_rel_vol": String("0.81"), "total_asks_rel_vol_fraction": Object({"numer": String("81"), "denom": String("100")}), "total_asks_rel_vol_rat": Array([Array([Number(1), Array([Number(81)])]), Array([Number(1), Array([Number(100)])])]), "total_bids_base_vol": String("0"), "total_bids_base_vol_fraction": Object({"numer": String("0"), "denom": String("1")}), "total_bids_base_vol_rat": Array([Array([Number(0), Array([])]), Array([Number(1), Array([Number(1)])])]), "total_bids_rel_vol": String("0"), "total_bids_rel_vol_fraction": Object({"numer": String("0"), "denom": String("1")}), "total_bids_rel_vol_rat": Array([Array([Number(0), Array([])]), Array([Number(1), Array([Number(1)])])])})
2024-03-23T10:06:08.5011515Z 23 10:03:22, mm2_tests_inner:2377] Get RICK/MORTY orderbook on Alice side
2024-03-23T10:06:08.5012464Z 23 10:03:22, for_tests:1375] sending rpc request {"userpass":"pass","method":"orderbook","base":"RICK","rel":"MORTY"} to http://127.0.0.29:7783
2024-03-23T10:06:08.5013615Z error: test failed, to rerun pass `-p mm2_main --test mm2_tests_main`
2024-03-23T10:06:08.5014170Z error: 1 target failed:
2024-03-23T10:06:08.5014610Z     `-p mm2_main --test mm2_tests_main`
2024-03-23T10:06:08.5039867Z 23 10:03:22, mm2_tests_inner:2388] Alice orderbook Object({"askdepth": Number(0), "asks": Array([Object({"coin": String("RICK"), "address": String("RRnMcSeKiLrNdbp91qNVQwwXx5azD4S4CD"), "price": String("0.9"), "price_rat": Array([Array([Number(1), Array([Number(9)])]), Array([Number(1), Array([Number(10)])])]), "price_fraction": Object({"numer": String("9"), "denom": String("10")}), "maxvolume": String("0.9"), "max_volume_rat": Array([Array([Number(1), Array([Number(9)])]), Array([Number(1), Array([Number(10)])])]), "max_volume_fraction": Object({"numer": String("9"), "denom": String("10")}), "min_volume": String("0.0001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"), "min_volume_rat": Array([Array([Number(1), Array([Number(1)])]), Array([Number(1), Array([Number(9000)])])]), "min_volume_fraction": Object({"numer": String("1"), "denom": String("9000")}), "pubkey": String("022cd3021a2197361fb70b862c412bc8e44cff6951fa1de45ceabfdd9b4c520420"), "age": Number(2), "uuid": String("e4bef2c2-9332-4d4e-adc9-914ddee124f8"), "is_mine": Bool(false), "base_max_volume": String("0.9"), "base_max_volume_fraction": Object({"numer": String("9"), "denom": String("10")}), "base_max_volume_rat": Array([Array([Number(1), Array([Number(9)])]), Array([Number(1), Array([Number(10)])])]), "base_min_volume": String("0.0001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"), "base_min_volume_fraction": Object({"numer": String("1"), "denom": String("9000")}), "base_min_volume_rat": Array([Array([Number(1), Array([Number(1)])]), Array([Number(1), Array([Number(9000)])])]), "rel_max_volume": String("0.81"), "rel_max_volume_fraction": Object({"numer": String("81"), "denom": String("100")}), "rel_max_volume_rat": Array([Array([Number(1), Array([Number(81)])]), Array([Number(1), Array([Number(100)])])]), "rel_min_volume": String("0.0001"), "rel_min_volume_fraction": Object({"numer": String("1"), "denom": String("10000")}), "rel_min_volume_rat": Array([Array([Number(1), Array([Number(1)])]), Array([Number(1), Array([Number(10000)])])]), "base_confs": Number(1), "base_nota": Bool(false), "rel_confs": Number(1), "rel_nota": Bool(false), "base_max_volume_aggr": String("1.8"), "base_max_volume_aggr_fraction": Object({"numer": String("9"), "denom": String("5")}), "base_max_volume_aggr_rat": Array([Array([Number(1), Array([Number(9)])]), Array([Number(1), Array([Number(5)])])]), "rel_max_volume_aggr": String("1.62"), "rel_max_volume_aggr_fraction": Object({"numer": String("81"), "denom": String("50")}), "rel_max_volume_aggr_rat": Array([Array([Number(1), Array([Number(81)])]), Array([Number(1), Array([Number(50)])])])}), Object({"coin": String("RICK"), "address": String("RRnMcSeKiLrNdbp91qNVQwwXx5azD4S4CD"), "price": String("0.9"), "price_rat": Array([Array([Number(1), Array([Number(9)])]), Array([Number(1), Array([Number(10)])])]), "price_fraction": Object({"numer": String("9"), "denom": String("10")}), "maxvolume": String("0.9"), "max_volume_rat": Array([Array([Number(1), Array([Number(9)])]), Array([Number(1), Array([Number(10)])])]), "max_volume_fraction": Object({"numer": String("9"), "denom": String("10")}), "min_volume": String("0.0001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"), "min_volume_rat": Array([Array([Number(1), Array([Number(1)])]), Array([Number(1), Array([Number(9000)])])]), "min_volume_fraction": Object({"numer": String("1"), "denom": String("9000")}), "pubkey": String("022cd3021a2197361fb70b862c412bc8e44cff6951fa1de45ceabfdd9b4c520420"), "age": Number(5), "uuid": String("64745178-caa6-40e5-b87e-bec45c4e20c3"), "is_mine": Bool(false), "base_max_volume": String("0.9"), "base_max_volume_fraction": Object({"numer": String("9"), "denom": String("10")}), "base_max_volume_rat": Array([Array([Number(1), Array([Number(9)])]), Array([Number(1), Array([Number(10)])])]), "base_min_volume": String("0.0001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"), "base_min_volume_fraction": Object({"numer": String("1"), "denom": String("9000")}), "base_min_volume_rat": Array([Array([Number(1), Array([Number(1)])]), Array([Number(1), Array([Number(9000)])])]), "rel_max_volume": String("0.81"), "rel_max_volume_fraction": Object({"numer": String("81"), "denom": String("100")}), "rel_max_volume_rat": Array([Array([Number(1), Array([Number(81)])]), Array([Number(1), Array([Number(100)])])]), "rel_min_volume": String("0.0001"), "rel_min_volume_fraction": Object({"numer": String("1"), "denom": String("10000")}), "rel_min_volume_rat": Array([Array([Number(1), Array([Number(1)])]), Array([Number(1), Array([Number(10000)])])]), "base_confs": Number(1), "base_nota": Bool(false), "rel_confs": Number(1), "rel_nota": Bool(false), "base_max_volume_aggr": String("0.9"), "base_max_volume_aggr_fraction": Object({"numer": String("9"), "denom": String("10")}), "base_max_volume_aggr_rat": Array([Array([Number(1), Array([Number(9)])]), Array([Number(1), Array([Number(10)])])]), "rel_max_volume_aggr": String("0.81"), "rel_max_volume_aggr_fraction": Object({"numer": String("81"), "denom": String("100")}), "rel_max_volume_aggr_rat": Array([Array([Number(1), Array([Number(81)])]), Array([Number(1), Array([Number(100)])])])})]), "base": String("RICK"), "biddepth": Number(0), "bids": Array([]), "netid": Number(9998), "numasks": Number(2), "numbids": Number(0), "rel": String("MORTY"), "timestamp": Number(1711188202), "total_asks_base_vol": String("1.8"), "total_asks_base_vol_fraction": Object({"numer": String("9"), "denom": String("5")}), "total_asks_base_vol_rat": Array([Array([Number(1), Array([Number(9)])]), Array([Number(1), Array([Number(5)])])]), "total_asks_rel_vol": String("1.62"), "total_asks_rel_vol_fraction": Object({"numer": String("81"), "denom": String("50")}), "total_asks_rel_vol_rat": Array([Array([Number(1), Array([Number(81)])]), Array([Number(1), Array([Number(50)])])]), "total_bids_base_vol": String("0"), "total_bids_base_vol_fraction": Object({"numer": String("0"), "denom": String("1")}), "total_bids_base_vol_rat": Array([Array([Number(0), Array([])]), Array([Number(1), Array([Number(1)])])]), "total_bids_rel_vol": String("0"), "total_bids_rel_vol_fraction": Object({"numer": String("0"), "denom": String("1")}), "total_bids_rel_vol_rat": Array([Array([Number(0), Array([])]), Array([Number(1), Array([Number(1)])])])})
2024-03-23T10:06:08.5065889Z thread 'mm2_tests::mm2_tests_inner::set_price_with_cancel_previous_should_broadcast_cancelled_message' panicked at 'assertion failed: `(left == right)`
2024-03-23T10:06:08.5066714Z   left: `2`,
2024-03-23T10:06:08.5067568Z  right: `1`: Alice RICK/MORTY orderbook must have exactly 1 ask', mm2src\mm2_main\tests\mm2_tests\mm2_tests_inner.rs:2390:5

Other tests (test_send_taker_fee (tx rejected by network rules), test_until_success (test might take longer than permitted, probably due to starvation)) have been observed failing sometimes on macos:

qrc20::qrc20_tests::test_send_taker_fee
2024-03-19T17:36:06.4172690Z failures:
2024-03-19T17:36:06.4173350Z 
2024-03-19T17:36:06.4175370Z ---- qrc20::qrc20_tests::test_send_taker_fee stdout ----
2024-03-19T17:36:06.4214320Z thread 'qrc20::qrc20_tests::test_send_taker_fee' panicked at 'called `Result::unwrap()` on an `Err` value: TxRecoverable(UtxoTx(Transaction { version: 1, n_time: None, overwintered: false, version_group_id: 0, inputs: [TransactionInput { previous_output: OutPoint { hash: 8190018c8557c57b43eb86148a69435b22620001fc02ed70aa4c326a49acb19a, index: 1 }, script_sig: 47304402204db86c7a1355464f91ab9496876b35f88ad0a1c776a25f0d6c9b961f579dc72802202b446c5a728904e4bbeaa59b4b29814dd56fdb95c957d9252b291522a5e78456012103693bff1b39e8b5a306810023c29b95397eb395530b106b1820ea235fd81d9ce9, sequence: 4294967295, script_witness: [] }], outputs: [TransactionOutput { value: 0, script_pubkey: 5403a08601012844a9059cbb000000000000000000000000ca1e04745e8ca0c60d8c5881531d51bec470743f00000000000000000000000000000000000000000000000000000000000f424014d362e096e873eb7907e205fadc6175c6fec7bc44c2 }, TransactionOutput { value: 70826005, script_pubkey: 76a9149e032d4b0090a11dc40fe6c47601499a35d55fbb88ac }], lock_time: 1710869720, expiry_height: 0, shielded_spends: [], shielded_outputs: [], join_splits: [], value_balance: 0, join_split_pubkey: 0000000000000000000000000000000000000000000000000000000000000000, join_split_sig: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, binding_sig: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, zcash: false, posv: false, str_d_zeel: None, tx_hash_algo: DSHA256 }), "mm2src/coins/qrc20.rs:514] rpc_clients:2287] ResponseParseError(JsonRpcError { client_info: \"coin: QRC20\", request: JsonRpcRequest { jsonrpc: \"2.0\", id: \"97\", method: \"blockchain.transaction.broadcast\", params: [String(\"01000000018190018c8557c57b43eb86148a69435b22620001fc02ed70aa4c326a49acb19a010000006a47304402204db86c7a1355464f91ab9496876b35f88ad0a1c776a25f0d6c9b961f579dc72802202b446c5a728904e4bbeaa59b4b29814dd56fdb95c957d9252b291522a5e78456012103693bff1b39e8b5a306810023c29b95397eb395530b106b1820ea235fd81d9ce9ffffffff020000000000000000625403a08601012844a9059cbb000000000000000000000000ca1e04745e8ca0c60d8c5881531d51bec470743f00000000000000000000000000000000000000000000000000000000000f424014d362e096e873eb7907e205fadc6175c6fec7bc44c215b83804000000001976a9149e032d4b0090a11dc40fe6c47601499a35d55fbb88acd8ccf965\")] }, error: Response(electrum3.cipig.net:10071, Object({\"code\": Number(1), \"message\": String(\"the transaction was rejected by network rules.\\n\\ntxn-mempool-conflict\\n[01000000018190018c8557c57b43eb86148a69435b22620001fc02ed70aa4c326a49acb19a010000006a47304402204db86c7a1355464f91ab9496876b35f88ad0a1c776a25f0d6c9b961f579dc72802202b446c5a728904e4bbeaa59b4b29814dd56fdb95c957d9252b291522a5e78456012103693bff1b39e8b5a306810023c29b95397eb395530b106b1820ea235fd81d9ce9ffffffff020000000000000000625403a08601012844a9059cbb000000000000000000000000ca1e04745e8ca0c60d8c5881531d51bec470743f00000000000000000000000000000000000000000000000000000000000f424014d362e096e873eb7907e205fadc6175c6fec7bc44c215b83804000000001976a9149e032d4b0090a11dc40fe6c47601499a35d55fbb88acd8ccf965]\")})) })")', mm2src/coins/qrc20/qrc20_tests.rs:326:10
custom_futures::repeatable::tests::test_until_success
2024-03-19T18:38:54.6233270Z failures:
2024-03-19T18:38:54.6233470Z 
2024-03-19T18:38:54.6234190Z ---- custom_futures::repeatable::tests::test_until_success stdout ----
2024-03-19T18:38:54.6236000Z 19 18:38:48, common:509] panicked at 'Expected [350ms, 800ms], but took 815.602832ms', mm2src/common/custom_futures/repeatable.rs:525:9
2024-03-19T18:38:54.6237200Z 19 18:38:48, common:510] backtrace

Test best_orders_must_return_duplicate_for_orderbook_tickers has been observed failing consistently on macos, this seems due to low balance.

mm2_tests::best_orders_tests::best_orders_must_return_duplicate_for_orderbook_tickers
2024-03-19T17:37:15.0140380Z failures:
2024-03-19T17:37:15.0140590Z 
2024-03-19T17:37:15.0141850Z ---- mm2_tests::best_orders_tests::best_orders_must_return_duplicate_for_orderbook_tickers stdout ----
2024-03-19T17:37:15.0143810Z 19 17:33:57, best_orders_tests:987] Bob log path: /var/folders/h1/8hndypj13nsbj5pn4xsnv1tm0000gn/T/mm2_2024-03-19_17-33-57-747_127.0.0.21/mm2.log
2024-03-19T17:37:15.0150270Z 19 17:33:57, for_tests:1375] sending rpc request {"userpass":"pass","method":"electrum","coin":"tBTC","servers":[{"url":"electrum1.cipig.net:10068"},{"url":"electrum2.cipig.net:10068"},{"url":"electrum3.cipig.net:10068"}],"mm2":1,"tx_history":false,"path_to_address":{"account":0,"is_change":false,"address_index":0}} to http://127.0.0.21:7783
2024-03-19T17:37:15.0155760Z 19 17:33:59, best_orders_tests:990] Bob enable tBTC: CoinInitResponse { result: "success", address: "mnPmDUfrd656SZxwhZS98xN6LqETPAmxZm", balance: BigDecimal("0"), unspendable_balance: BigDecimal("0"), coin: "tBTC", required_confirmations: 0, requires_notarization: false, mature_confirmations: Some(100) }
2024-03-19T17:37:15.0162830Z 19 17:33:59, for_tests:1375] sending rpc request {"userpass":"pass","method":"electrum","coin":"RICK","servers":[{"url":"electrum1.cipig.net:10020"},{"url":"electrum2.cipig.net:10020"},{"url":"electrum3.cipig.net:10020"}],"mm2":1,"tx_history":false,"path_to_address":{"account":0,"is_change":false,"address_index":0}} to http://127.0.0.21:7783
2024-03-19T17:37:15.0170840Z 19 17:34:00, best_orders_tests:993] Bob enable RICK: CoinInitResponse { result: "success", address: "RG9zzwUAQtSQjTrXTAStQZUyF76MDzSDei", balance: BigDecimal("7.54039315"), unspendable_balance: BigDecimal("0"), coin: "RICK", required_confirmations: 0, requires_notarization: false, mature_confirmations: Some(100) }
2024-03-19T17:37:15.0175090Z 19 17:34:00, best_orders_tests:996] Issue bob sell requests
2024-03-19T17:37:15.0178420Z 19 17:34:00, for_tests:1375] sending rpc request {"userpass":"pass","method":"setprice","base":"tBTC","rel":"RICK","price":"0.7","volume":"0.0002","min_volume":"0.00015","cancel_previous":false} to http://127.0.0.21:7783
2024-03-19T17:37:15.0184850Z thread 'mm2_tests::best_orders_tests::best_orders_must_return_duplicate_for_orderbook_tickers' panicked at '!setprice: {"error":"rpc:215] dispatcher_legacy:141] lp_ordermatch:4654] maker_swap:2182] utxo_common:4251] utxo_common:991] Not enough tBTC for swap: available 0, required at least 0.0002, locked by swaps None"}', mm2src/mm2_main/tests/mm2_tests/best_orders_tests.rs:1016:9

Copy link
Member

@borngraced borngraced left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! a question and a change request :)

I'll continue with the review after you are done with then PR.

@@ -2431,6 +2437,7 @@ async fn sign_transaction_with_keypair(
Ok((
tx.sign(key_pair.secret(), coin.chain_id),
web3_instances_with_latest_nonce,
nonce_lock,
))
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what difference does it make if we just drop the nonce_lock before returning from this function and returning it without using e.g

async fn sign_transaction_with_keypair(
    ctx: MmArc,
    coin: &EthCoin,
    key_pair: &KeyPair,
    value: U256,
    action: Action,
    data: Vec<u8>,
    gas: U256,
) -> Result<(SignedEthTx, Vec<Web3Instance>), TransactionErr> {
    let mut status = ctx.log.status_handle();
    macro_rules! tags {
        () => {
            &[&"sign"]
        };
    }
    let nonce_lock = coin.nonce_lock.lock().await;
    status.status(tags!(), "get_addr_nonce…");
    let (nonce, web3_instances_with_latest_nonce) =
        try_tx_s!(coin.clone().get_addr_nonce(coin.my_address).compat().await);
    status.status(tags!(), "get_gas_price…");
    let gas_price = try_tx_s!(coin.get_gas_price().compat().await);

    let tx = UnSignedEthTx {
        nonce,
        gas_price,
        gas,
        action,
        value,
        data,
    };

    let _ = nonce_lock;
    Ok((
        tx.sign(key_pair.secret(), coin.chain_id),
        web3_instances_with_latest_nonce,
    ))
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A nonce can not be reused in another tx. We get the nonce from RPC nodes (we pick the highest of them) and use it in our tx.
If another tx is being created at the same time from another thread (which is the case tested by test_nonce_lock test) they would get the same nonce from the RPC. And the eth network will reject the second one.

We will want to return the lock so the caller can have the nonce locked until the transaction is relayed successfully and the nonce is updated on the connected RPC nodes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok thanks for the explanation 🙏🏼

scripts/ci/macos-ifconfig.sh Outdated Show resolved Hide resolved
Copy link
Member

@onur-ozkan onur-ozkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just the initial review for the dependency changes:

@@ -173,5 +172,5 @@ mm2_test_helpers = { path = "../mm2_test_helpers" }
wagyu-zcash-parameters = { version = "0.2" }

[build-dependencies]
prost-build = { version = "0.10.4", default-features = false }
tonic-build = { version = "0.7", default-features = false, features = ["prost", "compression"] }
prost-build = { version = "0.11", default-features = false }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you bump this one to the same version too?

prost-build = { version = "0.10.4", default-features = false }

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh thanks, that would hopefully help reduce duplications.

Cargo.lock Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Most of these are duplicated dependencies in our dependency stack. Can we somehow manage to reduce this list? This will increase the build time.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can upgrade other deps to achieve that. I will give it a try.

p.s. is there some tool that analyzes such a toml & lock files and advises what versions to use to reduce duplication?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/EmbarkStudios/cargo-deny can help to detect duplications but I don't think there is tool that says "bump these to reduce duplication".

@shamardy
Copy link
Collaborator

shamardy commented Mar 25, 2024

set_price_with_cancel_previous_should_broadcast_cancelled_message is flaky. This has been observed on windows and macos so far:

I tried it separately a 100 times on macos locally and it never fails, maybe we should use unique tickers for this test to have a unique orderbook entry for it in case other concurrent tests affect it. If that doesn't solve it, maybe increase the pause a bit

But I don't think increasing the pause will fix it.

@shamardy
Copy link
Collaborator

Other tests (test_send_taker_fee (tx rejected by network rules)

This is probably due to using the same private key across CI machines

let priv_key = [
3, 98, 177, 3, 108, 39, 234, 144, 131, 178, 103, 103, 127, 80, 230, 166, 53, 68, 147, 215, 42, 216, 144, 72,
172, 110, 180, 13, 123, 179, 10, 49,
];

We should probably move it to qrc20 docker tests to use a different private key for each run.

@shamardy
Copy link
Collaborator

test_until_success (test might take longer than permitted, probably due to starvation)) have been observed failing sometimes on macos:

It's ok to increase the HIGHEST_TIMEOUT for this test. Running this test alone locally on macOS always takes 410 to 420 ms. So I think the failure it's due to resource exhaustion.

@shamardy
Copy link
Collaborator

Test best_orders_must_return_duplicate_for_orderbook_tickers has been observed failing consistently on macos, this seems due to low balance.

I see that you already fixed this test by adding funds to the address https://mempool.space/testnet/tx/faca07c3ed403d57b54e54b373439480be483dbbec6604e8b81dd8a9f246ceec I guess it doesn't fail anymore.

@shamardy
Copy link
Collaborator

@mariocynicys test_websocket_invalid_url in wasm seems to be flaky as well. Can you please check it?

mm2src/coins/tendermint/tendermint_coin.rs Outdated Show resolved Hide resolved
mm2src/coins/tendermint/tendermint_coin.rs Outdated Show resolved Hide resolved
mm2src/coins/tendermint/tendermint_coin.rs Outdated Show resolved Hide resolved
.github/workflows/adex-cli.yml Show resolved Hide resolved
Comment on lines 168 to 176
env:
AVAILABLE: ${{ secrets.FILE_SERVER_KEY }}
if: ${{ env.AVAILABLE != '' }}
if: env.FILE_SERVER_AVAILABLE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test this? The last time I tried it wasn't working or supported directly like this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, I thought this should be intuitive, but truly nothing is intuitive about github actions 😢.
The case you want to make sure of here is that when this is run from another repo it shouldn't fail here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case we have to revert those

@@ -7,34 +7,38 @@ concurrency:

jobs:
fmt-and-lint:
name: Style Checks
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this title isn't correct, we lint the code from many aspects which isn't all about styles

Suggested change
name: Style Checks
name: X86 Format and Lint Check

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might wanna omit and X86 part tho. and also have wasm with the same name.
I think this makes the workflow looks more organized:
image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problem is we do have cross compilation pipelines (armv7, aarch64, x86, wasm, etc.) that's why I prefer explicitly adding targets in the pipeline names.

run: cargo clippy --all-targets --all-features -- --D warnings

wasm-lint:
name: Style Checks (wasm)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: Style Checks (wasm)
name: WASM Lint Check

@mariocynicys
Copy link
Collaborator Author

This is probably due to using the same private key across CI machines

Yup that was my guess. Cool, will move this one to docker then.

I see that you already fixed this test by adding funds to the address https://mempool.space/testnet/tx/faca07c3ed403d57b54e54b373439480be483dbbec6604e8b81dd8a9f246ceec I guess it doesn't fail anymore.

Oh yeah, I totally forgot I did that xD.

test_websocket_invalid_url in wasm seems to be flaky as well. Can you please check it?

I will. My experience though is that it fails all the time but sami had it working sometimes locally. The test doesn't seem all that complicated which makes me think it is a network issue.

the testnet ibc channels are unmaintained and get expired a lot, making these specific two tendermint tests fail
also fix some formatting issue
looks like secrets can't be probagated to the global env of a workflow
not all dups of these deps are cleared. e.g. libp2p uses futures-rustls 0.22, tokio-tungstenite-wasm uses tokio-tungstenite which pulls an old version of tokio-rustls.
+ remove ignored wasm test

squashed: fix quik -> qick
they used eth so moved them to docker tests
two cases for print! were ommited but they seem used in an interactive test to prompt the user for a password
…t available yet

and also use the trade_base_rel function from the docker commons
looks like using IP with ssl encryption isn't a common practice [1], also tls connector from tokio-rustls explicilty calls the ServerName argument in `connect` method `domain`, so lets stick with that.
https://stackoverflow.com/questions/2043617/is-it-possible-to-have-ssl-certificate-for-ip-address-not-domain-name
@shamardy
Copy link
Collaborator

Will merge this now and continue review after merging since this is needed in #2079
@mariocynicys as discussed, for any new review comments, you can fix them in a new PR.

@shamardy shamardy merged commit ee3c418 into dev Apr 15, 2024
25 checks passed
@shamardy shamardy deleted the fix-failing-tests branch April 15, 2024 13:45
dimxy added a commit to dimxy/komodo-defi-framework that referenced this pull request Apr 16, 2024
* dev:
  fix(tests): fix failing tests (KomodoPlatform#2085)
  fix(wasm): websocket url validation (KomodoPlatform#2096)
  deps(zcoin): use librustzcash that uses the same `aes` version as mm2 (KomodoPlatform#2095)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants