Skip to content

Commit

Permalink
fixed eth and uniswap tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fengtality committed Feb 7, 2023
1 parent e7410d8 commit a30274d
Show file tree
Hide file tree
Showing 28 changed files with 160 additions and 158 deletions.
38 changes: 19 additions & 19 deletions docs/swagger/definitions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ definitions:
example: 'ethereum'
network:
type: 'string'
example: 'kovan'
example: 'goerli'

NonceResponse:
type: 'object'
Expand Down Expand Up @@ -70,7 +70,7 @@ definitions:
example: 'ethereum'
network:
type: 'string'
example: 'kovan'
example: 'goerli'

AllowancesResponse:
type: 'object'
Expand Down Expand Up @@ -122,7 +122,7 @@ definitions:
example: 'ethereum'
network:
type: 'string'
example: 'kovan'
example: 'goerli'

BalancesResponse:
type: 'object'
Expand Down Expand Up @@ -185,7 +185,7 @@ definitions:
example: 'ethereum'
network:
type: 'string'
example: 'kovan'
example: 'goerli'

ApproveResponse:
type: 'object'
Expand Down Expand Up @@ -239,7 +239,7 @@ definitions:
example: 'ethereum'
network:
type: 'string'
example: 'kovan'
example: 'goerli'

PollResponse:
type: 'object'
Expand Down Expand Up @@ -324,7 +324,7 @@ definitions:
example: 'ethereum'
network:
type: 'string'
example: 'kovan'
example: 'goerli'

PriceResponse:
type: 'object'
Expand Down Expand Up @@ -414,7 +414,7 @@ definitions:
example: 'ethereum'
network:
type: 'string'
example: 'kovan'
example: 'goerli'
connector:
type: 'string'
example: 'uniswap'
Expand Down Expand Up @@ -492,7 +492,7 @@ definitions:
example: 'ethereum'
network:
type: 'string'
example: 'kovan'
example: 'goerli'

CancelResponse:
type: 'object'
Expand Down Expand Up @@ -687,7 +687,7 @@ definitions:
example: 'ethereum'
network:
type: 'string'
example: 'kovan'
example: 'goerli'
connector:
type: 'string'
example: 'uniswap'
Expand Down Expand Up @@ -763,7 +763,7 @@ definitions:
example: 'ethereum'
network:
type: 'string'
example: 'kovan'
example: 'goerli'
connector:
type: 'string'
example: 'uniswapLP'
Expand All @@ -783,7 +783,7 @@ definitions:
properties:
network:
type: 'string'
example: 'kovan'
example: 'goerli'
timestamp:
type: 'integer'
example: 1636368085740
Expand Down Expand Up @@ -829,7 +829,7 @@ definitions:
example: 'ethereum'
network:
type: 'string'
example: 'kovan'
example: 'goerli'
connector:
type: 'string'
example: 'uniswapLP'
Expand All @@ -848,7 +848,7 @@ definitions:
properties:
network:
type: 'string'
example: 'kovan'
example: 'goerli'
timestamp:
type: 'integer'
example: 1636368085740
Expand Down Expand Up @@ -891,7 +891,7 @@ definitions:
example: 'ethereum'
network:
type: 'string'
example: 'kovan'
example: 'goerli'
connector:
type: 'string'
example: 'uniswapLP'
Expand All @@ -910,7 +910,7 @@ definitions:
properties:
network:
type: 'string'
example: 'kovan'
example: 'goerli'
timestamp:
type: 'integer'
example: 1636368085740
Expand Down Expand Up @@ -945,7 +945,7 @@ definitions:
example: 'ethereum'
network:
type: 'string'
example: 'kovan'
example: 'goerli'
connector:
type: 'string'
example: 'uniswapLP'
Expand All @@ -968,7 +968,7 @@ definitions:
properties:
network:
type: 'string'
example: 'kovan'
example: 'goerli'
timestamp:
type: 'integer'
example: 1636368085740
Expand Down Expand Up @@ -1032,7 +1032,7 @@ definitions:
example: 'ethereum'
network:
type: 'string'
example: 'kovan'
example: 'goerli'
connector:
type: 'string'
example: 'uniswapLP'
Expand All @@ -1050,7 +1050,7 @@ definitions:
properties:
network:
type: 'string'
example: 'kovan'
example: 'goerli'
timestamp:
type: 'integer'
example: 1636368085740
Expand Down
2 changes: 1 addition & 1 deletion docs/swagger/network-routes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ paths:
name: 'network'
required: true
type: 'string'
example: 'kovan'
example: 'goerli'
- in: 'query'
name: 'tokenSymbols'
required: false
Expand Down
4 changes: 2 additions & 2 deletions manual-tests/curl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: app

curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT https://localhost:15888/network/status | jq

curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "https://localhost:15888/network/status?chain=ethereum&network=kovan" | jq
curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "https://localhost:15888/network/status?chain=ethereum&network=goerli" | jq

curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "https://localhost:15888/network/status?chain=avalanche&network=avalanche" | jq

Expand All @@ -33,7 +33,7 @@ curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT https://localhost:1588

curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "Content-Type: application/json" -d "$(envsubst < ./requests/network_poll.json)" https://localhost:15888/network/poll | jq

curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "https://localhost:15888/network/tokens?chain=ethereum&network=kovan" | jq
curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "https://localhost:15888/network/tokens?chain=ethereum&network=goerli" | jq

curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "https://localhost:15888/network/tokens?chain=polygon&network=mumbai" | jq

Expand Down
2 changes: 1 addition & 1 deletion manual-tests/requests/add_ethereum_key.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"privateKey": "$ETH_PRIVATE_KEY",
"chain": "ethereum",
"network": "kovan"
"network": "goerli"
}
2 changes: 1 addition & 1 deletion manual-tests/requests/eth_allowances.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"chain": "ethereum",
"network": "kovan",
"network": "goerli",
"address": "$ETH_ADDRESS",
"spender": "uniswap",
"tokenSymbols": ["DAI", "WETH"]
Expand Down
2 changes: 1 addition & 1 deletion manual-tests/requests/eth_approve.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"chain": "ethereum",
"network": "kovan",
"network": "goerli",
"address": "$ETH_ADDRESS",
"spender": "uniswap",
"token": "DAI"
Expand Down
2 changes: 1 addition & 1 deletion manual-tests/requests/eth_nonce.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"chain": "ethereum",
"network": "kovan",
"network": "goerli",
"address": "$ETH_ADDRESS"
}
2 changes: 1 addition & 1 deletion manual-tests/requests/eth_uniswap_add_liquidity.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"lowerPrice": "1",
"upperPrice": "5",
"chain": "ethereum",
"network": "kovan",
"network": "goerli",
"connector": "uniswapLP"
}
2 changes: 1 addition & 1 deletion manual-tests/requests/eth_uniswap_pool_price.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"period": 120,
"interval": 60,
"chain": "ethereum",
"network": "kovan",
"network": "goerli",
"connector": "uniswapLP"
}
2 changes: 1 addition & 1 deletion manual-tests/requests/eth_uniswap_position.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"address": "$ETH_ADDRESS",
"tokenId": 2732,
"chain": "ethereum",
"network": "kovan",
"network": "goerli",
"connector": "uniswapLP"
}
2 changes: 1 addition & 1 deletion manual-tests/requests/eth_uniswap_trade.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"amount": "1",
"side": "BUY",
"chain": "ethereum",
"network": "kovan",
"network": "goerli",
"connector": "uniswap"
}
2 changes: 1 addition & 1 deletion manual-tests/requests/network_poll.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"chain": "ethereum",
"network": "kovan",
"network": "goerli",
"txHash": "0xadaef9c4540192e45c991ffe6f12cc86be9c07b80b43487e5778d95c964405c7"
}
2 changes: 1 addition & 1 deletion manual-tests/requests/price_uniswap.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"connector": "uniswap",
"chain": "ethereum",
"network": "kovan",
"network": "goerli",
"quote": "WETH",
"base": "DAI",
"amount": "1",
Expand Down
2 changes: 1 addition & 1 deletion manual-tests/requests/status_request.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"chain": "ethereum",
"network": "kovan"
"network": "goerli"
}
4 changes: 3 additions & 1 deletion src/connectors/uniswap/uniswap.lp.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,9 @@ export class UniswapLPHelper {
const token1 = this.getTokenByAddress(positionData.token1);
const fee = positionData.fee;
if (!token0 || !token1) {
throw new Error(`One of the tokens in this position isn't recognized.`);
throw new Error(
`One of the tokens in this position isn't recognized. $token0: ${token0}, $token1: ${token1}`
);
}
const poolAddress = uniV3.Pool.getAddress(token0, token1, fee);
const poolData = await this.getPoolState(poolAddress, fee);
Expand Down
12 changes: 6 additions & 6 deletions src/services/config-manager-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ export class ConfigurationNamespace {
*
* Note that configuration paths may have multiple levels. What it implies
* is those configurations are stored in nested dictionaries - aka. a tree.
* e.g. if the config path is "ethereum.networks.kovan.networkID", then,
* what it means you're accessing ["networks"]["kovan"]["networkID"] under
* e.g. if the config path is "ethereum.networks.goerli.networkID", then,
* what it means you're accessing ["networks"]["goerli"]["networkID"] under
* the "ethereum" namespace.
*/
readonly #namespaceId: string;
Expand Down Expand Up @@ -243,10 +243,10 @@ export class ConfigManagerV2 {
* initiation, the get() and set() functions will map configuration keys and
* values to the appropriate namespaces.
*
* e.g. get('ethereum.networks.kovan.networkID') will be mapped to
* ethereumNamespace.get('networks.kovan.networkID')
* e.g. set('ethereum.networks.kovan.networkID', 42) will be mapped to
* ethereumNamespace.set('networks.kovan.networkID', 42)
* e.g. get('ethereum.networks.goerli.networkID') will be mapped to
* ethereumNamespace.get('networks.goerli.networkID')
* e.g. set('ethereum.networks.goerli.networkID', 42) will be mapped to
* ethereumNamespace.set('networks.goerli.networkID', 42)
*
* File paths in the root configuration file may be defined as absolute paths
* or relative paths. Any relative paths would be rebased to the root
Expand Down
18 changes: 9 additions & 9 deletions test/chains/ethereum/ethereum.controllers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { patchEVMNonceManager } from '../../evm.nonce.mock';
let eth: Ethereum;

beforeAll(async () => {
eth = Ethereum.getInstance('kovan');
eth = Ethereum.getInstance('goerli');

patchEVMNonceManager(eth.nonceManager);

Expand Down Expand Up @@ -55,7 +55,7 @@ describe('nonce', () => {
patch(eth.nonceManager, 'getNonce', () => 2);
const n = await nonce(eth, {
chain: 'ethereum',
network: 'kovan',
network: 'goerli',
address: zeroAddress,
});
expect(n).toEqual({ nonce: 2 });
Expand All @@ -70,7 +70,7 @@ describe('nonce', () => {
patch(eth.nonceManager, 'getNextNonce', () => 3);
const n = await nextNonce(eth, {
chain: 'ethereum',
network: 'kovan',
network: 'goerli',
address: zeroAddress,
});
expect(n).toEqual({ nonce: 3 });
Expand Down Expand Up @@ -120,7 +120,7 @@ describe('allowances', () => {

const result = await allowances(eth, {
chain: 'ethereum',
network: 'kovan',
network: 'goerli',
address: zeroAddress,
spender: uniswap,
tokenSymbols: ['WETH'],
Expand Down Expand Up @@ -161,7 +161,7 @@ describe('approve', () => {

const result = await approve(eth, {
chain: 'ethereum',
network: 'kovan',
network: 'goerli',
address: zeroAddress,
spender: uniswap,
token: 'WETH',
Expand All @@ -182,7 +182,7 @@ describe('approve', () => {
await expect(
approve(eth, {
chain: 'ethereum',
network: 'kovan',
network: 'goerli',
address: zeroAddress,
spender: uniswap,
token: 'WETH',
Expand Down Expand Up @@ -214,7 +214,7 @@ describe('approve', () => {
await expect(
approve(eth, {
chain: 'ethereum',
network: 'kovan',
network: 'goerli',
address: zeroAddress,
spender: uniswap,
token: 'WETH',
Expand All @@ -239,7 +239,7 @@ describe('balances', () => {
await expect(
balances(eth, {
chain: 'ethereum',
network: 'kovan',
network: 'goerli',
address: zeroAddress,
tokenSymbols: ['WETH', 'DAI'],
})
Expand All @@ -263,7 +263,7 @@ describe('cancel', () => {
await expect(
cancel(eth, {
chain: 'ethereum',
network: 'kovan',
network: 'goerli',
nonce: 123,
address: zeroAddress,
})
Expand Down
Loading

0 comments on commit a30274d

Please sign in to comment.