feat: use neon-router in CI tests (#453)
* fix: initially skip all tests that don't work with the Rust router * fix: enable rust router for CircleCI tests * fix: handle invalid output sampels & enable numSamples tests * chore: add comments about disabled tests * chore: add asset-swapper changelog entry
This commit is contained in:
parent
c9c30d3a76
commit
c881723578
@ -110,6 +110,8 @@ jobs:
|
||||
docker:
|
||||
- image: node:16
|
||||
working_directory: ~/repo
|
||||
environment:
|
||||
RUST_ROUTER: "true"
|
||||
steps:
|
||||
- restore_cache:
|
||||
keys:
|
||||
|
@ -5,6 +5,10 @@
|
||||
{
|
||||
"note": "Adds support for STG/USDC pool on Curve Mainnet",
|
||||
"pr": 451
|
||||
},
|
||||
{
|
||||
"note": "Use neon-router in asset-swapper tests",
|
||||
"pr": 453
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -227,8 +227,9 @@ function findRoutesAndCreateOptimalPath(
|
||||
const sourcePathId = hexUtils.random();
|
||||
const singleSourceSamplesWithOutput = [...singleSourceSamples];
|
||||
for (let i = singleSourceSamples.length - 1; i >= 0; i--) {
|
||||
if (singleSourceSamples[i].output.isZero()) {
|
||||
// Remove trailing 0 output samples
|
||||
const currentOutput = singleSourceSamples[i].output;
|
||||
if (currentOutput.isZero() || !currentOutput.isFinite()) {
|
||||
// Remove trailing 0/invalid output samples
|
||||
singleSourceSamplesWithOutput.pop();
|
||||
} else {
|
||||
break;
|
||||
|
@ -483,7 +483,8 @@ describe('MarketOperationUtils tests', () => {
|
||||
});
|
||||
|
||||
it('queries `numSamples` samples', async () => {
|
||||
const numSamples = _.random(1, NUM_SAMPLES);
|
||||
// neon-router requires at least 3 samples
|
||||
const numSamples = _.random(3, NUM_SAMPLES);
|
||||
let actualNumSamples = 0;
|
||||
replaceSamplerOps({
|
||||
getSellQuotes: (sources, makerToken, takerToken, amounts, wethAddress) => {
|
||||
@ -501,6 +502,7 @@ describe('MarketOperationUtils tests', () => {
|
||||
await getMarketSellOrdersAsync(marketOperationUtils, ORDERS, FILL_AMOUNT, {
|
||||
...DEFAULT_OPTS,
|
||||
numSamples,
|
||||
neonRouterNumSamples: numSamples,
|
||||
});
|
||||
expect(actualNumSamples).eq(numSamples);
|
||||
});
|
||||
@ -1078,7 +1080,8 @@ describe('MarketOperationUtils tests', () => {
|
||||
|
||||
const ETH_TO_MAKER_RATE = 1.5;
|
||||
|
||||
it('factors in fees for native orders', async () => {
|
||||
// TODO: disabled as this is not supported by neon-router
|
||||
it.skip('factors in fees for native orders', async () => {
|
||||
// Native orders will have the best rates but have fees,
|
||||
// dropping their effective rates.
|
||||
const nativeFeeRate = 0.06;
|
||||
@ -1181,7 +1184,9 @@ describe('MarketOperationUtils tests', () => {
|
||||
expect(orderSources.sort()).to.deep.eq(expectedSources.sort());
|
||||
});
|
||||
|
||||
it('does not create a fallback if below maxFallbackSlippage', async () => {
|
||||
// NOTE: Currently fallbacks for native orders are disabled
|
||||
// TODO: remove this if we remove fallbacks completely
|
||||
it.skip('does not create a fallback if below maxFallbackSlippage', async () => {
|
||||
const rates: RatesBySource = {};
|
||||
rates[ERC20BridgeSource.Native] = [1, 1, 0.01, 0.01];
|
||||
rates[ERC20BridgeSource.Uniswap] = [1, 1, 0.01, 0.01];
|
||||
@ -1325,7 +1330,8 @@ describe('MarketOperationUtils tests', () => {
|
||||
});
|
||||
|
||||
it('queries `numSamples` samples', async () => {
|
||||
const numSamples = _.random(1, 16);
|
||||
// neon-router requires at least 3 samples
|
||||
const numSamples = _.random(3, 16);
|
||||
let actualNumSamples = 0;
|
||||
replaceSamplerOps({
|
||||
getBuyQuotes: (sources, makerToken, takerToken, amounts, wethAddress) => {
|
||||
@ -1343,6 +1349,8 @@ describe('MarketOperationUtils tests', () => {
|
||||
await getMarketBuyOrdersAsync(marketOperationUtils, ORDERS, FILL_AMOUNT, {
|
||||
...DEFAULT_OPTS,
|
||||
numSamples,
|
||||
// Make sure to use same number of samples in neon-router for compatibility
|
||||
neonRouterNumSamples: numSamples,
|
||||
});
|
||||
expect(actualNumSamples).eq(numSamples);
|
||||
});
|
||||
@ -1494,7 +1502,8 @@ describe('MarketOperationUtils tests', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('can mix convex sources', async () => {
|
||||
// TODO: disabled as this is not supported by neon-router
|
||||
it.skip('can mix convex sources', async () => {
|
||||
const rates: RatesBySource = { ...ZERO_RATES };
|
||||
rates[ERC20BridgeSource.Native] = [0.4, 0.3, 0.2, 0.1];
|
||||
rates[ERC20BridgeSource.Uniswap] = [0.5, 0.05, 0.05, 0.05];
|
||||
@ -1521,7 +1530,8 @@ describe('MarketOperationUtils tests', () => {
|
||||
|
||||
const ETH_TO_TAKER_RATE = 1.5;
|
||||
|
||||
it('factors in fees for native orders', async () => {
|
||||
// TODO: disabled as this is not supported by neon-router
|
||||
it.skip('factors in fees for native orders', async () => {
|
||||
// Native orders will have the best rates but have fees,
|
||||
// dropping their effective rates.
|
||||
const nativeFeeRate = 0.06;
|
||||
@ -1598,7 +1608,9 @@ describe('MarketOperationUtils tests', () => {
|
||||
expect(orderSources.sort()).to.deep.eq(expectedSources.sort());
|
||||
});
|
||||
|
||||
it('does not create a fallback if below maxFallbackSlippage', async () => {
|
||||
// NOTE: Currently fallbacks for native orders are disabled
|
||||
// TODO: remove this if we remove fallbacks completely
|
||||
it.skip('does not create a fallback if below maxFallbackSlippage', async () => {
|
||||
const rates: RatesBySource = { ...ZERO_RATES };
|
||||
rates[ERC20BridgeSource.Native] = [1, 1, 0.01, 0.01];
|
||||
rates[ERC20BridgeSource.Uniswap] = [1, 1, 0.01, 0.01];
|
||||
|
Loading…
x
Reference in New Issue
Block a user