MCPcopy Create free account
hub / github.com/cowprotocol/services / assert_allows_failed_transfer

Function assert_allows_failed_transfer

crates/shared/src/order_validation.rs:2689–2776  ·  view source on GitHub ↗
(
            create_error: impl Fn() -> TransferSimulationError + Send + 'static,
            is_expected_error: impl Fn(ValidationError) -> bool,
        )

Source from the content-addressed store, hash-verified

2687 #[test]
2688 fn allows_insufficient_allowance_and_balance_for_presign_orders() {
2689 fn assert_allows_failed_transfer(
2690 create_error: impl Fn() -> TransferSimulationError + Send + 'static,
2691 is_expected_error: impl Fn(ValidationError) -> bool,
2692 ) {
2693 let mut order_quoter = MockOrderQuoting::new();
2694 let mut balance_fetcher = MockBalanceFetching::new();
2695 order_quoter
2696 .expect_find_quote()
2697 .returning(|_, _| Ok(Default::default()));
2698 balance_fetcher
2699 .expect_can_transfer()
2700 .returning(move |_, _| Err(create_error()));
2701 balance_fetcher
2702 .expect_allowance()
2703 .returning(|_, _, _| Ok(U256::ZERO));
2704 let mut limit_order_counter = MockLimitOrderCounting::new();
2705 limit_order_counter.expect_count().returning(|_| Ok(0u64));
2706 let native_token =
2707 WETH9::Instance::new([0xef; 20].into(), ethrpc::mock::web3().provider);
2708 let validator = OrderValidator::new(
2709 native_token,
2710 Arc::new(order_validation::banned::Users::none()),
2711 OrderValidPeriodConfiguration::any(),
2712 false,
2713 Default::default(),
2714 HooksTrampoline::Instance::new(
2715 Address::from([0xcf; 20]),
2716 ProviderBuilder::new()
2717 .connect_mocked_client(Asserter::new())
2718 .erased(),
2719 ),
2720 Arc::new(order_quoter),
2721 Arc::new(balance_fetcher),
2722 Arc::new(MockSignatureValidating::new()),
2723 None,
2724 Arc::new(limit_order_counter),
2725 0,
2726 Default::default(),
2727 u64::MAX,
2728 SameTokensPolicy::Disallow,
2729 Arc::new(LegacyVolumeFees::default()),
2730 wrapper_validator(),
2731 );
2732
2733 let order = OrderCreation {
2734 valid_to: u32::MAX,
2735 sell_token: Address::with_last_byte(1),
2736 sell_amount: alloy::primitives::U256::from(1),
2737 buy_token: Address::with_last_byte(2),
2738 buy_amount: alloy::primitives::U256::from(1),
2739 app_data: OrderCreationAppData::Full {
2740 full: "{}".to_string(),
2741 },
2742 ..Default::default()
2743 };
2744
2745 for signing_scheme in [EcdsaSigningScheme::Eip712, EcdsaSigningScheme::EthSign] {
2746 let err = validator

Calls 8

wrapper_validatorFunction · 0.85
unwrapMethod · 0.80
web3Function · 0.70
newFunction · 0.50
intoMethod · 0.45
signMethod · 0.45
cloneMethod · 0.45