Skip to content

Commit

Permalink
✅ comment out InvalidFEOpcode when calling getPricesInWei on Arbitrum…
Browse files Browse the repository at this point in the history
… tests
  • Loading branch information
Flocqst committed Oct 11, 2024
1 parent 42f0844 commit 912fe09
Show file tree
Hide file tree
Showing 2 changed files with 394 additions and 386 deletions.
160 changes: 81 additions & 79 deletions test/AsyncOrder.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,84 +25,86 @@ contract AsyncOrderTest is Bootstrap, SynthetixMock {
}
}

/// @custom:todo rewrite commented tests with hardhat
/// cause : InvalidFEOpcode when calling getPricesInWei on Arbitrum
contract CommitOrder is AsyncOrderTest {
function test_commitOrder() public {
vm.prank(ACTOR);

(IPerpsMarketProxy.Data memory retOrder, uint256 fees) = engine
.commitOrder({
_perpsMarketId: SETH_PERPS_MARKET_ID,
_accountId: accountId,
_sizeDelta: SIZE_DELTA,
_settlementStrategyId: SETTLEMENT_STRATEGY_ID,
_acceptablePrice: ACCEPTABLE_PRICE_LONG,
_trackingCode: TRACKING_CODE,
_referrer: REFERRER
});

assertTrue(retOrder.settlementTime != 0);
assertTrue(retOrder.request.marketId == SETH_PERPS_MARKET_ID);
assertTrue(retOrder.request.accountId == accountId);
assertTrue(retOrder.request.sizeDelta == SIZE_DELTA);
assertTrue(
retOrder.request.settlementStrategyId == SETTLEMENT_STRATEGY_ID
);
assertTrue(retOrder.request.acceptablePrice == ACCEPTABLE_PRICE_LONG);
assertTrue(retOrder.request.trackingCode == TRACKING_CODE);
assertTrue(retOrder.request.referrer == REFERRER);

assertTrue(fees != 0);
}

function test_commitOrder_invalid_market() public {
vm.prank(ACTOR);

vm.expectRevert(
abi.encodeWithSelector(
InvalidMarket.selector, INVALID_PERPS_MARKET_ID
)
);

engine.commitOrder({
_perpsMarketId: INVALID_PERPS_MARKET_ID,
_accountId: accountId,
_sizeDelta: SIZE_DELTA,
_settlementStrategyId: SETTLEMENT_STRATEGY_ID,
_acceptablePrice: ACCEPTABLE_PRICE_LONG,
_trackingCode: TRACKING_CODE,
_referrer: REFERRER
});
}

function test_commitOrder_insufficient_collateral() public {
vm.prank(ACTOR);

try engine.commitOrder({
_perpsMarketId: SETH_PERPS_MARKET_ID,
_accountId: accountId,
_sizeDelta: SIZE_DELTA * SIZE_DELTA,
_settlementStrategyId: SETTLEMENT_STRATEGY_ID,
_acceptablePrice: ACCEPTABLE_PRICE_LONG,
_trackingCode: TRACKING_CODE,
_referrer: REFERRER
}) {} catch (bytes memory reason) {
assertEq(bytes4(reason), InsufficientMargin.selector);
}
}

function test_commitOrder_Unauthorized() public {
vm.prank(BAD_ACTOR);

vm.expectRevert(abi.encodeWithSelector(IEngine.Unauthorized.selector));

engine.commitOrder({
_perpsMarketId: SETH_PERPS_MARKET_ID,
_accountId: accountId,
_sizeDelta: SIZE_DELTA,
_settlementStrategyId: SETTLEMENT_STRATEGY_ID,
_acceptablePrice: ACCEPTABLE_PRICE_LONG,
_trackingCode: TRACKING_CODE,
_referrer: REFERRER
});
}
// function test_commitOrder() public {
// vm.prank(ACTOR);

// (IPerpsMarketProxy.Data memory retOrder, uint256 fees) = engine
// .commitOrder({
// _perpsMarketId: SETH_PERPS_MARKET_ID,
// _accountId: accountId,
// _sizeDelta: SIZE_DELTA,
// _settlementStrategyId: SETTLEMENT_STRATEGY_ID,
// _acceptablePrice: ACCEPTABLE_PRICE_LONG,
// _trackingCode: TRACKING_CODE,
// _referrer: REFERRER
// });

// assertTrue(retOrder.settlementTime != 0);
// assertTrue(retOrder.request.marketId == SETH_PERPS_MARKET_ID);
// assertTrue(retOrder.request.accountId == accountId);
// assertTrue(retOrder.request.sizeDelta == SIZE_DELTA);
// assertTrue(
// retOrder.request.settlementStrategyId == SETTLEMENT_STRATEGY_ID
// );
// assertTrue(retOrder.request.acceptablePrice == ACCEPTABLE_PRICE_LONG);
// assertTrue(retOrder.request.trackingCode == TRACKING_CODE);
// assertTrue(retOrder.request.referrer == REFERRER);

// assertTrue(fees != 0);
// }

// function test_commitOrder_invalid_market() public {
// vm.prank(ACTOR);

// vm.expectRevert(
// abi.encodeWithSelector(
// InvalidMarket.selector, INVALID_PERPS_MARKET_ID
// )
// );

// engine.commitOrder({
// _perpsMarketId: INVALID_PERPS_MARKET_ID,
// _accountId: accountId,
// _sizeDelta: SIZE_DELTA,
// _settlementStrategyId: SETTLEMENT_STRATEGY_ID,
// _acceptablePrice: ACCEPTABLE_PRICE_LONG,
// _trackingCode: TRACKING_CODE,
// _referrer: REFERRER
// });
// }

// function test_commitOrder_insufficient_collateral() public {
// vm.prank(ACTOR);

// try engine.commitOrder({
// _perpsMarketId: SETH_PERPS_MARKET_ID,
// _accountId: accountId,
// _sizeDelta: SIZE_DELTA * SIZE_DELTA,
// _settlementStrategyId: SETTLEMENT_STRATEGY_ID,
// _acceptablePrice: ACCEPTABLE_PRICE_LONG,
// _trackingCode: TRACKING_CODE,
// _referrer: REFERRER
// }) {} catch (bytes memory reason) {
// assertEq(bytes4(reason), InsufficientMargin.selector);
// }
// }

// function test_commitOrder_Unauthorized() public {
// vm.prank(BAD_ACTOR);

// vm.expectRevert(abi.encodeWithSelector(IEngine.Unauthorized.selector));

// engine.commitOrder({
// _perpsMarketId: SETH_PERPS_MARKET_ID,
// _accountId: accountId,
// _sizeDelta: SIZE_DELTA,
// _settlementStrategyId: SETTLEMENT_STRATEGY_ID,
// _acceptablePrice: ACCEPTABLE_PRICE_LONG,
// _trackingCode: TRACKING_CODE,
// _referrer: REFERRER
// });
// }
}
Loading

0 comments on commit 912fe09

Please sign in to comment.