Skip to content

Commit

Permalink
Merge pull request #610 from bobanetwork/fix/crashes-and-anchorage-wi…
Browse files Browse the repository at this point in the history
…thdrawal

Fix/crashes and anchorage withdrawal
  • Loading branch information
sk-enya authored Aug 30, 2024
2 parents 372d4e3 + a7a920e commit fc75fec
Show file tree
Hide file tree
Showing 59 changed files with 3,459 additions and 790 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ REACT_APP_GA4_MEASUREMENT_ID=
REACT_APP_SENTRY_DSN=
REACT_APP_WC_PROJECT_ID=
REACT_APP_GATEWAY_DATA_BRANCH=
REACT_APP_THE_GRAPH_API_KEY=
#####################
##### WebWallet #####
#####################
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/end2end-test.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Integration Test

on:
# push:
# branches: ['main', 'master']
# pull_request:
workflow_dispatch
push:
branches: ['main', 'master']
pull_request:
workflow_dispatch:

jobs:
e2e-test:
Expand Down
142 changes: 26 additions & 116 deletions e2e-tests/lib/gatewayAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,6 @@ import { Page } from '@playwright/test'
import { BasePage } from '../pages/basePage'
import { BridgePage } from '../pages/bridgePage'

const networkConfig = {
L1: {
token: 'ETH',
chainId: '11155111',
name: 'Sepolia',
},
L2: {
token: 'ETH',
chainId: '28882',
name: 'Boba Sepolia',
},
}

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

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 All @@ -46,53 +11,14 @@ export class GatewayAction {
this.bridgePage = new BridgePage(page)
}

async classicBridgeDeposit({
amountToBridge,
tokenSymbol,
successWaitTime = 1000,
approveAllowance = false,
networkKey = 'eth',
}: {
amountToBridge: string
tokenSymbol: string
successWaitTime?: number
approveAllowance?: boolean
networkKey?: 'bnb' | 'eth'
}) {
await this.bridgePage.openTokenPickerAndSelect(tokenSymbol)
await this.bridgePage.bridgeButtonToBeDisable()
await this.bridgePage.fillBridgingAmount(amountToBridge)
await this.bridgePage.bridgeButtonToBeEnable()
await this.bridgePage.validateBridgingFee({
amount: amountToBridge,
token: tokenSymbol,
estimatedTime: '13 ~ 14mins.',
})
await this.bridgePage.clickToBridge()
await this.bridgePage.validateAndConfirmBridging({
amount: amountToBridge,
token: tokenSymbol,
...networkNames[networkKey],
estimatedTime: '13 ~ 14mins.',
})
if (approveAllowance) {
await this.bridgePage.approveAndConfirmMetaMaskSuccess(amountToBridge)
} else {
await this.bridgePage.confirmMetaMaskModalToBridge(amountToBridge)
}
await this.bridgePage.wait(successWaitTime) // have to wait for success modal
await this.bridgePage.validateBridgeSuccess()
await this.bridgePage.toHistoryPage()
}

async classicBridgeWithdrawal({
async classicBridge({
amountToBridge,
tokenSymbol,
networkKey = 'eth',
estimatedTime = '',
}: {
amountToBridge: string
tokenSymbol: string
networkKey?: 'bnb' | 'eth'
estimatedTime?: string
}) {
await this.bridgePage.openTokenPickerAndSelect(tokenSymbol)
await this.bridgePage.bridgeButtonToBeDisable()
Expand All @@ -101,68 +27,51 @@ export class GatewayAction {
await this.bridgePage.validateBridgingFee({
amount: amountToBridge,
token: tokenSymbol,
estimatedTime: '7 days',
estimatedTime,
})
await this.bridgePage.clickToBridge()
await this.bridgePage.validateAndConfirmBridging({
amount: amountToBridge,
token: tokenSymbol,
...withDrawalNetworkNames[networkKey],
estimatedTime: '7 days',
estimatedTime,
})
await this.bridgePage.reviewAndInitiateWithdrawal()
// TODO :
// await this.bridgePage.switchNetworkProovWithdrawal()
// NOTE: Discuss and implement the proove validation.
}

async lightBridgeDeposit({
async doDepositClassicBridge({
amountToBridge,
tokenSymbol,
successWaitTime = 1000,
approveAllowance = false,
}: {
amountToBridge: string
tokenSymbol: string
successWaitTime?: number
approveAllowance?: boolean
}) {
await this.bridgePage.switchToLightBridge()
await this.bridgePage.openTokenPickerAndSelect(tokenSymbol)
await this.bridgePage.bridgeButtonToBeDisable()
await this.bridgePage.fillBridgingAmount(amountToBridge)
await this.bridgePage.bridgeButtonToBeEnable()
await this.bridgePage.validateBridgingFee({
amount: amountToBridge,
token: tokenSymbol,
estimatedTime: '~1min.',
})
await this.bridgePage.clickToBridge()
await this.bridgePage.validateAndConfirmBridging({
amount: amountToBridge,
token: tokenSymbol,
fromNetwork: 'Ethereum (Sepolia)',
toNetwork: 'Boba (Sepolia)',
estimatedTime: '~1min.',
})
if (approveAllowance) {
await this.bridgePage.approveAndConfirmMetaMaskSuccess(amountToBridge)
} else {
await this.bridgePage.confirmMetaMaskModalToBridge(amountToBridge)
}
await this.bridgePage.wait(successWaitTime) // have to wait for success modal
await this.bridgePage.wait(1000)
await this.bridgePage.validateBridgeSuccess()
await this.bridgePage.toHistoryPage()
}

async lightBridgeWithdraw({
async doWithdrawClassicBridge() {
await this.bridgePage.reviewAndWithdraw()
}

async doWithdrawClassicBridgeBnb(amount) {
await this.bridgePage.reviewAproveAndWithdraw(amount)
}

async lightBridge({
amountToBridge,
tokenSymbol,
successWaitTime = 1000,
approveAllowance = false,
receivableAmt,
}: {
amountToBridge: string
tokenSymbol: string
receivableAmt?: string
successWaitTime?: number
approveAllowance?: boolean
}) {
Expand All @@ -171,27 +80,22 @@ export class GatewayAction {
await this.bridgePage.bridgeButtonToBeDisable()
await this.bridgePage.fillBridgingAmount(amountToBridge)
await this.bridgePage.bridgeButtonToBeEnable()
const receivableAmt = Number(amountToBridge) * ((100 - 1) / 100)
await this.bridgePage.validateBridgingFee({
amount: receivableAmt.toFixed(4),
amount: receivableAmt ? Number(receivableAmt).toFixed(4) : amountToBridge,
token: tokenSymbol,
estimatedTime: '~1min.',
})
await this.bridgePage.clickToBridge()
await this.bridgePage.validateAndConfirmBridging({
amount: amountToBridge,
token: tokenSymbol,
fromNetwork: 'Boba (Sepolia)',
toNetwork: 'Ethereum (Sepolia)',
estimatedTime: '~1min.',
})

if (approveAllowance) {
await this.bridgePage.approveAndConfirmMetaMaskSuccess(amountToBridge)
} else {
await this.bridgePage.confirmMetaMaskModalToBridge(amountToBridge)
}

await this.bridgePage.wait(successWaitTime) // have to wait for success modal
await this.bridgePage.validateBridgeSuccess()
await this.bridgePage.toHistoryPage()
Expand All @@ -204,8 +108,14 @@ export class GatewayAction {
await this.basePage.wait(1000)
}

async switchL2Network() {
async connect() {
await this.basePage.connectToMetamask(true)
}

async switchToL2AndReset() {
await this.basePage.clickToSwitchNetwork()
await this.basePage.disconnectMetamask()
await this.basePage.connectToMetamask(true)
}

async addAndConnectBNBTestnet() {
Expand Down
47 changes: 20 additions & 27 deletions e2e-tests/pages/bridgePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,34 +71,21 @@ export class BridgePage extends BasePage {
async validateAndConfirmBridging({
amount,
token,
fromNetwork,
toNetwork,
estimatedTime,
}: {
amount: string
token: string
fromNetwork: string
toNetwork: string
amount: string
estimatedTime: string
}) {
await expect(
this.page.getByRole('heading', { name: 'Bridge Confirmation' })
).toBeVisible()

// label can change base on networkType.
await expect(this.page.getByTestId('fromNetwork')).toContainText(
fromNetwork //'Ethereum (Sepolia)'
)

await expect(this.page.getByTestId('toNetwork')).toContainText(
toNetwork //'Boba (Sepolia)'
)

const amountToBridge = await this.page
.locator(':text("Amount to bridge") + p')
.textContent()

await expect(amountToBridge).toContain(`${amount} ${token}`)
expect(amountToBridge).toContain(`${amount} ${token}`)

const time = await this.page
.locator('[data-testid="bridge-confirmation"] :text("Time") + p')
Expand Down Expand Up @@ -128,7 +115,7 @@ export class BridgePage extends BasePage {

await metamask.confirmPermissionToSpend(amount, true)

this.page.waitForTimeout(3000) // wait for 3 secs.
this.page.waitForTimeout(6000) // wait for 3 secs.

await metamask.confirmTransaction({ shouldWaitForPopupClosure: true })

Expand All @@ -151,23 +138,29 @@ export class BridgePage extends BasePage {
)
}

async reviewAndInitiateWithdrawal() {
async reviewAndWithdraw() {
await expect(
this.page.getByRole('heading', { name: 'Withdrawal' })
).toBeVisible()

const initBtn = this.page.getByRole('button', {
name: 'Initiate Withdrawal',
})

await expect(initBtn).toBeEnabled()

await initBtn.click()

await expect(
this.page.getByRole('button', { name: 'Initiate Withdrawal' })
).toBeEnabled()
await this.page.getByRole('button', { name: 'Initiate Withdrawal' }).click()
await metamask.confirmTransaction()

await this.wait(2000)
await this.page.getByRole('button', { name: 'Close' }).click()
}

async reviewAproveAndWithdraw(amount) {
await expect(
this.page.getByRole('heading', { name: 'Withdrawal' })
).toBeVisible()
await expect(
this.page.getByRole('button', { name: 'Initiate Withdrawal' })
).toBeEnabled()
await this.page.getByRole('button', { name: 'Initiate Withdrawal' }).click()
await metamask.confirmPermissionToSpend(amount)
await this.wait(2000)
await this.page.getByRole('button', { name: 'Close' }).click()
}

Expand Down
Loading

0 comments on commit fc75fec

Please sign in to comment.