Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tech Debt cleanup & refactoring of network service with unit test coverage! #601

Merged
merged 29 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1138709
change: DevTools page Cleanup with updating unit test.
sk-enya Jul 29, 2024
9254585
cleanup bobascope pages
sk-enya Jul 29, 2024
c16c40a
change:
sk-enya Jul 29, 2024
0f08190
change: fix spec snapshot and spy on console log to cleanup test output.
sk-enya Jul 29, 2024
731eabc
remove labeler ci action as not needed
sk-enya Jul 29, 2024
a180430
removed export unused export
sk-enya Jul 29, 2024
3331928
change: move teleporation service to folder!
sk-enya Jul 29, 2024
aaf2910
change: seperated dao as separate service and cleanup unused function…
sk-enya Jul 29, 2024
3f4da56
change: earn functions to separate services to reduce network service…
sk-enya Jul 29, 2024
e5bd1c8
change:
sk-enya Jul 29, 2024
c5d808c
change: separated out the oracle specific functions
sk-enya Jul 29, 2024
b87048c
fixed fetching earn user and pool info
sk-enya Jul 29, 2024
c732704
fixed saving as separate service with cleaning up function from netwo…
sk-enya Jul 29, 2024
4096a11
updated specs or unit test coverage
sk-enya Jul 31, 2024
e4559b5
Merge pull request #602 from bobanetwork/chore/split-network-service
sk-enya Jul 31, 2024
77eb297
change: unit test cases for oracle service, name change
sk-enya Jul 31, 2024
0d92fd7
change: teleporation service unit test coverage
sk-enya Jul 31, 2024
2bbbca3
change: unit test with 90% coverage and fixing the await for disburser.
sk-enya Jul 31, 2024
4e5d708
change the exported member of app service.
sk-enya Jul 31, 2024
b980d7f
change: unit specs for fixed saving contracts
sk-enya Jul 31, 2024
4a25bca
change: test bridging service test update with 100% coverage
sk-enya Jul 31, 2024
ad88142
change: updated spec for bridging service
sk-enya Jul 31, 2024
25ae34e
change: dao service unit test cases
sk-enya Aug 1, 2024
5cd9f2d
change: handling exception case in test
sk-enya Aug 1, 2024
eaba35e
change: earn service unit test cases!
sk-enya Aug 1, 2024
e4cc3a0
change: coverage badges to show the details about coverage.
sk-enya Aug 1, 2024
4690bf6
removed server test package and add log mock
sk-enya Aug 5, 2024
545a34d
Merge pull request #603 from bobanetwork/test/services-tests
sk-enya Aug 5, 2024
a727683
change: fixed network names for gateway
sk-enya Aug 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .github/labeler.yml

This file was deleted.

12 changes: 0 additions & 12 deletions .github/workflows/labeler.yml

This file was deleted.

1 change: 1 addition & 0 deletions badges/badge-branches.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions badges/badge-functions.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions badges/badge-lines.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions badges/badge-statements.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 12 additions & 1 deletion e2e-tests/lib/gatewayAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ const networkNames = {
},
}

const withDrawalNetworkNames = {
eth: {
toNetwork: 'Ethereum (Sepolia)',
fromNetwork: 'Boba (Sepolia)',
},
bnb: {
toNetwork: 'BNB Testnet',
fromNetwork: 'Boba BNB Testnet',
},
}

export class GatewayAction {
basePage: BasePage
bridgePage: BridgePage
Expand Down Expand Up @@ -96,7 +107,7 @@ export class GatewayAction {
await this.bridgePage.validateAndConfirmBridging({
amount: amountToBridge,
token: tokenSymbol,
...networkNames[networkKey],
...withDrawalNetworkNames[networkKey],
estimatedTime: '7 days',
})
await this.bridgePage.reviewAndInitiateWithdrawal()
Expand Down
6 changes: 4 additions & 2 deletions e2e-tests/pages/bridgePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class BridgePage extends BasePage {
estimatedTime: string
}) {
await expect(this.page.getByTestId('amountToRecieve')).toHaveText(
`${Number(amount).toFixed(4)} ${token}`
`${parseFloat(Number(amount).toFixed(4))} ${token}`
)

const estTime = await this.page
Expand All @@ -55,7 +55,9 @@ export class BridgePage extends BasePage {
.textContent()

// TODO: update value with fee calculation.
expect(estRecievable).toBe(`${Number(amount).toFixed(4)} ${token}`)
expect(estRecievable).toBe(
`${parseFloat(Number(amount).toFixed(4))} ${token}`
)
}

async clickToBridge() {
Expand Down
15 changes: 10 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
"lint:fix": "yarn lint:check --fix",
"postinstall": "patch-package",
"pre-commit": "lint-staged",
"listDead": "ts-prune",
"prebuild": "./bin/release.sh",
"prepare": "husky install",
"start": "GENERATE_SOURCEMAP=false react-app-rewired start",
"test": "TZ=utc react-scripts test --watchAll=false",
"test:coverage": "yarn test --coverage",
"test:coverage": "yarn test --coverage && jest-coverage-badges output \"./badges\" ",
"test:u": "yarn test -u",
"test:w": "yarn test --watchAll=true"
},
Expand Down Expand Up @@ -57,7 +58,6 @@
"http-browserify": "^1.7.0",
"https-browserify": "^1.0.0",
"human-standard-token-abi": "^2.0.0",
"lodash.flatten": "^4.4.0",
"lodash.intersection": "^4.4.0",
"lodash.isequal": "^4.5.0",
"lodash.keyby": "^4.6.0",
Expand Down Expand Up @@ -95,7 +95,6 @@
"@testing-library/react": "^12.1.2",
"@testing-library/react-hooks": "^8.0.1",
"@types/jest": "^29.5.1",
"@types/lodash.flatten": "^4.4.9",
"@types/lodash.intersection": "^4.4.9",
"@types/lodash.isequal": "^4.5.6",
"@types/lodash.keyby": "^4.6.9",
Expand All @@ -114,12 +113,13 @@
"eslint-plugin-testing-library": "^6.2.0",
"eslint-plugin-unicorn": "^50.0.1",
"husky": "^8.0.3",
"jest-coverage-badges": "^1.1.2",
"jest-styled-components": "^7.1.1",
"lint-staged": "^14.0.1",
"prettier": "^3.0.3",
"react-app-rewired": "^2.2.1",
"redux-mock-store": "^1.5.4",
"start-server-and-test": "2.0.3",
"ts-prune": "^0.10.3",
"typescript": "^5.1.6"
},
"jest": {
Expand All @@ -132,14 +132,19 @@
"src/layout/**/*.tsx",
"src/util/**/*.ts",
"src/services/**/*.ts",
"src/containers/Home/index.tsx",
"!src/actions/**/*.ts",
"!src/api/**/*.ts",
"!src/selectors/**/*.ts",
"!src/reducers/**/*.ts",
"!src/store/**/*.tsx",
"!src/containers/Home/index.tsx",
"!src/**/types.{ts,tsx}",
"!src/**/style.{ts,tsx}"
],
"coverageReporters": [
"json-summary",
"text",
"lcov"
]
},
"resolutions": {
Expand Down
7 changes: 7 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@

<br />

# Coverage report

<img src="coverage/badge-lines.svg" alt="Line Coverage">
<img src="coverage/badge-branches.svg" alt="Branch Coverage">
<img src="coverage/badge-functions.svg" alt="Function Coverage">
<img src="coverage/badge-statements.svg" alt="Function Coverage">

# Contributing

Follow these instructions to set up your local development environment.
Expand Down
31 changes: 14 additions & 17 deletions src/actions/daoAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,51 +17,48 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import networkService from 'services/networkService'
import { createAction } from './createAction'

import daoService from 'services/dao/dao.service'

export const fetchDaoBalance = () =>
createAction('BALANCE/DAO/GET', () => networkService.getDaoBalance())
createAction('BALANCE/DAO/GET', () => daoService.loadBobaBalance())

export const fetchDaoVotes = () =>
createAction('VOTES/DAO/GET', () => networkService.getDaoVotes())
createAction('VOTES/DAO/GET', () => daoService.loadBobaVotes())

export const fetchDaoBalanceX = () =>
createAction('BALANCEX/DAO/GET', () => networkService.getDaoBalanceX())
createAction('BALANCEX/DAO/GET', () => daoService.loadXBobaBalance())

export const fetchDaoVotesX = () =>
createAction('VOTESX/DAO/GET', () => networkService.getDaoVotesX())
createAction('VOTESX/DAO/GET', () => daoService.loadXBobaVotes())

export const delegateVotes = ({ recipient }) =>
createAction('DELEGATE/VOTES/CREATE', () =>
networkService.delegateVotes({ recipient })
daoService.delegateBobaVotes({ recipient })
)

export const delegateVotesX = ({ recipient }) =>
createAction('DELEGATEX/VOTES/CREATE', () =>
networkService.delegateVotesX({ recipient })
daoService.delegateXBobaVotes({ recipient })
)

export const getProposalThreshold = () =>
createAction('PROPOSALTHRESHOLD/GET', () =>
networkService.getProposalThreshold()
daoService.loadProposalThreshold()
)

export const fetchDaoProposals = () =>
createAction('PROPOSALS/GET', () => networkService.fetchProposals())
createAction('PROPOSALS/GET', () => daoService.loadProposals())

export const createDaoProposal = (payload) =>
createAction('PROPOSAL/CREATE', () => networkService.createProposal(payload))
createAction('PROPOSAL/CREATE', () => daoService.createProposal(payload))

export const queueProposal = (proposalID) =>
createAction('PROPOSAL/QUEUE', () => networkService.queueProposal(proposalID))
createAction('PROPOSAL/QUEUE', () => daoService.queueProposal(proposalID))

export const executeProposal = (proposalID) =>
createAction('PROPOSAL/EXECUTE', () =>
networkService.executeProposal(proposalID)
)
createAction('PROPOSAL/EXECUTE', () => daoService.executeProposal(proposalID))

export const castProposalVote = (payload) =>
createAction('PROPOSAL/CAST/VOTE', () =>
networkService.castProposalVote(payload)
)
createAction('PROPOSAL/CAST/VOTE', () => daoService.castVote(payload))
35 changes: 0 additions & 35 deletions src/actions/devToolsAction.ts

This file was deleted.

56 changes: 30 additions & 26 deletions src/actions/earnAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,25 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import networkService from 'services/networkService'
import { createAction } from './createAction'
import { BigNumberish } from 'ethers'
import earnService from 'services/earn/earn.service'
import { LiquidityPoolLayer } from 'types/earn.types'
import { createAction } from './createAction'

const getEarnInfoBegin = () => ({
type: 'GET_EARNINFO',
})

export const updateWithdrawToken = (withdrawToken: any) => ({
type: 'UPDATE_WITHDRAW_TOKEN',
payload: withdrawToken,
})

export const updateWithdrawPayload = (withdrawToken: any) => ({
type: 'UPDATE_WITHDRAW_PAYLOAD',
payload: withdrawToken,
})

const getEarnInfoSuccess = (
L1PoolInfo,
L1UserInfo,
Expand All @@ -39,53 +49,47 @@ const getEarnInfoSuccess = (
export const getEarnInfo = () => async (dispatch) => {
dispatch(getEarnInfoBegin())
const [L1LPInfo, L2LPInfo] = await Promise.all([
networkService.getL1LPInfo(),
networkService.getL2LPInfo(),
earnService.loadL1LpInfo(),
earnService.loadL2LpInfo(),
])
dispatch(
getEarnInfoSuccess(
L1LPInfo.poolInfo,
L1LPInfo.userInfo,
L2LPInfo.poolInfo,
L2LPInfo.userInfo
(L1LPInfo as any).poolInfo,
(L1LPInfo as any).userInfo,
sk-enya marked this conversation as resolved.
Show resolved Hide resolved
(L2LPInfo as any).poolInfo,
(L2LPInfo as any).userInfo
)
)
}

export const updateWithdrawToken = (withdrawToken: any) => ({
type: 'UPDATE_WITHDRAW_TOKEN',
payload: withdrawToken,
})

export const updateWithdrawPayload = (withdrawToken: any) => ({
type: 'UPDATE_WITHDRAW_PAYLOAD',
payload: withdrawToken,
})

export const fetchL1LPBalance = (currency: string) =>
createAction('FETCH/L1LPBALANCE', () => networkService.L1LPBalance(currency))
createAction('FETCH/L1LPBALANCE', () => earnService.loadL1LpBalance(currency))

export const fetchL2LPBalance = (currency: string) =>
createAction('FETCH/L2LPBALANCE', () => networkService.L2LPBalance(currency))
createAction('FETCH/L2LPBALANCE', () => earnService.loadL2LpBalance(currency))

export const getReward = (
currencyAddress: string,
value_Wei_String: BigNumberish,
L1orL2Pool: LiquidityPoolLayer
) =>
createAction('EARN/HARVEST', () =>
networkService.getReward(currencyAddress, value_Wei_String, L1orL2Pool)
earnService.loadReward({
currencyAddress,
value_Wei_String,
L1orL2Pool,
})
)

export const withdrawLiquidity = (
currencyAddress: string,
currency: string,
value_Wei_String: string,
L1orL2Pool: LiquidityPoolLayer
) =>
createAction('EARN/WITHDRAW', () =>
networkService.withdrawLiquidity(
currencyAddress,
earnService.withdrawLiquidity({
currency,
L1orL2Pool,
value_Wei_String,
L1orL2Pool
)
})
)
10 changes: 5 additions & 5 deletions src/actions/fixedAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import networkService from 'services/networkService'
import fixedSavingService from 'services/fixedsaving/fixedSaving.service'
import { createAction } from './createAction'

export const addFS_Savings = (weiString: string) =>
createAction('ADD/FS_SAVINGS', () => networkService.addFS_Savings(weiString))
createAction('ADD/FS_SAVINGS', () => fixedSavingService.addSavings(weiString))

export const withdrawFS_Savings = (stakeID: number) =>
createAction('WITHDRAW/FS_SAVINGS', () =>
networkService.withdrawFS_Savings(stakeID)
fixedSavingService.withdrawSavings(stakeID)
)

export const getFS_Saves = () =>
createAction('GET/FS_SAVES', () => networkService.getFS_Saves())
createAction('GET/FS_SAVES', () => fixedSavingService.loadSavings())

export const getFS_Info = () =>
createAction('GET/FS_INFO', () => networkService.getFS_Info())
createAction('GET/FS_INFO', () => fixedSavingService.loadAccountSaveInfo())
Loading
Loading