Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
dorin-iancu committed Feb 28, 2024
1 parent 8720b69 commit 2dad4c0
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@
"str:WEGLD-123456",
"76,000,000,000",
"u64:1",
"0x01|u8:4|str:data|u32:20000000|u8:0",
"0x01|u8:4|str:data|u32:5,000,000|u8:0",
"0x0102030405060708091011121314151617181920",
"sc:egld_esdt_swap",
"str:ETH-123456",
"76,000,000,000",
"u64:2",
"0x01|u8:4|str:data|u32:20000000|u8:0"
"0x01|u8:4|str:data|u32:5,000,000|u8:0"
],
"gasLimit": "50,000,000",
"gasPrice": "0"
Expand Down Expand Up @@ -127,15 +127,15 @@
"3-token_id": "nested:str:WEGLD-123456",
"4-amount": "biguint:76,000,000,000",
"5-tx_id": "u64:1",
"6-call_data": "0x01|u8:4|str:data|u32:20000000|u8:0"
"6-call_data": "0x01|u8:4|str:data|u32:5,000,000|u8:0"
},
{
"1-from": "0x0102030405060708091011121314151617181920",
"2-to": "sc:egld_esdt_swap",
"3-token_id": "nested:str:ETH-123456",
"4-amount": "biguint:76,000,000,000",
"5-tx_id": "u64:2",
"6-call_data": "0x01|u8:4|str:data|u32:20000000|u8:0"
"6-call_data": "0x01|u8:4|str:data|u32:5,000,000|u8:0"
}
]
},
Expand Down
14 changes: 7 additions & 7 deletions multisig/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#![no_std]
#![allow(clippy::too_many_arguments)]

mod action;
mod multisig_general;
mod queries;
mod setup;
mod storage;
mod user_role;
mod util;
pub mod action;
pub mod multisig_general;
pub mod queries;
pub mod setup;
pub mod storage;
pub mod user_role;
pub mod util;

use action::Action;
use token_module::{AddressPercentagePair, INVALID_PERCENTAGE_SUM_OVER_ERR_MSG, PERCENTAGE_TOTAL};
Expand Down
100 changes: 100 additions & 0 deletions multisig/tests/multisig_rust_test.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
#![allow(deprecated)]

pub mod multisig_setup;
use eth_address::EthAddress;
use multisig::multisig_general::MultisigGeneralModule;
use multisig::Multisig;
use multisig_setup::*;
use multiversx_sc::types::{ManagedByteArray, ManagedVec, MultiValueEncoded};
use multiversx_sc_scenario::{
managed_address, managed_biguint, managed_buffer, managed_token_id, rust_biguint,
};
use transaction::call_data::CallData;

#[test]
fn setup_test() {
Expand All @@ -12,3 +20,95 @@ fn setup_test() {
multisig::contract_obj,
);
}

#[test]
fn eth_to_mx_transfer_both_rejected_test() {
let mut setup = MultisigSetup::new(
multiversx_price_aggregator_sc::contract_obj,
esdt_safe::contract_obj,
multi_transfer_esdt::contract_obj,
multisig::contract_obj,
);

let dest_sc = setup.b_mock.create_sc_account(
&rust_biguint!(0),
Some(&setup.owner_addr),
esdt_safe::contract_obj,
"other esdt safe wasm path",
);

setup
.b_mock
.execute_tx(
&setup.relayer_1,
&setup.multisig_wrapper,
&rust_biguint!(0),
|sc| {
let mut transfers = MultiValueEncoded::new();
let user_eth_addr = EthAddress {
raw_addr: ManagedByteArray::new_from_bytes(&[
01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,

Check warning on line 50 in multisig/tests/multisig_rust_test.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] multisig/tests/multisig_rust_test.rs#L50

warning: this is a decimal constant --> multisig/tests/multisig_rust_test.rs:50:25 | 50 | 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, | ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#zero_prefixed_literal = note: `#[warn(clippy::zero_prefixed_literal)]` on by default help: if you mean to use a decimal constant, remove the `0` to avoid confusion | 50 | 1, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, | ~ help: if you mean to use an octal constant, use `0o` | 50 | 0o1, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, | ~~~
Raw output
multisig/tests/multisig_rust_test.rs:50:25:w:warning: this is a decimal constant
  --> multisig/tests/multisig_rust_test.rs:50:25
   |
50 |                         01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
   |                         ^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#zero_prefixed_literal
   = note: `#[warn(clippy::zero_prefixed_literal)]` on by default
help: if you mean to use a decimal constant, remove the `0` to avoid confusion
   |
50 |                         1, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
   |                         ~
help: if you mean to use an octal constant, use `0o`
   |
50 |                         0o1, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
   |                         ~~~


__END__

Check warning on line 50 in multisig/tests/multisig_rust_test.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] multisig/tests/multisig_rust_test.rs#L50

warning: this is a decimal constant --> multisig/tests/multisig_rust_test.rs:50:29 | 50 | 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, | ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#zero_prefixed_literal help: if you mean to use a decimal constant, remove the `0` to avoid confusion | 50 | 01, 2, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, | ~ help: if you mean to use an octal constant, use `0o` | 50 | 01, 0o2, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, | ~~~
Raw output
multisig/tests/multisig_rust_test.rs:50:29:w:warning: this is a decimal constant
  --> multisig/tests/multisig_rust_test.rs:50:29
   |
50 |                         01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
   |                             ^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#zero_prefixed_literal
help: if you mean to use a decimal constant, remove the `0` to avoid confusion
   |
50 |                         01, 2, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
   |                             ~
help: if you mean to use an octal constant, use `0o`
   |
50 |                         01, 0o2, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
   |                             ~~~


__END__

Check warning on line 50 in multisig/tests/multisig_rust_test.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] multisig/tests/multisig_rust_test.rs#L50

warning: this is a decimal constant --> multisig/tests/multisig_rust_test.rs:50:33 | 50 | 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, | ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#zero_prefixed_literal help: if you mean to use a decimal constant, remove the `0` to avoid confusion | 50 | 01, 02, 3, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, | ~ help: if you mean to use an octal constant, use `0o` | 50 | 01, 02, 0o3, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, | ~~~
Raw output
multisig/tests/multisig_rust_test.rs:50:33:w:warning: this is a decimal constant
  --> multisig/tests/multisig_rust_test.rs:50:33
   |
50 |                         01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
   |                                 ^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#zero_prefixed_literal
help: if you mean to use a decimal constant, remove the `0` to avoid confusion
   |
50 |                         01, 02, 3, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
   |                                 ~
help: if you mean to use an octal constant, use `0o`
   |
50 |                         01, 02, 0o3, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
   |                                 ~~~


__END__

Check warning on line 50 in multisig/tests/multisig_rust_test.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] multisig/tests/multisig_rust_test.rs#L50

warning: this is a decimal constant --> multisig/tests/multisig_rust_test.rs:50:37 | 50 | 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, | ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#zero_prefixed_literal help: if you mean to use a decimal constant, remove the `0` to avoid confusion | 50 | 01, 02, 03, 4, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, | ~ help: if you mean to use an octal constant, use `0o` | 50 | 01, 02, 03, 0o4, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, | ~~~
Raw output
multisig/tests/multisig_rust_test.rs:50:37:w:warning: this is a decimal constant
  --> multisig/tests/multisig_rust_test.rs:50:37
   |
50 |                         01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
   |                                     ^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#zero_prefixed_literal
help: if you mean to use a decimal constant, remove the `0` to avoid confusion
   |
50 |                         01, 02, 03, 4, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
   |                                     ~
help: if you mean to use an octal constant, use `0o`
   |
50 |                         01, 02, 03, 0o4, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
   |                                     ~~~


__END__

Check warning on line 50 in multisig/tests/multisig_rust_test.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] multisig/tests/multisig_rust_test.rs#L50

warning: this is a decimal constant --> multisig/tests/multisig_rust_test.rs:50:41 | 50 | 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, | ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#zero_prefixed_literal help: if you mean to use a decimal constant, remove the `0` to avoid confusion | 50 | 01, 02, 03, 04, 5, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, | ~ help: if you mean to use an octal constant, use `0o` | 50 | 01, 02, 03, 04, 0o5, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, | ~~~
Raw output
multisig/tests/multisig_rust_test.rs:50:41:w:warning: this is a decimal constant
  --> multisig/tests/multisig_rust_test.rs:50:41
   |
50 |                         01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
   |                                         ^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#zero_prefixed_literal
help: if you mean to use a decimal constant, remove the `0` to avoid confusion
   |
50 |                         01, 02, 03, 04, 5, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
   |                                         ~
help: if you mean to use an octal constant, use `0o`
   |
50 |                         01, 02, 03, 04, 0o5, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
   |                                         ~~~


__END__

Check warning on line 50 in multisig/tests/multisig_rust_test.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] multisig/tests/multisig_rust_test.rs#L50

warning: this is a decimal constant --> multisig/tests/multisig_rust_test.rs:50:45 | 50 | 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, | ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#zero_prefixed_literal help: if you mean to use a decimal constant, remove the `0` to avoid confusion | 50 | 01, 02, 03, 04, 05, 6, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, | ~ help: if you mean to use an octal constant, use `0o` | 50 | 01, 02, 03, 04, 05, 0o6, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, | ~~~
Raw output
multisig/tests/multisig_rust_test.rs:50:45:w:warning: this is a decimal constant
  --> multisig/tests/multisig_rust_test.rs:50:45
   |
50 |                         01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
   |                                             ^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#zero_prefixed_literal
help: if you mean to use a decimal constant, remove the `0` to avoid confusion
   |
50 |                         01, 02, 03, 04, 05, 6, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
   |                                             ~
help: if you mean to use an octal constant, use `0o`
   |
50 |                         01, 02, 03, 04, 05, 0o6, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
   |                                             ~~~


__END__

Check warning on line 50 in multisig/tests/multisig_rust_test.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] multisig/tests/multisig_rust_test.rs#L50

warning: this is a decimal constant --> multisig/tests/multisig_rust_test.rs:50:49 | 50 | 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, | ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#zero_prefixed_literal help: if you mean to use a decimal constant, remove the `0` to avoid confusion | 50 | 01, 02, 03, 04, 05, 06, 7, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, | ~ help: if you mean to use an octal constant, use `0o` | 50 | 01, 02, 03, 04, 05, 06, 0o7, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, | ~~~
Raw output
multisig/tests/multisig_rust_test.rs:50:49:w:warning: this is a decimal constant
  --> multisig/tests/multisig_rust_test.rs:50:49
   |
50 |                         01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
   |                                                 ^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#zero_prefixed_literal
help: if you mean to use a decimal constant, remove the `0` to avoid confusion
   |
50 |                         01, 02, 03, 04, 05, 06, 7, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
   |                                                 ~
help: if you mean to use an octal constant, use `0o`
   |
50 |                         01, 02, 03, 04, 05, 06, 0o7, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
   |                                                 ~~~


__END__

Check warning on line 50 in multisig/tests/multisig_rust_test.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] multisig/tests/multisig_rust_test.rs#L50

warning: this is a decimal constant --> multisig/tests/multisig_rust_test.rs:50:53 | 50 | 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, | ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#zero_prefixed_literal help: if you mean to use a decimal constant, remove the `0` to avoid confusion | 50 | 01, 02, 03, 04, 05, 06, 07, 8, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, | ~
Raw output
multisig/tests/multisig_rust_test.rs:50:53:w:warning: this is a decimal constant
  --> multisig/tests/multisig_rust_test.rs:50:53
   |
50 |                         01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
   |                                                     ^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#zero_prefixed_literal
help: if you mean to use a decimal constant, remove the `0` to avoid confusion
   |
50 |                         01, 02, 03, 04, 05, 06, 07, 8, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
   |                                                     ~


__END__

Check warning on line 50 in multisig/tests/multisig_rust_test.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] multisig/tests/multisig_rust_test.rs#L50

warning: this is a decimal constant --> multisig/tests/multisig_rust_test.rs:50:57 | 50 | 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, | ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#zero_prefixed_literal help: if you mean to use a decimal constant, remove the `0` to avoid confusion | 50 | 01, 02, 03, 04, 05, 06, 07, 08, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, | ~
Raw output
multisig/tests/multisig_rust_test.rs:50:57:w:warning: this is a decimal constant
  --> multisig/tests/multisig_rust_test.rs:50:57
   |
50 |                         01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
   |                                                         ^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#zero_prefixed_literal
help: if you mean to use a decimal constant, remove the `0` to avoid confusion
   |
50 |                         01, 02, 03, 04, 05, 06, 07, 08, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
   |                                                         ~


__END__
20,
]),
};
transfers.push(
(
user_eth_addr.clone(),
managed_address!(dest_sc.address_ref()),
managed_token_id!(WEGLD_TOKEN_ID),
managed_biguint!(76_000_000_000),
1,
Some(CallData {
endpoint: managed_buffer!(b"data"),
gas_limit: 5_000_000,
args: ManagedVec::new(),
}),
)
.into(),
);
transfers.push(
(
user_eth_addr,
managed_address!(dest_sc.address_ref()),
managed_token_id!(ETH_TOKEN_ID),
managed_biguint!(76_000_000_000),
2,
Some(CallData {
endpoint: managed_buffer!(b"data"),
gas_limit: 5_000_000,
args: ManagedVec::new(),
}),
)
.into(),
);

let action_id = sc.propose_multi_transfer_esdt_batch(1, transfers);
assert_eq!(action_id, 1);
},
)
.assert_ok();

setup
.b_mock
.execute_tx(
&setup.relayer_2,
&setup.multisig_wrapper,
&rust_biguint!(0),
|sc| {
sc.sign(1);
},
)
.assert_ok();

setup
.b_mock
.execute_tx(
&setup.relayer_1,
&setup.multisig_wrapper,
&rust_biguint!(0),
|sc| {
sc.perform_action_endpoint(1);
},
)
.assert_ok();
}
8 changes: 4 additions & 4 deletions multisig/tests/multisig_scenario_rs_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ fn ethereum_to_multiversx_tx_batch_ok_rs() {
world().run("scenarios/ethereum_to_multiversx_tx_batch_ok.scen.json");
}

// #[test]
// fn ethereum_to_multiversx_tx_batch_rejected_rs() {
// world().run("scenarios/ethereum_to_multiversx_tx_batch_rejected.scen.json");
// }
#[test]
fn ethereum_to_multiversx_tx_batch_rejected_rs() {
world().run("scenarios/ethereum_to_multiversx_tx_batch_rejected.scen.json");
}

#[test]
fn ethereum_to_multiversx_tx_batch_without_data_rs() {
Expand Down
6 changes: 6 additions & 0 deletions multisig/tests/multisig_setup/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ pub struct MultisigSetup<
pub multi_transfer_wrapper:
ContractObjWrapper<multi_transfer_esdt::ContractObj<DebugApi>, MultiTransferBuilder>,
pub multisig_wrapper: ContractObjWrapper<multisig::ContractObj<DebugApi>, MultisigBuilder>,
pub relayer_1: Address,
pub relayer_2: Address,
pub user: Address,
}

impl<PriceAggregatorBuilder, EsdtSafeBuilder, MultiTransferBuilder, MultisigBuilder>
Expand Down Expand Up @@ -324,6 +327,9 @@ where
esdt_safe_wrapper,
multi_transfer_wrapper,
multisig_wrapper,
relayer_1,
relayer_2,
user,
}
}
}
8 changes: 4 additions & 4 deletions multisig/tests/scenario_go_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ fn ethereum_to_multiversx_tx_batch_ok_go() {
world().run("scenarios/ethereum_to_multiversx_tx_batch_ok.scen.json");
}

// #[test]
// fn ethereum_to_multiversx_tx_batch_rejected_go() {
// world().run("scenarios/ethereum_to_multiversx_tx_batch_rejected.scen.json");
// }
#[test]
fn ethereum_to_multiversx_tx_batch_rejected_go() {
world().run("scenarios/ethereum_to_multiversx_tx_batch_rejected.scen.json");
}

#[test]
fn execute_multiversx_to_ethereum_tx_batch_go() {
Expand Down

0 comments on commit 2dad4c0

Please sign in to comment.