-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Start separating functions for unit testing (#350)
* toWeiSafe works Signed-off-by: Tulun <[email protected]> * Addresses can be checked independently; odd import is screwing up other test. Signed-off-by: Tulun <[email protected]> * save wip Signed-off-by: Tulun <[email protected]> * address.test.ts Signed-off-by: Tulun <[email protected]> * update imports Signed-off-by: Tulun <[email protected]> * Fixed import issue Signed-off-by: Tulun <[email protected]> * test env Signed-off-by: Tulun <[email protected]> * removed unnec jest config stuff Signed-off-by: Tulun <[email protected]> * add to GH actions Signed-off-by: Tulun <[email protected]> * syntax Signed-off-by: Tulun <[email protected]> Signed-off-by: Tulun <[email protected]>
- Loading branch information
Showing
16 changed files
with
126 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
REACT_APP_V_ETH=0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 | ||
REACT_APP_UMA_ADDRESS=0x04Fa0d235C4abf4BcF4787aF4CF447DE572eF828 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { ethers } from "ethers"; | ||
import { ChainId } from "./utils.d"; | ||
import { hubPoolChainId } from "./constants"; | ||
const infuraId = process.env.REACT_APP_PUBLIC_INFURA_ID || ""; | ||
const ArbitrumProviderUrl = | ||
process.env.REACT_APP_CHAIN_42161_PROVIDER_URL || | ||
`https://arbitrum-mainnet.infura.io/v3/${infuraId}`; | ||
|
||
const PolygonProviderUrl = | ||
process.env.REACT_APP_CHAIN_137_PROVIDER_URL || | ||
`https://polygon-mainnet.infura.io/v3/${infuraId}`; | ||
|
||
export const providerUrls: [ChainId, string][] = [ | ||
[ChainId.MAINNET, `https://mainnet.infura.io/v3/${infuraId}`], | ||
[ChainId.ARBITRUM, ArbitrumProviderUrl], | ||
[ChainId.POLYGON, PolygonProviderUrl], | ||
[ChainId.OPTIMISM, `https://optimism-mainnet.infura.io/v3/${infuraId}`], | ||
[ChainId.BOBA, `https://mainnet.boba.network`], | ||
[ChainId.RINKEBY, `https://rinkeby.infura.io/v3/${infuraId}`], | ||
[ChainId.KOVAN, `https://kovan.infura.io/v3/${infuraId}`], | ||
[ChainId.KOVAN_OPTIMISM, `https://optimism-kovan.infura.io/v3/${infuraId}`], | ||
[ | ||
ChainId.ARBITRUM_RINKEBY, | ||
`https://arbitrum-rinkeby.infura.io/v3/${infuraId}`, | ||
], | ||
[ChainId.GOERLI, `https://goerli.infura.io/v3/${infuraId}`], | ||
[ChainId.MUMBAI, `https://polygon-mumbai.infura.io/v3/${infuraId}`], | ||
]; | ||
|
||
export const providerUrlsTable: Record<number, string> = | ||
Object.fromEntries(providerUrls); | ||
|
||
export const providers: [number, ethers.providers.StaticJsonRpcProvider][] = | ||
providerUrls.map(([chainId, url]) => { | ||
return [chainId, new ethers.providers.StaticJsonRpcProvider(url)]; | ||
}); | ||
export const providersTable: Record< | ||
number, | ||
ethers.providers.StaticJsonRpcProvider | ||
> = Object.fromEntries(providers); | ||
|
||
export function getProvider( | ||
chainId: ChainId = hubPoolChainId | ||
): ethers.providers.StaticJsonRpcProvider { | ||
// Requires for Cypress testing. Only use the injected test provider if isCypress flag has been added to the window object.. | ||
if ((window as any).isCypress) { | ||
const provider: ethers.providers.JsonRpcProvider = (window as any).ethereum | ||
.provider; | ||
|
||
return provider; | ||
} | ||
return providersTable[chainId]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { getCode } from "../address"; | ||
|
||
const V_ETH = process.env.REACT_APP_V_ETH || ""; | ||
const UMA_ADDRESS = process.env.REACT_APP_UMA_ADDRESS || ""; | ||
|
||
describe("#getCode", () => { | ||
it("return 0x when address is not a Contract", () => { | ||
return expect(getCode(V_ETH, 1)).resolves.toBe("0x"); | ||
}); | ||
|
||
it("returns a value different than 0x when address is a Contract", () => { | ||
return expect(getCode(UMA_ADDRESS, 1)).resolves.not.toBe("0x"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { toWeiSafe } from "../weiMath"; | ||
|
||
describe("toWeiSafe", () => { | ||
it("Converts the value without an error", () => { | ||
const toBigNum = toWeiSafe("1").toString(); | ||
expect(toBigNum).toEqual("1000000000000000000"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* Chains and Tokens section */ | ||
export enum ChainId { | ||
MAINNET = 1, | ||
OPTIMISM = 10, | ||
ARBITRUM = 42161, | ||
BOBA = 288, | ||
POLYGON = 137, | ||
// testnets | ||
RINKEBY = 4, | ||
KOVAN = 42, | ||
KOVAN_OPTIMISM = 69, | ||
ARBITRUM_RINKEBY = 421611, | ||
GOERLI = 5, | ||
// Polygon testnet | ||
MUMBAI = 80001, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7da0ffb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
goerli-frontend-v2 – ./
goerli-frontend-v2.vercel.app
goerli-frontend-v2-uma.vercel.app
goerli-frontend-v2-git-master-uma.vercel.app
7da0ffb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
frontend-v2 – ./
frontend-v2-uma.vercel.app
across.to
frontend-v2-git-master-uma.vercel.app
frontend-v2-seven.vercel.app
v2.across.to