Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Roznovjak committed Oct 2, 2024
1 parent 4bca2b6 commit d38504e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 41 deletions.
75 changes: 37 additions & 38 deletions pallets/amm-support/src/tests/incremental_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,53 +15,52 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use hydradx_traits::router::{Filler, TradeOperation};
use crate::tests::mock::*;
use crate::Event;
use hydradx_traits::router::{Filler, TradeOperation};

#[test]
fn event_id_should_be_incremented() {
ExtBuilder::default().build().execute_with(|| {
ExtBuilder::default().build().execute_with(|| {
assert_eq!(AmmSupport::incremental_id(), 0);
assert_eq!(AmmSupport::next_incremental_id(), 0);

assert_eq!(AmmSupport::incremental_id(), 0);
assert_eq!(AmmSupport::next_incremental_id(), 0);

assert_eq!(AmmSupport::incremental_id(), 1);
assert_eq!(AmmSupport::next_incremental_id(), 1);
assert_eq!(AmmSupport::incremental_id(), 1);
assert_eq!(AmmSupport::next_incremental_id(), 1);

assert_eq!(AmmSupport::incremental_id(), 2);
assert_eq!(AmmSupport::next_incremental_id(), 2);
});
assert_eq!(AmmSupport::incremental_id(), 2);
assert_eq!(AmmSupport::next_incremental_id(), 2);
});
}

#[test]
fn event_should_be_deposited() {
ExtBuilder::default().build().execute_with(|| {
AmmSupport::deposit_trade_event(
ALICE,
BOB,
Filler::Omnipool,
TradeOperation::Sell,
HDX,
DOT,
1_000_000,
2_000_000,
vec![(HDX, 1_000, ALICE), (DOT, 2_000, BOB)],
Some(7),
);
ExtBuilder::default().build().execute_with(|| {
AmmSupport::deposit_trade_event(
ALICE,
BOB,
Filler::Omnipool,
TradeOperation::Sell,
HDX,
DOT,
1_000_000,
2_000_000,
vec![(HDX, 1_000, ALICE), (DOT, 2_000, BOB)],
Some(7),
);

expect_events(vec![Event::Swapped {
swapper: ALICE,
filler: BOB,
filler_type: Filler::Omnipool,
operation: TradeOperation::Sell,
asset_in: HDX,
asset_out: DOT,
amount_in: 1_000_000,
amount_out: 2_000_000,
fees: vec![(HDX, 1_000, ALICE), (DOT, 2_000, BOB)],
event_id: Some(7),
}
.into()]);
});
}
expect_events(vec![Event::Swapped {
swapper: ALICE,
filler: BOB,
filler_type: Filler::Omnipool,
operation: TradeOperation::Sell,
asset_in: HDX,
asset_out: DOT,
amount_in: 1_000_000,
amount_out: 2_000_000,
fees: vec![(HDX, 1_000, ALICE), (DOT, 2_000, BOB)],
event_id: Some(7),
}
.into()]);
});
}
3 changes: 1 addition & 2 deletions pallets/amm-support/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ impl frame_system::Config for Test {
}

#[derive(Default)]
pub struct ExtBuilder {
}
pub struct ExtBuilder {}

impl ExtBuilder {
pub fn build(self) -> sp_io::TestExternalities {
Expand Down
2 changes: 1 addition & 1 deletion pallets/amm-support/src/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pub mod mock;
mod incremental_id;
pub mod mock;

0 comments on commit d38504e

Please sign in to comment.