From 7c02b14f42e430abcd7cb5f254b2d407e388bdc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Thu, 21 Dec 2023 13:13:06 +0200 Subject: [PATCH 1/3] Generates Rust integration tests Generates Rust integration tests based on scenarios provided in the scenarios folder of each contract. --- .../add_wrapped_token.scen.json | 0 .../blacklist_token.scen.json | 0 .../remove_wrapped_token.scen.json | 0 .../{mandos => scenarios}/setup.scen.json | 0 .../unwrap_token.scen.json | 0 .../whitelist_token.scen.json | 0 .../wrap_token.scen.json | 0 ...bridged_tokens_wrapper_scenario_go_test.rs | 40 +++++++++ ...bridged_tokens_wrapper_scenario_rs_test.rs | 40 +++++++++ .../tests/scenario_go_test.rs | 29 ------- .../add_refund_batch.scen.json | 0 .../create_another_tx_ok.scen.json | 0 ...te_another_tx_too_late_for_batch.scen.json | 0 .../create_transaction_ok.scen.json | 0 ...eate_transaction_over_max_amount.scen.json | 0 .../distribute_fees.scen.json | 0 .../execute_batch_both_rejected.scen.json | 0 .../execute_batch_both_success.scen.json | 0 ...e_batch_one_success_one_rejected.scen.json | 0 .../execute_transaction_rejected.scen.json | 0 .../execute_transaction_success.scen.json | 0 .../get_next_pending_tx.scen.json | 0 .../get_next_tx_batch.scen.json | 0 .../get_next_tx_batch_too_early.scen.json | 0 .../setup_accounts.scen.json | 0 .../{mandos => scenarios}/zero_fees.scen.json | 0 esdt-safe/tests/esdt_safe_scenario_go_test.rs | 85 +++++++++++++++++++ esdt-safe/tests/esdt_safe_scenario_rs_test.rs | 85 +++++++++++++++++++ esdt-safe/tests/scenario_go_test.rs | 69 --------------- .../batch_transfer_both_executed.scen.json | 0 .../batch_transfer_both_failed.scen.json | 0 ...transfer_one_executed_one_failed.scen.json | 0 ...batch_transfer_to_frozen_account.scen.json | 0 .../batch_transfer_with_wrapping.scen.json | 0 .../setup_accounts.scen.json | 0 .../transfer_ok.scen.json | 0 .../two_transfers_same_token.scen.json | 0 .../multi_transfer_esdt_scenario_go_test.rs | 45 ++++++++++ .../multi_transfer_esdt_scenario_rs_test.rs | 45 ++++++++++ multi-transfer-esdt/tests/scenario_go_test.rs | 34 -------- .../change_token_config.scen.json | 0 ...eate_elrond_to_ethereum_tx_batch.scen.json | 0 .../ethereum_to_elrond_tx_batch_ok.scen.json | 0 ...reum_to_elrond_tx_batch_rejected.scen.json | 0 ...cute_elrond_to_ethereum_tx_batch.scen.json | 0 .../get_empty_batch.scen.json | 0 ...ject_elrond_to_ethereum_tx_batch.scen.json | 0 .../{mandos => scenarios}/setup.scen.json | 0 .../{mandos => scenarios}/unstake.scen.json | 0 multisig/tests/multisig_scenario_go_test.rs | 50 +++++++++++ multisig/tests/multisig_scenario_rs_test.rs | 50 +++++++++++ multisig/tests/scenario_go_test.rs | 46 ---------- .../{mandos => scenarios}/deploy.scen.json | 0 .../get_latest_price_feed.scen.json | 0 ...acle_gwei_in_eth_and_egld_submit.scen.json | 0 .../oracle_submit.scen.json | 0 56 files changed, 440 insertions(+), 178 deletions(-) rename bridged-tokens-wrapper/{mandos => scenarios}/add_wrapped_token.scen.json (100%) rename bridged-tokens-wrapper/{mandos => scenarios}/blacklist_token.scen.json (100%) rename bridged-tokens-wrapper/{mandos => scenarios}/remove_wrapped_token.scen.json (100%) rename bridged-tokens-wrapper/{mandos => scenarios}/setup.scen.json (100%) rename bridged-tokens-wrapper/{mandos => scenarios}/unwrap_token.scen.json (100%) rename bridged-tokens-wrapper/{mandos => scenarios}/whitelist_token.scen.json (100%) rename bridged-tokens-wrapper/{mandos => scenarios}/wrap_token.scen.json (100%) create mode 100644 bridged-tokens-wrapper/tests/bridged_tokens_wrapper_scenario_go_test.rs create mode 100644 bridged-tokens-wrapper/tests/bridged_tokens_wrapper_scenario_rs_test.rs delete mode 100644 bridged-tokens-wrapper/tests/scenario_go_test.rs rename esdt-safe/{mandos => scenarios}/add_refund_batch.scen.json (100%) rename esdt-safe/{mandos => scenarios}/create_another_tx_ok.scen.json (100%) rename esdt-safe/{mandos => scenarios}/create_another_tx_too_late_for_batch.scen.json (100%) rename esdt-safe/{mandos => scenarios}/create_transaction_ok.scen.json (100%) rename esdt-safe/{mandos => scenarios}/create_transaction_over_max_amount.scen.json (100%) rename esdt-safe/{mandos => scenarios}/distribute_fees.scen.json (100%) rename esdt-safe/{mandos => scenarios}/execute_batch_both_rejected.scen.json (100%) rename esdt-safe/{mandos => scenarios}/execute_batch_both_success.scen.json (100%) rename esdt-safe/{mandos => scenarios}/execute_batch_one_success_one_rejected.scen.json (100%) rename esdt-safe/{mandos => scenarios}/execute_transaction_rejected.scen.json (100%) rename esdt-safe/{mandos => scenarios}/execute_transaction_success.scen.json (100%) rename esdt-safe/{mandos => scenarios}/get_next_pending_tx.scen.json (100%) rename esdt-safe/{mandos => scenarios}/get_next_tx_batch.scen.json (100%) rename esdt-safe/{mandos => scenarios}/get_next_tx_batch_too_early.scen.json (100%) rename esdt-safe/{mandos => scenarios}/setup_accounts.scen.json (100%) rename esdt-safe/{mandos => scenarios}/zero_fees.scen.json (100%) create mode 100644 esdt-safe/tests/esdt_safe_scenario_go_test.rs create mode 100644 esdt-safe/tests/esdt_safe_scenario_rs_test.rs delete mode 100644 esdt-safe/tests/scenario_go_test.rs rename multi-transfer-esdt/{mandos => scenarios}/batch_transfer_both_executed.scen.json (100%) rename multi-transfer-esdt/{mandos => scenarios}/batch_transfer_both_failed.scen.json (100%) rename multi-transfer-esdt/{mandos => scenarios}/batch_transfer_one_executed_one_failed.scen.json (100%) rename multi-transfer-esdt/{mandos => scenarios}/batch_transfer_to_frozen_account.scen.json (100%) rename multi-transfer-esdt/{mandos => scenarios}/batch_transfer_with_wrapping.scen.json (100%) rename multi-transfer-esdt/{mandos => scenarios}/setup_accounts.scen.json (100%) rename multi-transfer-esdt/{mandos => scenarios}/transfer_ok.scen.json (100%) rename multi-transfer-esdt/{mandos => scenarios}/two_transfers_same_token.scen.json (100%) create mode 100644 multi-transfer-esdt/tests/multi_transfer_esdt_scenario_go_test.rs create mode 100644 multi-transfer-esdt/tests/multi_transfer_esdt_scenario_rs_test.rs delete mode 100644 multi-transfer-esdt/tests/scenario_go_test.rs rename multisig/{mandos => scenarios}/change_token_config.scen.json (100%) rename multisig/{mandos => scenarios}/create_elrond_to_ethereum_tx_batch.scen.json (100%) rename multisig/{mandos => scenarios}/ethereum_to_elrond_tx_batch_ok.scen.json (100%) rename multisig/{mandos => scenarios}/ethereum_to_elrond_tx_batch_rejected.scen.json (100%) rename multisig/{mandos => scenarios}/execute_elrond_to_ethereum_tx_batch.scen.json (100%) rename multisig/{mandos => scenarios}/get_empty_batch.scen.json (100%) rename multisig/{mandos => scenarios}/reject_elrond_to_ethereum_tx_batch.scen.json (100%) rename multisig/{mandos => scenarios}/setup.scen.json (100%) rename multisig/{mandos => scenarios}/unstake.scen.json (100%) create mode 100644 multisig/tests/multisig_scenario_go_test.rs create mode 100644 multisig/tests/multisig_scenario_rs_test.rs delete mode 100644 multisig/tests/scenario_go_test.rs rename price-aggregator/{mandos => scenarios}/deploy.scen.json (100%) rename price-aggregator/{mandos => scenarios}/get_latest_price_feed.scen.json (100%) rename price-aggregator/{mandos => scenarios}/oracle_gwei_in_eth_and_egld_submit.scen.json (100%) rename price-aggregator/{mandos => scenarios}/oracle_submit.scen.json (100%) diff --git a/bridged-tokens-wrapper/mandos/add_wrapped_token.scen.json b/bridged-tokens-wrapper/scenarios/add_wrapped_token.scen.json similarity index 100% rename from bridged-tokens-wrapper/mandos/add_wrapped_token.scen.json rename to bridged-tokens-wrapper/scenarios/add_wrapped_token.scen.json diff --git a/bridged-tokens-wrapper/mandos/blacklist_token.scen.json b/bridged-tokens-wrapper/scenarios/blacklist_token.scen.json similarity index 100% rename from bridged-tokens-wrapper/mandos/blacklist_token.scen.json rename to bridged-tokens-wrapper/scenarios/blacklist_token.scen.json diff --git a/bridged-tokens-wrapper/mandos/remove_wrapped_token.scen.json b/bridged-tokens-wrapper/scenarios/remove_wrapped_token.scen.json similarity index 100% rename from bridged-tokens-wrapper/mandos/remove_wrapped_token.scen.json rename to bridged-tokens-wrapper/scenarios/remove_wrapped_token.scen.json diff --git a/bridged-tokens-wrapper/mandos/setup.scen.json b/bridged-tokens-wrapper/scenarios/setup.scen.json similarity index 100% rename from bridged-tokens-wrapper/mandos/setup.scen.json rename to bridged-tokens-wrapper/scenarios/setup.scen.json diff --git a/bridged-tokens-wrapper/mandos/unwrap_token.scen.json b/bridged-tokens-wrapper/scenarios/unwrap_token.scen.json similarity index 100% rename from bridged-tokens-wrapper/mandos/unwrap_token.scen.json rename to bridged-tokens-wrapper/scenarios/unwrap_token.scen.json diff --git a/bridged-tokens-wrapper/mandos/whitelist_token.scen.json b/bridged-tokens-wrapper/scenarios/whitelist_token.scen.json similarity index 100% rename from bridged-tokens-wrapper/mandos/whitelist_token.scen.json rename to bridged-tokens-wrapper/scenarios/whitelist_token.scen.json diff --git a/bridged-tokens-wrapper/mandos/wrap_token.scen.json b/bridged-tokens-wrapper/scenarios/wrap_token.scen.json similarity index 100% rename from bridged-tokens-wrapper/mandos/wrap_token.scen.json rename to bridged-tokens-wrapper/scenarios/wrap_token.scen.json diff --git a/bridged-tokens-wrapper/tests/bridged_tokens_wrapper_scenario_go_test.rs b/bridged-tokens-wrapper/tests/bridged_tokens_wrapper_scenario_go_test.rs new file mode 100644 index 00000000..a3d6e919 --- /dev/null +++ b/bridged-tokens-wrapper/tests/bridged_tokens_wrapper_scenario_go_test.rs @@ -0,0 +1,40 @@ +use multiversx_sc_scenario::*; + +fn world() -> ScenarioWorld { + ScenarioWorld::vm_go() +} + +#[test] +fn add_wrapped_token_go() { + world().run("scenarios/add_wrapped_token.scen.json"); +} + +#[test] +fn blacklist_token_go() { + world().run("scenarios/blacklist_token.scen.json"); +} + +#[test] +fn remove_wrapped_token_go() { + world().run("scenarios/remove_wrapped_token.scen.json"); +} + +#[test] +fn setup_go() { + world().run("scenarios/setup.scen.json"); +} + +#[test] +fn unwrap_token_go() { + world().run("scenarios/unwrap_token.scen.json"); +} + +#[test] +fn whitelist_token_go() { + world().run("scenarios/whitelist_token.scen.json"); +} + +#[test] +fn wrap_token_go() { + world().run("scenarios/wrap_token.scen.json"); +} diff --git a/bridged-tokens-wrapper/tests/bridged_tokens_wrapper_scenario_rs_test.rs b/bridged-tokens-wrapper/tests/bridged_tokens_wrapper_scenario_rs_test.rs new file mode 100644 index 00000000..c56d0406 --- /dev/null +++ b/bridged-tokens-wrapper/tests/bridged_tokens_wrapper_scenario_rs_test.rs @@ -0,0 +1,40 @@ +use multiversx_sc_scenario::*; + +fn world() -> ScenarioWorld { + todo!() +} + +#[test] +fn add_wrapped_token_rs() { + world().run("scenarios/add_wrapped_token.scen.json"); +} + +#[test] +fn blacklist_token_rs() { + world().run("scenarios/blacklist_token.scen.json"); +} + +#[test] +fn remove_wrapped_token_rs() { + world().run("scenarios/remove_wrapped_token.scen.json"); +} + +#[test] +fn setup_rs() { + world().run("scenarios/setup.scen.json"); +} + +#[test] +fn unwrap_token_rs() { + world().run("scenarios/unwrap_token.scen.json"); +} + +#[test] +fn whitelist_token_rs() { + world().run("scenarios/whitelist_token.scen.json"); +} + +#[test] +fn wrap_token_rs() { + world().run("scenarios/wrap_token.scen.json"); +} diff --git a/bridged-tokens-wrapper/tests/scenario_go_test.rs b/bridged-tokens-wrapper/tests/scenario_go_test.rs deleted file mode 100644 index 4bbc4b02..00000000 --- a/bridged-tokens-wrapper/tests/scenario_go_test.rs +++ /dev/null @@ -1,29 +0,0 @@ -#[test] -fn unwrap_token_go() { - multiversx_sc_scenario::run_go("mandos/unwrap_token.scen.json"); -} - -#[test] -fn wrap_token_go() { - multiversx_sc_scenario::run_go("mandos/wrap_token.scen.json"); -} - -#[test] -fn whitelist_token_go() { - multiversx_sc_scenario::run_go("mandos/whitelist_token.scen.json"); -} - -#[test] -fn blacklist_token_go() { - multiversx_sc_scenario::run_go("mandos/blacklist_token.scen.json"); -} - -#[test] -fn add_wrapped_token_go() { - multiversx_sc_scenario::run_go("mandos/add_wrapped_token.scen.json"); -} - -#[test] -fn remove_wrapped_token_go() { - multiversx_sc_scenario::run_go("mandos/remove_wrapped_token.scen.json"); -} diff --git a/esdt-safe/mandos/add_refund_batch.scen.json b/esdt-safe/scenarios/add_refund_batch.scen.json similarity index 100% rename from esdt-safe/mandos/add_refund_batch.scen.json rename to esdt-safe/scenarios/add_refund_batch.scen.json diff --git a/esdt-safe/mandos/create_another_tx_ok.scen.json b/esdt-safe/scenarios/create_another_tx_ok.scen.json similarity index 100% rename from esdt-safe/mandos/create_another_tx_ok.scen.json rename to esdt-safe/scenarios/create_another_tx_ok.scen.json diff --git a/esdt-safe/mandos/create_another_tx_too_late_for_batch.scen.json b/esdt-safe/scenarios/create_another_tx_too_late_for_batch.scen.json similarity index 100% rename from esdt-safe/mandos/create_another_tx_too_late_for_batch.scen.json rename to esdt-safe/scenarios/create_another_tx_too_late_for_batch.scen.json diff --git a/esdt-safe/mandos/create_transaction_ok.scen.json b/esdt-safe/scenarios/create_transaction_ok.scen.json similarity index 100% rename from esdt-safe/mandos/create_transaction_ok.scen.json rename to esdt-safe/scenarios/create_transaction_ok.scen.json diff --git a/esdt-safe/mandos/create_transaction_over_max_amount.scen.json b/esdt-safe/scenarios/create_transaction_over_max_amount.scen.json similarity index 100% rename from esdt-safe/mandos/create_transaction_over_max_amount.scen.json rename to esdt-safe/scenarios/create_transaction_over_max_amount.scen.json diff --git a/esdt-safe/mandos/distribute_fees.scen.json b/esdt-safe/scenarios/distribute_fees.scen.json similarity index 100% rename from esdt-safe/mandos/distribute_fees.scen.json rename to esdt-safe/scenarios/distribute_fees.scen.json diff --git a/esdt-safe/mandos/execute_batch_both_rejected.scen.json b/esdt-safe/scenarios/execute_batch_both_rejected.scen.json similarity index 100% rename from esdt-safe/mandos/execute_batch_both_rejected.scen.json rename to esdt-safe/scenarios/execute_batch_both_rejected.scen.json diff --git a/esdt-safe/mandos/execute_batch_both_success.scen.json b/esdt-safe/scenarios/execute_batch_both_success.scen.json similarity index 100% rename from esdt-safe/mandos/execute_batch_both_success.scen.json rename to esdt-safe/scenarios/execute_batch_both_success.scen.json diff --git a/esdt-safe/mandos/execute_batch_one_success_one_rejected.scen.json b/esdt-safe/scenarios/execute_batch_one_success_one_rejected.scen.json similarity index 100% rename from esdt-safe/mandos/execute_batch_one_success_one_rejected.scen.json rename to esdt-safe/scenarios/execute_batch_one_success_one_rejected.scen.json diff --git a/esdt-safe/mandos/execute_transaction_rejected.scen.json b/esdt-safe/scenarios/execute_transaction_rejected.scen.json similarity index 100% rename from esdt-safe/mandos/execute_transaction_rejected.scen.json rename to esdt-safe/scenarios/execute_transaction_rejected.scen.json diff --git a/esdt-safe/mandos/execute_transaction_success.scen.json b/esdt-safe/scenarios/execute_transaction_success.scen.json similarity index 100% rename from esdt-safe/mandos/execute_transaction_success.scen.json rename to esdt-safe/scenarios/execute_transaction_success.scen.json diff --git a/esdt-safe/mandos/get_next_pending_tx.scen.json b/esdt-safe/scenarios/get_next_pending_tx.scen.json similarity index 100% rename from esdt-safe/mandos/get_next_pending_tx.scen.json rename to esdt-safe/scenarios/get_next_pending_tx.scen.json diff --git a/esdt-safe/mandos/get_next_tx_batch.scen.json b/esdt-safe/scenarios/get_next_tx_batch.scen.json similarity index 100% rename from esdt-safe/mandos/get_next_tx_batch.scen.json rename to esdt-safe/scenarios/get_next_tx_batch.scen.json diff --git a/esdt-safe/mandos/get_next_tx_batch_too_early.scen.json b/esdt-safe/scenarios/get_next_tx_batch_too_early.scen.json similarity index 100% rename from esdt-safe/mandos/get_next_tx_batch_too_early.scen.json rename to esdt-safe/scenarios/get_next_tx_batch_too_early.scen.json diff --git a/esdt-safe/mandos/setup_accounts.scen.json b/esdt-safe/scenarios/setup_accounts.scen.json similarity index 100% rename from esdt-safe/mandos/setup_accounts.scen.json rename to esdt-safe/scenarios/setup_accounts.scen.json diff --git a/esdt-safe/mandos/zero_fees.scen.json b/esdt-safe/scenarios/zero_fees.scen.json similarity index 100% rename from esdt-safe/mandos/zero_fees.scen.json rename to esdt-safe/scenarios/zero_fees.scen.json diff --git a/esdt-safe/tests/esdt_safe_scenario_go_test.rs b/esdt-safe/tests/esdt_safe_scenario_go_test.rs new file mode 100644 index 00000000..7dcd7957 --- /dev/null +++ b/esdt-safe/tests/esdt_safe_scenario_go_test.rs @@ -0,0 +1,85 @@ +use multiversx_sc_scenario::*; + +fn world() -> ScenarioWorld { + ScenarioWorld::vm_go() +} + +#[test] +fn add_refund_batch_go() { + world().run("scenarios/add_refund_batch.scen.json"); +} + +#[test] +fn create_another_tx_ok_go() { + world().run("scenarios/create_another_tx_ok.scen.json"); +} + +#[test] +fn create_another_tx_too_late_for_batch_go() { + world().run("scenarios/create_another_tx_too_late_for_batch.scen.json"); +} + +#[test] +fn create_transaction_ok_go() { + world().run("scenarios/create_transaction_ok.scen.json"); +} + +#[test] +fn create_transaction_over_max_amount_go() { + world().run("scenarios/create_transaction_over_max_amount.scen.json"); +} + +#[test] +fn distribute_fees_go() { + world().run("scenarios/distribute_fees.scen.json"); +} + +#[test] +fn execute_batch_both_rejected_go() { + world().run("scenarios/execute_batch_both_rejected.scen.json"); +} + +#[test] +fn execute_batch_both_success_go() { + world().run("scenarios/execute_batch_both_success.scen.json"); +} + +#[test] +fn execute_batch_one_success_one_rejected_go() { + world().run("scenarios/execute_batch_one_success_one_rejected.scen.json"); +} + +#[test] +fn execute_transaction_rejected_go() { + world().run("scenarios/execute_transaction_rejected.scen.json"); +} + +#[test] +fn execute_transaction_success_go() { + world().run("scenarios/execute_transaction_success.scen.json"); +} + +#[test] +fn get_next_pending_tx_go() { + world().run("scenarios/get_next_pending_tx.scen.json"); +} + +#[test] +fn get_next_tx_batch_go() { + world().run("scenarios/get_next_tx_batch.scen.json"); +} + +#[test] +fn get_next_tx_batch_too_early_go() { + world().run("scenarios/get_next_tx_batch_too_early.scen.json"); +} + +#[test] +fn setup_accounts_go() { + world().run("scenarios/setup_accounts.scen.json"); +} + +#[test] +fn zero_fees_go() { + world().run("scenarios/zero_fees.scen.json"); +} diff --git a/esdt-safe/tests/esdt_safe_scenario_rs_test.rs b/esdt-safe/tests/esdt_safe_scenario_rs_test.rs new file mode 100644 index 00000000..a8db856b --- /dev/null +++ b/esdt-safe/tests/esdt_safe_scenario_rs_test.rs @@ -0,0 +1,85 @@ +use multiversx_sc_scenario::*; + +fn world() -> ScenarioWorld { + todo!() +} + +#[test] +fn add_refund_batch_rs() { + world().run("scenarios/add_refund_batch.scen.json"); +} + +#[test] +fn create_another_tx_ok_rs() { + world().run("scenarios/create_another_tx_ok.scen.json"); +} + +#[test] +fn create_another_tx_too_late_for_batch_rs() { + world().run("scenarios/create_another_tx_too_late_for_batch.scen.json"); +} + +#[test] +fn create_transaction_ok_rs() { + world().run("scenarios/create_transaction_ok.scen.json"); +} + +#[test] +fn create_transaction_over_max_amount_rs() { + world().run("scenarios/create_transaction_over_max_amount.scen.json"); +} + +#[test] +fn distribute_fees_rs() { + world().run("scenarios/distribute_fees.scen.json"); +} + +#[test] +fn execute_batch_both_rejected_rs() { + world().run("scenarios/execute_batch_both_rejected.scen.json"); +} + +#[test] +fn execute_batch_both_success_rs() { + world().run("scenarios/execute_batch_both_success.scen.json"); +} + +#[test] +fn execute_batch_one_success_one_rejected_rs() { + world().run("scenarios/execute_batch_one_success_one_rejected.scen.json"); +} + +#[test] +fn execute_transaction_rejected_rs() { + world().run("scenarios/execute_transaction_rejected.scen.json"); +} + +#[test] +fn execute_transaction_success_rs() { + world().run("scenarios/execute_transaction_success.scen.json"); +} + +#[test] +fn get_next_pending_tx_rs() { + world().run("scenarios/get_next_pending_tx.scen.json"); +} + +#[test] +fn get_next_tx_batch_rs() { + world().run("scenarios/get_next_tx_batch.scen.json"); +} + +#[test] +fn get_next_tx_batch_too_early_rs() { + world().run("scenarios/get_next_tx_batch_too_early.scen.json"); +} + +#[test] +fn setup_accounts_rs() { + world().run("scenarios/setup_accounts.scen.json"); +} + +#[test] +fn zero_fees_rs() { + world().run("scenarios/zero_fees.scen.json"); +} diff --git a/esdt-safe/tests/scenario_go_test.rs b/esdt-safe/tests/scenario_go_test.rs deleted file mode 100644 index 205306a5..00000000 --- a/esdt-safe/tests/scenario_go_test.rs +++ /dev/null @@ -1,69 +0,0 @@ -#[test] -fn claim_fees_go() { - multiversx_sc_scenario::run_go("mandos/distribute_fees.scen.json"); -} - -#[test] -fn create_another_tx_ok_go() { - multiversx_sc_scenario::run_go("mandos/create_another_tx_ok.scen.json"); -} - -#[test] -fn create_another_tx_too_late_for_batch_go() { - multiversx_sc_scenario::run_go("mandos/create_another_tx_too_late_for_batch.scen.json"); -} - -#[test] -fn create_transaction_ok_go() { - multiversx_sc_scenario::run_go("mandos/create_transaction_ok.scen.json"); -} - -#[test] -fn execute_batch_both_rejected_go() { - multiversx_sc_scenario::run_go("mandos/execute_batch_both_rejected.scen.json"); -} - -#[test] -fn execute_batch_both_success_go() { - multiversx_sc_scenario::run_go("mandos/execute_batch_both_success.scen.json"); -} - -#[test] -fn execute_batch_one_success_one_rejected_go() { - multiversx_sc_scenario::run_go("mandos/execute_batch_one_success_one_rejected.scen.json"); -} - -#[test] -fn execute_transaction_rejected_go() { - multiversx_sc_scenario::run_go("mandos/execute_transaction_rejected.scen.json"); -} - -#[test] -fn execute_transaction_success_go() { - multiversx_sc_scenario::run_go("mandos/execute_transaction_success.scen.json"); -} - -#[test] -fn get_next_pending_tx_go() { - multiversx_sc_scenario::run_go("mandos/get_next_pending_tx.scen.json"); -} - -#[test] -fn get_next_tx_batch_go() { - multiversx_sc_scenario::run_go("mandos/get_next_tx_batch.scen.json"); -} - -#[test] -fn get_next_tx_batch_too_early_go() { - multiversx_sc_scenario::run_go("mandos/get_next_tx_batch_too_early.scen.json"); -} - -#[test] -fn setup_accounts_go() { - multiversx_sc_scenario::run_go("mandos/setup_accounts.scen.json"); -} - -#[test] -fn zero_fees_go() { - multiversx_sc_scenario::run_go("mandos/zero_fees.scen.json"); -} diff --git a/multi-transfer-esdt/mandos/batch_transfer_both_executed.scen.json b/multi-transfer-esdt/scenarios/batch_transfer_both_executed.scen.json similarity index 100% rename from multi-transfer-esdt/mandos/batch_transfer_both_executed.scen.json rename to multi-transfer-esdt/scenarios/batch_transfer_both_executed.scen.json diff --git a/multi-transfer-esdt/mandos/batch_transfer_both_failed.scen.json b/multi-transfer-esdt/scenarios/batch_transfer_both_failed.scen.json similarity index 100% rename from multi-transfer-esdt/mandos/batch_transfer_both_failed.scen.json rename to multi-transfer-esdt/scenarios/batch_transfer_both_failed.scen.json diff --git a/multi-transfer-esdt/mandos/batch_transfer_one_executed_one_failed.scen.json b/multi-transfer-esdt/scenarios/batch_transfer_one_executed_one_failed.scen.json similarity index 100% rename from multi-transfer-esdt/mandos/batch_transfer_one_executed_one_failed.scen.json rename to multi-transfer-esdt/scenarios/batch_transfer_one_executed_one_failed.scen.json diff --git a/multi-transfer-esdt/mandos/batch_transfer_to_frozen_account.scen.json b/multi-transfer-esdt/scenarios/batch_transfer_to_frozen_account.scen.json similarity index 100% rename from multi-transfer-esdt/mandos/batch_transfer_to_frozen_account.scen.json rename to multi-transfer-esdt/scenarios/batch_transfer_to_frozen_account.scen.json diff --git a/multi-transfer-esdt/mandos/batch_transfer_with_wrapping.scen.json b/multi-transfer-esdt/scenarios/batch_transfer_with_wrapping.scen.json similarity index 100% rename from multi-transfer-esdt/mandos/batch_transfer_with_wrapping.scen.json rename to multi-transfer-esdt/scenarios/batch_transfer_with_wrapping.scen.json diff --git a/multi-transfer-esdt/mandos/setup_accounts.scen.json b/multi-transfer-esdt/scenarios/setup_accounts.scen.json similarity index 100% rename from multi-transfer-esdt/mandos/setup_accounts.scen.json rename to multi-transfer-esdt/scenarios/setup_accounts.scen.json diff --git a/multi-transfer-esdt/mandos/transfer_ok.scen.json b/multi-transfer-esdt/scenarios/transfer_ok.scen.json similarity index 100% rename from multi-transfer-esdt/mandos/transfer_ok.scen.json rename to multi-transfer-esdt/scenarios/transfer_ok.scen.json diff --git a/multi-transfer-esdt/mandos/two_transfers_same_token.scen.json b/multi-transfer-esdt/scenarios/two_transfers_same_token.scen.json similarity index 100% rename from multi-transfer-esdt/mandos/two_transfers_same_token.scen.json rename to multi-transfer-esdt/scenarios/two_transfers_same_token.scen.json diff --git a/multi-transfer-esdt/tests/multi_transfer_esdt_scenario_go_test.rs b/multi-transfer-esdt/tests/multi_transfer_esdt_scenario_go_test.rs new file mode 100644 index 00000000..099736dd --- /dev/null +++ b/multi-transfer-esdt/tests/multi_transfer_esdt_scenario_go_test.rs @@ -0,0 +1,45 @@ +use multiversx_sc_scenario::*; + +fn world() -> ScenarioWorld { + ScenarioWorld::vm_go() +} + +#[test] +fn batch_transfer_both_executed_go() { + world().run("scenarios/batch_transfer_both_executed.scen.json"); +} + +#[test] +fn batch_transfer_both_failed_go() { + world().run("scenarios/batch_transfer_both_failed.scen.json"); +} + +#[test] +fn batch_transfer_one_executed_one_failed_go() { + world().run("scenarios/batch_transfer_one_executed_one_failed.scen.json"); +} + +#[test] +fn batch_transfer_to_frozen_account_go() { + world().run("scenarios/batch_transfer_to_frozen_account.scen.json"); +} + +#[test] +fn batch_transfer_with_wrapping_go() { + world().run("scenarios/batch_transfer_with_wrapping.scen.json"); +} + +#[test] +fn setup_accounts_go() { + world().run("scenarios/setup_accounts.scen.json"); +} + +#[test] +fn transfer_ok_go() { + world().run("scenarios/transfer_ok.scen.json"); +} + +#[test] +fn two_transfers_same_token_go() { + world().run("scenarios/two_transfers_same_token.scen.json"); +} diff --git a/multi-transfer-esdt/tests/multi_transfer_esdt_scenario_rs_test.rs b/multi-transfer-esdt/tests/multi_transfer_esdt_scenario_rs_test.rs new file mode 100644 index 00000000..b31af7c2 --- /dev/null +++ b/multi-transfer-esdt/tests/multi_transfer_esdt_scenario_rs_test.rs @@ -0,0 +1,45 @@ +use multiversx_sc_scenario::*; + +fn world() -> ScenarioWorld { + todo!() +} + +#[test] +fn batch_transfer_both_executed_rs() { + world().run("scenarios/batch_transfer_both_executed.scen.json"); +} + +#[test] +fn batch_transfer_both_failed_rs() { + world().run("scenarios/batch_transfer_both_failed.scen.json"); +} + +#[test] +fn batch_transfer_one_executed_one_failed_rs() { + world().run("scenarios/batch_transfer_one_executed_one_failed.scen.json"); +} + +#[test] +fn batch_transfer_to_frozen_account_rs() { + world().run("scenarios/batch_transfer_to_frozen_account.scen.json"); +} + +#[test] +fn batch_transfer_with_wrapping_rs() { + world().run("scenarios/batch_transfer_with_wrapping.scen.json"); +} + +#[test] +fn setup_accounts_rs() { + world().run("scenarios/setup_accounts.scen.json"); +} + +#[test] +fn transfer_ok_rs() { + world().run("scenarios/transfer_ok.scen.json"); +} + +#[test] +fn two_transfers_same_token_rs() { + world().run("scenarios/two_transfers_same_token.scen.json"); +} diff --git a/multi-transfer-esdt/tests/scenario_go_test.rs b/multi-transfer-esdt/tests/scenario_go_test.rs deleted file mode 100644 index cdda9c2b..00000000 --- a/multi-transfer-esdt/tests/scenario_go_test.rs +++ /dev/null @@ -1,34 +0,0 @@ -#[test] -fn batch_transfer_both_executed_go() { - multiversx_sc_scenario::run_go("mandos/batch_transfer_both_executed.scen.json"); -} - -#[test] -fn batch_transfer_both_failed_go() { - multiversx_sc_scenario::run_go("mandos/batch_transfer_both_failed.scen.json"); -} - -#[test] -fn batch_transfer_one_executed_one_failed_go() { - multiversx_sc_scenario::run_go("mandos/batch_transfer_one_executed_one_failed.scen.json"); -} - -#[test] -fn batch_transfer_to_frozen_account_go() { - multiversx_sc_scenario::run_go("mandos/batch_transfer_to_frozen_account.scen.json"); -} - -#[test] -fn setup_accounts_go() { - multiversx_sc_scenario::run_go("mandos/setup_accounts.scen.json"); -} - -#[test] -fn transfer_ok_go() { - multiversx_sc_scenario::run_go("mandos/transfer_ok.scen.json"); -} - -#[test] -fn two_transfers_same_token_go() { - multiversx_sc_scenario::run_go("mandos/two_transfers_same_token.scen.json"); -} diff --git a/multisig/mandos/change_token_config.scen.json b/multisig/scenarios/change_token_config.scen.json similarity index 100% rename from multisig/mandos/change_token_config.scen.json rename to multisig/scenarios/change_token_config.scen.json diff --git a/multisig/mandos/create_elrond_to_ethereum_tx_batch.scen.json b/multisig/scenarios/create_elrond_to_ethereum_tx_batch.scen.json similarity index 100% rename from multisig/mandos/create_elrond_to_ethereum_tx_batch.scen.json rename to multisig/scenarios/create_elrond_to_ethereum_tx_batch.scen.json diff --git a/multisig/mandos/ethereum_to_elrond_tx_batch_ok.scen.json b/multisig/scenarios/ethereum_to_elrond_tx_batch_ok.scen.json similarity index 100% rename from multisig/mandos/ethereum_to_elrond_tx_batch_ok.scen.json rename to multisig/scenarios/ethereum_to_elrond_tx_batch_ok.scen.json diff --git a/multisig/mandos/ethereum_to_elrond_tx_batch_rejected.scen.json b/multisig/scenarios/ethereum_to_elrond_tx_batch_rejected.scen.json similarity index 100% rename from multisig/mandos/ethereum_to_elrond_tx_batch_rejected.scen.json rename to multisig/scenarios/ethereum_to_elrond_tx_batch_rejected.scen.json diff --git a/multisig/mandos/execute_elrond_to_ethereum_tx_batch.scen.json b/multisig/scenarios/execute_elrond_to_ethereum_tx_batch.scen.json similarity index 100% rename from multisig/mandos/execute_elrond_to_ethereum_tx_batch.scen.json rename to multisig/scenarios/execute_elrond_to_ethereum_tx_batch.scen.json diff --git a/multisig/mandos/get_empty_batch.scen.json b/multisig/scenarios/get_empty_batch.scen.json similarity index 100% rename from multisig/mandos/get_empty_batch.scen.json rename to multisig/scenarios/get_empty_batch.scen.json diff --git a/multisig/mandos/reject_elrond_to_ethereum_tx_batch.scen.json b/multisig/scenarios/reject_elrond_to_ethereum_tx_batch.scen.json similarity index 100% rename from multisig/mandos/reject_elrond_to_ethereum_tx_batch.scen.json rename to multisig/scenarios/reject_elrond_to_ethereum_tx_batch.scen.json diff --git a/multisig/mandos/setup.scen.json b/multisig/scenarios/setup.scen.json similarity index 100% rename from multisig/mandos/setup.scen.json rename to multisig/scenarios/setup.scen.json diff --git a/multisig/mandos/unstake.scen.json b/multisig/scenarios/unstake.scen.json similarity index 100% rename from multisig/mandos/unstake.scen.json rename to multisig/scenarios/unstake.scen.json diff --git a/multisig/tests/multisig_scenario_go_test.rs b/multisig/tests/multisig_scenario_go_test.rs new file mode 100644 index 00000000..3f070d94 --- /dev/null +++ b/multisig/tests/multisig_scenario_go_test.rs @@ -0,0 +1,50 @@ +use multiversx_sc_scenario::*; + +fn world() -> ScenarioWorld { + ScenarioWorld::vm_go() +} + +#[test] +fn change_token_config_go() { + world().run("scenarios/change_token_config.scen.json"); +} + +#[test] +fn create_elrond_to_ethereum_tx_batch_go() { + world().run("scenarios/create_elrond_to_ethereum_tx_batch.scen.json"); +} + +#[test] +fn ethereum_to_elrond_tx_batch_ok_go() { + world().run("scenarios/ethereum_to_elrond_tx_batch_ok.scen.json"); +} + +#[test] +fn ethereum_to_elrond_tx_batch_rejected_go() { + world().run("scenarios/ethereum_to_elrond_tx_batch_rejected.scen.json"); +} + +#[test] +fn execute_elrond_to_ethereum_tx_batch_go() { + world().run("scenarios/execute_elrond_to_ethereum_tx_batch.scen.json"); +} + +#[test] +fn get_empty_batch_go() { + world().run("scenarios/get_empty_batch.scen.json"); +} + +#[test] +fn reject_elrond_to_ethereum_tx_batch_go() { + world().run("scenarios/reject_elrond_to_ethereum_tx_batch.scen.json"); +} + +#[test] +fn setup_go() { + world().run("scenarios/setup.scen.json"); +} + +#[test] +fn unstake_go() { + world().run("scenarios/unstake.scen.json"); +} diff --git a/multisig/tests/multisig_scenario_rs_test.rs b/multisig/tests/multisig_scenario_rs_test.rs new file mode 100644 index 00000000..081aa6c3 --- /dev/null +++ b/multisig/tests/multisig_scenario_rs_test.rs @@ -0,0 +1,50 @@ +use multiversx_sc_scenario::*; + +fn world() -> ScenarioWorld { + todo!() +} + +#[test] +fn change_token_config_rs() { + world().run("scenarios/change_token_config.scen.json"); +} + +#[test] +fn create_elrond_to_ethereum_tx_batch_rs() { + world().run("scenarios/create_elrond_to_ethereum_tx_batch.scen.json"); +} + +#[test] +fn ethereum_to_elrond_tx_batch_ok_rs() { + world().run("scenarios/ethereum_to_elrond_tx_batch_ok.scen.json"); +} + +#[test] +fn ethereum_to_elrond_tx_batch_rejected_rs() { + world().run("scenarios/ethereum_to_elrond_tx_batch_rejected.scen.json"); +} + +#[test] +fn execute_elrond_to_ethereum_tx_batch_rs() { + world().run("scenarios/execute_elrond_to_ethereum_tx_batch.scen.json"); +} + +#[test] +fn get_empty_batch_rs() { + world().run("scenarios/get_empty_batch.scen.json"); +} + +#[test] +fn reject_elrond_to_ethereum_tx_batch_rs() { + world().run("scenarios/reject_elrond_to_ethereum_tx_batch.scen.json"); +} + +#[test] +fn setup_rs() { + world().run("scenarios/setup.scen.json"); +} + +#[test] +fn unstake_rs() { + world().run("scenarios/unstake.scen.json"); +} diff --git a/multisig/tests/scenario_go_test.rs b/multisig/tests/scenario_go_test.rs deleted file mode 100644 index 9605e9d4..00000000 --- a/multisig/tests/scenario_go_test.rs +++ /dev/null @@ -1,46 +0,0 @@ -#[test] -fn create_elrond_to_ethereum_tx_batch_go() { - multiversx_sc_scenario::run_go("mandos/create_elrond_to_ethereum_tx_batch.scen.json"); -} - -#[test] -fn ethereum_to_elrond_tx_batch_ok_go() { - multiversx_sc_scenario::run_go("mandos/ethereum_to_elrond_tx_batch_ok.scen.json"); -} - -#[test] -fn ethereum_to_elrond_tx_batch_rejected_go() { - multiversx_sc_scenario::run_go("mandos/ethereum_to_elrond_tx_batch_rejected.scen.json"); -} - -#[test] -fn execute_elrond_to_ethereum_tx_batch_go() { - multiversx_sc_scenario::run_go("mandos/execute_elrond_to_ethereum_tx_batch.scen.json"); -} - -#[test] -fn get_empty_batch_go() { - multiversx_sc_scenario::run_go("mandos/get_empty_batch.scen.json"); -} - -#[test] -fn reject_elrond_to_ethereum_tx_batch_go() { - multiversx_sc_scenario::run_go("mandos/reject_elrond_to_ethereum_tx_batch.scen.json"); -} - -#[test] -fn setup_go() { - multiversx_sc_scenario::run_go("mandos/setup.scen.json"); -} - -#[test] -fn unstake_go() { - multiversx_sc_scenario::run_go("mandos/unstake.scen.json"); -} - -/* -#[test] -fn upgrade_child_sc_go() { - multiversx_sc_scenario::run_go("mandos/upgrade_child_sc.scen.json"); -} -*/ diff --git a/price-aggregator/mandos/deploy.scen.json b/price-aggregator/scenarios/deploy.scen.json similarity index 100% rename from price-aggregator/mandos/deploy.scen.json rename to price-aggregator/scenarios/deploy.scen.json diff --git a/price-aggregator/mandos/get_latest_price_feed.scen.json b/price-aggregator/scenarios/get_latest_price_feed.scen.json similarity index 100% rename from price-aggregator/mandos/get_latest_price_feed.scen.json rename to price-aggregator/scenarios/get_latest_price_feed.scen.json diff --git a/price-aggregator/mandos/oracle_gwei_in_eth_and_egld_submit.scen.json b/price-aggregator/scenarios/oracle_gwei_in_eth_and_egld_submit.scen.json similarity index 100% rename from price-aggregator/mandos/oracle_gwei_in_eth_and_egld_submit.scen.json rename to price-aggregator/scenarios/oracle_gwei_in_eth_and_egld_submit.scen.json diff --git a/price-aggregator/mandos/oracle_submit.scen.json b/price-aggregator/scenarios/oracle_submit.scen.json similarity index 100% rename from price-aggregator/mandos/oracle_submit.scen.json rename to price-aggregator/scenarios/oracle_submit.scen.json From 13cb2d41569f3df44fcaa2902f0c30af135abf10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Wed, 27 Dec 2023 12:30:39 +0200 Subject: [PATCH 2/3] Fix bridged-tokens-wrapper mandos unit tests --- .../scenarios/add_wrapped_token.scen.json | 16 +-- .../scenarios/blacklist_token.scen.json | 4 +- .../scenarios/setup.scen.json | 80 +++++-------- .../scenarios/unwrap_token.scen.json | 111 +++++++++++------- .../scenarios/whitelist_token.scen.json | 16 +-- .../scenarios/wrap_token.scen.json | 34 +++--- bridged-tokens-wrapper/src/lib.rs | 3 +- ...bridged_tokens_wrapper_scenario_rs_test.rs | 6 +- 8 files changed, 133 insertions(+), 137 deletions(-) diff --git a/bridged-tokens-wrapper/scenarios/add_wrapped_token.scen.json b/bridged-tokens-wrapper/scenarios/add_wrapped_token.scen.json index 0a0d8c44..13b0530d 100644 --- a/bridged-tokens-wrapper/scenarios/add_wrapped_token.scen.json +++ b/bridged-tokens-wrapper/scenarios/add_wrapped_token.scen.json @@ -13,18 +13,10 @@ "address:user": { "nonce": "0", "esdt": { - "str:USDC-aaaaaa": { - "balance": "500000000000000" - }, - "str:USDC-bbbbbb": { - "balance": "500000000000000" - }, - "str:USDC-cccccc": { - "balance": "500000000000000" - }, - "str:WUSDC-abcdef": { - "balance": "500" - } + "str:USDC-aaaaaa": "500,000,000,000,000", + "str:USDC-bbbbbb": "500,000,000,000,000", + "str:USDC-cccccc": "500,000,000,000,000", + "str:WUSDC-abcdef": "500" }, "storage": {} }, diff --git a/bridged-tokens-wrapper/scenarios/blacklist_token.scen.json b/bridged-tokens-wrapper/scenarios/blacklist_token.scen.json index 7f36f67d..ac76ef0e 100644 --- a/bridged-tokens-wrapper/scenarios/blacklist_token.scen.json +++ b/bridged-tokens-wrapper/scenarios/blacklist_token.scen.json @@ -33,10 +33,10 @@ "from": "address:user", "to": "sc:bridged_tokens_wrapper", "value": "0", - "esdt": { + "esdtValue": [{ "tokenIdentifier": "str:WUSDC-abcdef", "value": "100" - }, + }], "function": "unwrapToken", "arguments": [ "str:USDC-aaaaaa" diff --git a/bridged-tokens-wrapper/scenarios/setup.scen.json b/bridged-tokens-wrapper/scenarios/setup.scen.json index 6a11bc37..f80f15c2 100644 --- a/bridged-tokens-wrapper/scenarios/setup.scen.json +++ b/bridged-tokens-wrapper/scenarios/setup.scen.json @@ -13,24 +13,12 @@ "address:user": { "nonce": "7", "esdt": { - "str:USDC-aaaaaa": { - "balance": "300000000000000" - }, - "str:USDC-bbbbbb": { - "balance": "500000000000000" - }, - "str:USDC-cccccc": { - "balance": "400000000000000" - }, - "str:WUSDC-abcdef": { - "balance": "900" - }, - "str:WUSDC-ghijkl": { - "balance": "900" - }, - "str:WUSDC-mnopqr": { - "balance": "900" - } + "str:USDC-aaaaaa": "300,000,000,000,000", + "str:USDC-bbbbbb": "500,000,000,000,000", + "str:USDC-cccccc": "400,000,000,000,000", + "str:WUSDC-abcdef": "900", + "str:WUSDC-ghijkl": "900", + "str:WUSDC-mnopqr": "900" }, "storage": {} }, @@ -66,16 +54,16 @@ ] }, "str:USDC-aaaaaa": { - "balance": "300000000000000" + "balance": "300,000,000,000,000" }, "str:USDC-cccccc": { - "balance": "100000000000000" + "balance": "100,000,000,000,000" }, "str:USDC-ffffff": { - "balance": "400000000000000" + "balance": "400,000,000,000,000" }, "str:USDC-eeeeee": { - "balance": "400000000000000" + "balance": "400,000,000,000,000" } }, "storage": { @@ -101,10 +89,10 @@ "str:universalBridgedTokenIds.item|u32:2": "str:WUSDC-ghijkl", "str:universalBridgedTokenIds.index|nested:str:WUSDC-mnopqr": "3", "str:universalBridgedTokenIds.item|u32:3": "str:WUSDC-mnopqr", - "str:tokenLiquidity|nested:str:USDC-aaaaaa": "300000000000000", - "str:tokenLiquidity|nested:str:USDC-cccccc": "100000000000000", - "str:tokenLiquidity|nested:str:USDC-eeeeee": "400000000000000", - "str:tokenLiquidity|nested:str:USDC-ffffff": "400000000000000", + "str:tokenLiquidity|nested:str:USDC-aaaaaa": "300,000,000,000,000", + "str:tokenLiquidity|nested:str:USDC-cccccc": "100,000,000,000,000", + "str:tokenLiquidity|nested:str:USDC-eeeeee": "400,000,000,000,000", + "str:tokenLiquidity|nested:str:USDC-ffffff": "400,000,000,000,000", "str:token_decimals_num|nested:str:WUSDC-abcdef": "6", "str:token_decimals_num|nested:str:WUSDC-ghijkl": "6", "str:token_decimals_num|nested:str:USDC-aaaaaa": "18", @@ -126,24 +114,12 @@ "address:user": { "nonce": "7", "esdt": { - "str:USDC-aaaaaa": { - "balance": "300000000000000" - }, - "str:USDC-bbbbbb": { - "balance": "500000000000000" - }, - "str:USDC-cccccc": { - "balance": "400000000000000" - }, - "str:WUSDC-abcdef": { - "balance": "900" - }, - "str:WUSDC-ghijkl": { - "balance": "900" - }, - "str:WUSDC-mnopqr": { - "balance": "900" - } + "str:USDC-aaaaaa": "300,000,000,000,000", + "str:USDC-bbbbbb": "500,000,000,000,000", + "str:USDC-cccccc": "400,000,000,000,000", + "str:WUSDC-abcdef": "900", + "str:WUSDC-ghijkl": "900", + "str:WUSDC-mnopqr": "900" }, "storage": {} }, @@ -179,16 +155,16 @@ ] }, "str:USDC-aaaaaa": { - "balance": "300000000000000" + "balance": "300,000,000,000,000" }, "str:USDC-cccccc": { - "balance": "100000000000000" + "balance": "100,000,000,000,000" }, "str:USDC-eeeeee": { - "balance": "400000000000000" + "balance": "400,000,000,000,000" }, "str:USDC-ffffff": { - "balance": "400000000000000" + "balance": "400,000,000,000,000" } }, "storage": { @@ -214,10 +190,10 @@ "str:universalBridgedTokenIds.item|u32:2": "str:WUSDC-ghijkl", "str:universalBridgedTokenIds.index|nested:str:WUSDC-mnopqr": "3", "str:universalBridgedTokenIds.item|u32:3": "str:WUSDC-mnopqr", - "str:tokenLiquidity|nested:str:USDC-aaaaaa": "300000000000000", - "str:tokenLiquidity|nested:str:USDC-cccccc": "100000000000000", - "str:tokenLiquidity|nested:str:USDC-eeeeee": "400000000000000", - "str:tokenLiquidity|nested:str:USDC-ffffff": "400000000000000", + "str:tokenLiquidity|nested:str:USDC-aaaaaa": "300,000,000,000,000", + "str:tokenLiquidity|nested:str:USDC-cccccc": "100,000,000,000,000", + "str:tokenLiquidity|nested:str:USDC-eeeeee": "400,000,000,000,000", + "str:tokenLiquidity|nested:str:USDC-ffffff": "400,000,000,000,000", "str:token_decimals_num|nested:str:WUSDC-abcdef": "6", "str:token_decimals_num|nested:str:WUSDC-ghijkl": "6", "str:token_decimals_num|nested:str:USDC-aaaaaa": "18", diff --git a/bridged-tokens-wrapper/scenarios/unwrap_token.scen.json b/bridged-tokens-wrapper/scenarios/unwrap_token.scen.json index 819c3ecd..162938e0 100644 --- a/bridged-tokens-wrapper/scenarios/unwrap_token.scen.json +++ b/bridged-tokens-wrapper/scenarios/unwrap_token.scen.json @@ -13,10 +13,12 @@ "from": "address:user", "to": "sc:bridged_tokens_wrapper", "value": "0", - "esdt": { - "tokenIdentifier": "str:WUSDC-abcdef", - "value": "300" - }, + "esdtValue": [ + { + "tokenIdentifier": "str:WUSDC-abcdef", + "value": "300" + } + ], "function": "unwrapToken", "arguments": [ "str:USDC-bbbbbb" @@ -38,10 +40,12 @@ "from": "address:user", "to": "sc:bridged_tokens_wrapper", "value": "0", - "esdt": { - "tokenIdentifier": "str:WUSDC-abcdef", - "value": "500" - }, + "esdtValue": [ + { + "tokenIdentifier": "str:WUSDC-abcdef", + "value": "500" + } + ], "function": "unwrapToken", "arguments": [ "str:USDC-aaaaaa" @@ -63,10 +67,12 @@ "from": "address:user", "to": "sc:bridged_tokens_wrapper", "value": "0", - "esdt": { - "tokenIdentifier": "str:WUSDC-mnopqr", - "value": "500" - }, + "esdtValue": [ + { + "tokenIdentifier": "str:WUSDC-mnopqr", + "value": "500" + } + ], "function": "unwrapToken", "arguments": [ "str:USDC-eeeeee" @@ -88,10 +94,12 @@ "from": "address:user", "to": "sc:bridged_tokens_wrapper", "value": "0", - "esdt": { - "tokenIdentifier": "str:WUSDC-ghijkl", - "value": "500" - }, + "esdtValue": [ + { + "tokenIdentifier": "str:WUSDC-ghijkl", + "value": "500" + } + ], "function": "unwrapToken", "arguments": [ "str:USDC-ffffff" @@ -106,6 +114,33 @@ "refund": "*" } }, + { + "step": "scCall", + "txId": "wrap-token-a", + "tx": { + "from": "address:user", + "to": "sc:bridged_tokens_wrapper", + "function": "wrapTokens", + "esdtValue": [ + { + "tokenIdentifier": "str:USDC-aaaaaa", + "value": "100,000,000,000,000" + } + ], + "arguments": [], + "gasLimit": "5,000,000", + "gasPrice": "0" + }, + "expect": { + "status": "0", + "message": "", + "gas": "*", + "refund": "*", + "out": [ + "nested:str:WUSDC-abcdef|u64:0|biguint:100" + ] + } + }, { "step": "scCall", "txId": "unwrap-token", @@ -113,10 +148,12 @@ "from": "address:user", "to": "sc:bridged_tokens_wrapper", "value": "0", - "esdt": { - "tokenIdentifier": "str:WUSDC-abcdef", - "value": "100" - }, + "esdtValue": [ + { + "tokenIdentifier": "str:WUSDC-abcdef", + "value": "100" + } + ], "function": "unwrapToken", "arguments": [ "str:USDC-aaaaaa" @@ -140,27 +177,17 @@ "storage": {} }, "address:user": { - "nonce": "12", - "esdt": { - "str:USDC-aaaaaa": { - "balance": "400000000000000" - }, - "str:USDC-bbbbbb": { - "balance": "500000000000000" - }, - "str:USDC-cccccc": { - "balance": "400000000000000" - }, - "str:WUSDC-abcdef": { - "balance": "800" - }, - "str:WUSDC-ghijkl": { - "balance": "900" - }, - "str:WUSDC-mnopqr": { - "balance": "900" + "nonce": "13", + "esdtValue": [ + { + "str:USDC-aaaaaa": "400,000,000,000,000", + "str:USDC-bbbbbb": "500,000,000,000,000", + "str:USDC-cccccc": "400,000,000,000,000", + "str:WUSDC-abcdef": "800", + "str:WUSDC-ghijkl": "900", + "str:WUSDC-mnopqr": "900" } - }, + ], "storage": {} }, "sc:bridged_tokens_wrapper": { @@ -230,7 +257,7 @@ "str:universalBridgedTokenIds.item|u32:2": "str:WUSDC-ghijkl", "str:universalBridgedTokenIds.index|nested:str:WUSDC-mnopqr": "3", "str:universalBridgedTokenIds.item|u32:3": "str:WUSDC-mnopqr", - "str:tokenLiquidity|nested:str:USDC-aaaaaa": "200000000000000", + "str:tokenLiquidity|nested:str:USDC-aaaaaa": "300000000000000", "str:tokenLiquidity|nested:str:USDC-cccccc": "100000000000000", "str:tokenLiquidity|nested:str:USDC-eeeeee": "400000000000000", "str:tokenLiquidity|nested:str:USDC-ffffff": "400000000000000", @@ -245,4 +272,4 @@ } } ] -} +} \ No newline at end of file diff --git a/bridged-tokens-wrapper/scenarios/whitelist_token.scen.json b/bridged-tokens-wrapper/scenarios/whitelist_token.scen.json index 5a05ecaa..221aba29 100644 --- a/bridged-tokens-wrapper/scenarios/whitelist_token.scen.json +++ b/bridged-tokens-wrapper/scenarios/whitelist_token.scen.json @@ -83,18 +83,10 @@ "address:user": { "nonce": "1", "esdt": { - "str:USDC-aaaaaa": { - "balance": "500000000000000" - }, - "str:USDC-bbbbbb": { - "balance": "500000000000000" - }, - "str:USDC-cccccc": { - "balance": "500000000000000" - }, - "str:WUSDC-abcdef": { - "balance": "500" - } + "str:USDC-aaaaaa": "500,000,000,000,000", + "str:USDC-bbbbbb": "500,000,000,000,000", + "str:USDC-cccccc": "500,000,000,000,000", + "str:WUSDC-abcdef": "500" }, "storage": {} }, diff --git a/bridged-tokens-wrapper/scenarios/wrap_token.scen.json b/bridged-tokens-wrapper/scenarios/wrap_token.scen.json index 65a5dfba..cc637e17 100644 --- a/bridged-tokens-wrapper/scenarios/wrap_token.scen.json +++ b/bridged-tokens-wrapper/scenarios/wrap_token.scen.json @@ -13,12 +13,14 @@ "from": "address:user", "to": "sc:bridged_tokens_wrapper", "function": "wrapTokens", - "esdt": { - "tokenIdentifier": "str:USDC-bbbbbb", - "value": "300000000000000" - }, + "esdtValue": [ + { + "tokenIdentifier": "str:USDC-bbbbbb", + "value": "300,000,000,000,000" + } + ], "arguments": [], - "gasLimit": "5,000,000", + "gasLimit": "100,000,000", "gasPrice": "0" }, "expect": { @@ -38,10 +40,12 @@ "from": "address:user", "to": "sc:bridged_tokens_wrapper", "function": "wrapTokens", - "esdt": { - "tokenIdentifier": "str:USDC-aaaaaa", - "value": "300000000000000" - }, + "esdtValue": [ + { + "tokenIdentifier": "str:USDC-aaaaaa", + "value": "300,000,000,000,000" + } + ], "arguments": [], "gasLimit": "5,000,000", "gasPrice": "0" @@ -63,10 +67,12 @@ "from": "address:user", "to": "sc:bridged_tokens_wrapper", "function": "wrapTokens", - "esdt": { - "tokenIdentifier": "str:USDC-cccccc", - "value": "100000000000000" - }, + "esdtValue": [ + { + "tokenIdentifier": "str:USDC-cccccc", + "value": "100,000,000,000,000" + } + ], "arguments": [], "gasLimit": "5,000,000", "gasPrice": "0" @@ -154,4 +160,4 @@ } } ] -} +} \ No newline at end of file diff --git a/bridged-tokens-wrapper/src/lib.rs b/bridged-tokens-wrapper/src/lib.rs index c0a0f4bd..774754ef 100644 --- a/bridged-tokens-wrapper/src/lib.rs +++ b/bridged-tokens-wrapper/src/lib.rs @@ -1,7 +1,6 @@ #![no_std] mod dfp_big_uint; -use core::ops::Deref; pub use dfp_big_uint::DFPBigUint; use transaction::PaymentsVec; @@ -142,7 +141,7 @@ pub trait BridgedTokensWrapper: multiversx_sc_modules::pause::PauseModule { #[endpoint(wrapTokens)] fn wrap_tokens(&self) -> PaymentsVec { require!(self.not_paused(), "Contract is paused"); - let original_payments = self.call_value().all_esdt_transfers().deref().clone(); + let original_payments = self.call_value().all_esdt_transfers().clone_value(); if original_payments.is_empty() { return original_payments; } diff --git a/bridged-tokens-wrapper/tests/bridged_tokens_wrapper_scenario_rs_test.rs b/bridged-tokens-wrapper/tests/bridged_tokens_wrapper_scenario_rs_test.rs index c56d0406..445158b9 100644 --- a/bridged-tokens-wrapper/tests/bridged_tokens_wrapper_scenario_rs_test.rs +++ b/bridged-tokens-wrapper/tests/bridged_tokens_wrapper_scenario_rs_test.rs @@ -1,7 +1,11 @@ use multiversx_sc_scenario::*; fn world() -> ScenarioWorld { - todo!() + let mut blockchain = ScenarioWorld::new(); + blockchain.set_current_dir_from_workspace("bridged-tokens-wrapper/"); + + blockchain.register_contract("file:output/bridged-tokens-wrapper.wasm", bridged_tokens_wrapper::ContractBuilder); + blockchain } #[test] From a438fa29034dc49e3874e6b8457cb74376d10c8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Wed, 27 Dec 2023 12:31:08 +0200 Subject: [PATCH 3/3] Auto-generate scenarios unit tests --- esdt-safe/scenarios/setup_accounts.scen.json | 2 +- esdt-safe/tests/esdt_safe_scenario_rs_test.rs | 6 +++++- .../scenarios/batch_transfer_with_wrapping.scen.json | 2 +- multisig/scenarios/setup.scen.json | 2 +- multisig/tests/multisig_scenario_rs_test.rs | 6 +++++- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/esdt-safe/scenarios/setup_accounts.scen.json b/esdt-safe/scenarios/setup_accounts.scen.json index c6e77b27..1c2822c3 100644 --- a/esdt-safe/scenarios/setup_accounts.scen.json +++ b/esdt-safe/scenarios/setup_accounts.scen.json @@ -3,7 +3,7 @@ "steps": [ { "step": "externalSteps", - "path": "../../price-aggregator/mandos/get_latest_price_feed.scen.json" + "path": "../../price-aggregator/scenarios/get_latest_price_feed.scen.json" }, { "step": "setState", diff --git a/esdt-safe/tests/esdt_safe_scenario_rs_test.rs b/esdt-safe/tests/esdt_safe_scenario_rs_test.rs index a8db856b..cd2b7bbc 100644 --- a/esdt-safe/tests/esdt_safe_scenario_rs_test.rs +++ b/esdt-safe/tests/esdt_safe_scenario_rs_test.rs @@ -1,7 +1,11 @@ use multiversx_sc_scenario::*; fn world() -> ScenarioWorld { - todo!() + let mut blockchain = ScenarioWorld::new(); + blockchain.set_current_dir_from_workspace("esdt-safe/"); + + blockchain.register_contract("file:output/esdt-safe.wasm", esdt_safe::ContractBuilder); + blockchain } #[test] diff --git a/multi-transfer-esdt/scenarios/batch_transfer_with_wrapping.scen.json b/multi-transfer-esdt/scenarios/batch_transfer_with_wrapping.scen.json index 07bb451c..21e08d72 100644 --- a/multi-transfer-esdt/scenarios/batch_transfer_with_wrapping.scen.json +++ b/multi-transfer-esdt/scenarios/batch_transfer_with_wrapping.scen.json @@ -3,7 +3,7 @@ "steps": [ { "step": "externalSteps", - "path": "../../bridged-tokens-wrapper/mandos/whitelist_token.scen.json" + "path": "../../bridged-tokens-wrapper/scenarios/whitelist_token.scen.json" }, { "step": "setState", diff --git a/multisig/scenarios/setup.scen.json b/multisig/scenarios/setup.scen.json index 9739684e..e3165d96 100644 --- a/multisig/scenarios/setup.scen.json +++ b/multisig/scenarios/setup.scen.json @@ -3,7 +3,7 @@ "steps": [ { "step": "externalSteps", - "path": "../../price-aggregator/mandos/oracle_gwei_in_eth_and_egld_submit.scen.json" + "path": "../../price-aggregator/scenarios/oracle_gwei_in_eth_and_egld_submit.scen.json" }, { "step": "setState", diff --git a/multisig/tests/multisig_scenario_rs_test.rs b/multisig/tests/multisig_scenario_rs_test.rs index 081aa6c3..be5e8d0b 100644 --- a/multisig/tests/multisig_scenario_rs_test.rs +++ b/multisig/tests/multisig_scenario_rs_test.rs @@ -1,7 +1,11 @@ use multiversx_sc_scenario::*; fn world() -> ScenarioWorld { - todo!() + let mut blockchain = ScenarioWorld::new(); + blockchain.set_current_dir_from_workspace("multisig/"); + + blockchain.register_contract("file:output/multisig.wasm", multisig::ContractBuilder); + blockchain } #[test]