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:
Kim Persson 2022-03-31 14:32:59 +02:00 committed by GitHub
parent c9c30d3a76
commit c881723578
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 9 deletions

View File

@ -110,6 +110,8 @@ jobs:
docker: docker:
- image: node:16 - image: node:16
working_directory: ~/repo working_directory: ~/repo
environment:
RUST_ROUTER: "true"
steps: steps:
- restore_cache: - restore_cache:
keys: keys:

View File

@ -5,6 +5,10 @@
{ {
"note": "Adds support for STG/USDC pool on Curve Mainnet", "note": "Adds support for STG/USDC pool on Curve Mainnet",
"pr": 451 "pr": 451
},
{
"note": "Use neon-router in asset-swapper tests",
"pr": 453
} }
] ]
}, },

View File

@ -227,8 +227,9 @@ function findRoutesAndCreateOptimalPath(
const sourcePathId = hexUtils.random(); const sourcePathId = hexUtils.random();
const singleSourceSamplesWithOutput = [...singleSourceSamples]; const singleSourceSamplesWithOutput = [...singleSourceSamples];
for (let i = singleSourceSamples.length - 1; i >= 0; i--) { for (let i = singleSourceSamples.length - 1; i >= 0; i--) {
if (singleSourceSamples[i].output.isZero()) { const currentOutput = singleSourceSamples[i].output;
// Remove trailing 0 output samples if (currentOutput.isZero() || !currentOutput.isFinite()) {
// Remove trailing 0/invalid output samples
singleSourceSamplesWithOutput.pop(); singleSourceSamplesWithOutput.pop();
} else { } else {
break; break;

View File

@ -483,7 +483,8 @@ describe('MarketOperationUtils tests', () => {
}); });
it('queries `numSamples` samples', async () => { 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; let actualNumSamples = 0;
replaceSamplerOps({ replaceSamplerOps({
getSellQuotes: (sources, makerToken, takerToken, amounts, wethAddress) => { getSellQuotes: (sources, makerToken, takerToken, amounts, wethAddress) => {
@ -501,6 +502,7 @@ describe('MarketOperationUtils tests', () => {
await getMarketSellOrdersAsync(marketOperationUtils, ORDERS, FILL_AMOUNT, { await getMarketSellOrdersAsync(marketOperationUtils, ORDERS, FILL_AMOUNT, {
...DEFAULT_OPTS, ...DEFAULT_OPTS,
numSamples, numSamples,
neonRouterNumSamples: numSamples,
}); });
expect(actualNumSamples).eq(numSamples); expect(actualNumSamples).eq(numSamples);
}); });
@ -1078,7 +1080,8 @@ describe('MarketOperationUtils tests', () => {
const ETH_TO_MAKER_RATE = 1.5; 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, // Native orders will have the best rates but have fees,
// dropping their effective rates. // dropping their effective rates.
const nativeFeeRate = 0.06; const nativeFeeRate = 0.06;
@ -1181,7 +1184,9 @@ describe('MarketOperationUtils tests', () => {
expect(orderSources.sort()).to.deep.eq(expectedSources.sort()); 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 = {}; const rates: RatesBySource = {};
rates[ERC20BridgeSource.Native] = [1, 1, 0.01, 0.01]; rates[ERC20BridgeSource.Native] = [1, 1, 0.01, 0.01];
rates[ERC20BridgeSource.Uniswap] = [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 () => { 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; let actualNumSamples = 0;
replaceSamplerOps({ replaceSamplerOps({
getBuyQuotes: (sources, makerToken, takerToken, amounts, wethAddress) => { getBuyQuotes: (sources, makerToken, takerToken, amounts, wethAddress) => {
@ -1343,6 +1349,8 @@ describe('MarketOperationUtils tests', () => {
await getMarketBuyOrdersAsync(marketOperationUtils, ORDERS, FILL_AMOUNT, { await getMarketBuyOrdersAsync(marketOperationUtils, ORDERS, FILL_AMOUNT, {
...DEFAULT_OPTS, ...DEFAULT_OPTS,
numSamples, numSamples,
// Make sure to use same number of samples in neon-router for compatibility
neonRouterNumSamples: numSamples,
}); });
expect(actualNumSamples).eq(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 }; const rates: RatesBySource = { ...ZERO_RATES };
rates[ERC20BridgeSource.Native] = [0.4, 0.3, 0.2, 0.1]; rates[ERC20BridgeSource.Native] = [0.4, 0.3, 0.2, 0.1];
rates[ERC20BridgeSource.Uniswap] = [0.5, 0.05, 0.05, 0.05]; 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; 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, // Native orders will have the best rates but have fees,
// dropping their effective rates. // dropping their effective rates.
const nativeFeeRate = 0.06; const nativeFeeRate = 0.06;
@ -1598,7 +1608,9 @@ describe('MarketOperationUtils tests', () => {
expect(orderSources.sort()).to.deep.eq(expectedSources.sort()); 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 }; const rates: RatesBySource = { ...ZERO_RATES };
rates[ERC20BridgeSource.Native] = [1, 1, 0.01, 0.01]; rates[ERC20BridgeSource.Native] = [1, 1, 0.01, 0.01];
rates[ERC20BridgeSource.Uniswap] = [1, 1, 0.01, 0.01]; rates[ERC20BridgeSource.Uniswap] = [1, 1, 0.01, 0.01];