Skip to content

Commit

Permalink
tests: add send funds happy path with replay (#3485)
Browse files Browse the repository at this point in the history
  • Loading branch information
mike10ca authored Mar 27, 2024
1 parent d6ecb97 commit 549b964
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 14 deletions.
29 changes: 15 additions & 14 deletions cypress/e2e/happypath/sendfunds_1.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,28 @@ const safeBalanceEth = 5000000000000000n
const testToken = 'DoritoNfts'
const tokenAmount = 0.005

describe('Send funds happy path tests 1', () => {
beforeEach(() => {
cy.visit(constants.BALANCE_URL + constants.SEPOLIA_TEST_SAFE_28_SEND_FUNDS_HP1)
cy.clearLocalStorage()
main.acceptCookies()
})
function visit(url) {
cy.visit(url)
cy.clearLocalStorage()
main.acceptCookies()
}

describe('Send funds happy path tests 1', () => {
it('Verify tx creation and execution of non-native token with connected signer', () => {
function executeTransactionFlow(fromSafe, toSafe) {
cy.visit(constants.BALANCE_URL + fromSafe)
visit(constants.BALANCE_URL + fromSafe)
assets.selectTokenList(assets.tokenListOptions.allTokens)
assets.clickOnSendBtn(1)

loadsafe.inputOwnerAddress(0, toSafe)
assets.checkSelectedToken(constants.tokenAbbreviation.ttone)
assets.enterAmount(10)
navigation.clickOnNewTxBtnS()
tx.executeFlow_1()
cy.wait(5000)
}
executeTransactionFlow(constants.SEPOLIA_TEST_SAFE_28_SEND_FUNDS_HP1, constants.SEPOLIA_TEST_SAFE_29_SEND_FUNDS_HP2)
executeTransactionFlow(constants.SEPOLIA_TEST_SAFE_29_SEND_FUNDS_HP2, constants.SEPOLIA_TEST_SAFE_28_SEND_FUNDS_HP1)
cy.wait(10000)
cy.wait(5000)
main.checkTokenBalanceIsNull(constants.SEPOLIA_TEST_SAFE_29_SEND_FUNDS_HP2, constants.tokenAbbreviation.ttone)
main.checkTokenBalance(
constants.SEPOLIA_TEST_SAFE_28_SEND_FUNDS_HP1,
Expand All @@ -43,30 +43,31 @@ describe('Send funds happy path tests 1', () => {

it('Verify tx creation and execution of NFT with connected signer', () => {
function executeTransactionFlow(fromSafe, toSafe) {
cy.visit(constants.balanceNftsUrl + fromSafe)
cy.wait(2000)
visit(constants.balanceNftsUrl + fromSafe)
nfts.selectNFTs(1)
nfts.sendNFT()
nfts.typeRecipientAddress(toSafe)
nfts.clikOnNextBtn()
tx.executeFlow_1()
cy.wait(5000)
}
executeTransactionFlow(constants.SEPOLIA_TEST_SAFE_30_SEND_NFT_HP1, constants.SEPOLIA_TEST_SAFE_31_SEND_NFT_HP2)
executeTransactionFlow(constants.SEPOLIA_TEST_SAFE_31_SEND_NFT_HP2, constants.SEPOLIA_TEST_SAFE_30_SEND_NFT_HP1)
cy.wait(10000)
cy.wait(5000)
main.checkNFTBalance(constants.SEPOLIA_TEST_SAFE_30_SEND_NFT_HP1, constants.tokenAbbreviation.dor, testToken)
main.checkTokenBalanceIsNull(constants.SEPOLIA_TEST_SAFE_31_SEND_NFT_HP2, constants.tokenAbbreviation.dor)
})

it('Verify tx creation and execution of native token with connected signer', () => {
function executeTransactionFlow(fromSafe, toSafe, tokenAmount) {
cy.visit(constants.BALANCE_URL + fromSafe)
visit(constants.BALANCE_URL + fromSafe)
assets.clickOnSendBtn(0)
loadsafe.inputOwnerAddress(0, toSafe)
assets.checkSelectedToken(constants.tokenAbbreviation.sep)
assets.enterAmount(tokenAmount)
navigation.clickOnNewTxBtnS()
tx.executeFlow_1()
cy.wait(5000)
}
main.fetchCurrentNonce(constants.SEPOLIA_TEST_SAFE_32_SEND_NATIVE_HP1).then((currentNonceSafe1) => {
main.fetchCurrentNonce(constants.SEPOLIA_TEST_SAFE_33_SEND_NATIVE_HP2).then((currentNonceSafe2) => {
Expand All @@ -80,7 +81,7 @@ describe('Send funds happy path tests 1', () => {
constants.SEPOLIA_TEST_SAFE_32_SEND_NATIVE_HP1,
tokenAmount,
)
cy.wait(10000)
cy.wait(5000)
main.verifyNonceChange(constants.SEPOLIA_TEST_SAFE_33_SEND_NATIVE_HP2, currentNonceSafe2 + 1)
main.verifyNonceChange(constants.SEPOLIA_TEST_SAFE_32_SEND_NATIVE_HP1, currentNonceSafe1 + 1)

Expand Down
98 changes: 98 additions & 0 deletions cypress/e2e/happypath/sendfunds_2.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import * as constants from '../../support/constants'
import * as main from '../pages/main.page'
import * as assets from '../pages/assets.pages'
import * as loadsafe from '../pages/load_safe.pages'
import * as navigation from '../pages/navigation.page'
import * as tx from '../pages/transactions.page'
import * as nfts from '../pages/nfts.pages'

const safe1Balance_2 = 100000000000000000000n
const safeBalanceEth = 5000000000000000n
const testToken = 'GasTestingToken'
const tokenAmount = 0.005

function visit(url) {
cy.visit(url)
cy.clearLocalStorage()
main.acceptCookies()
}

describe('Send funds happy path tests 2', () => {
it('Verify tx creation and execution of non-native token with relay', () => {
function executeTransactionFlow(fromSafe, toSafe) {
visit(constants.BALANCE_URL + fromSafe)
assets.selectTokenList(assets.tokenListOptions.allTokens)
assets.clickOnSendBtn(1)

loadsafe.inputOwnerAddress(0, toSafe)
assets.checkSelectedToken(constants.tokenAbbreviation.ttone)
assets.enterAmount(10)
navigation.clickOnNewTxBtnS()
tx.executeFlow_2()
cy.wait(5000)
}
executeTransactionFlow(constants.SEPOLIA_TEST_SAFE_36_SEND_FUNDS_HP5, constants.SEPOLIA_TEST_SAFE_37_SEND_FUNDS_HP6)
executeTransactionFlow(constants.SEPOLIA_TEST_SAFE_37_SEND_FUNDS_HP6, constants.SEPOLIA_TEST_SAFE_36_SEND_FUNDS_HP5)
cy.wait(5000)
main.checkTokenBalanceIsNull(constants.SEPOLIA_TEST_SAFE_37_SEND_FUNDS_HP6, constants.tokenAbbreviation.ttone)
main.checkTokenBalance(
constants.SEPOLIA_TEST_SAFE_36_SEND_FUNDS_HP5,
constants.tokenAbbreviation.ttone,
safe1Balance_2,
)
})

it('Verify tx creation and execution of NFT with relay', () => {
function executeTransactionFlow(fromSafe, toSafe) {
visit(constants.balanceNftsUrl + fromSafe)
nfts.selectNFTs(1)
nfts.sendNFT()
nfts.typeRecipientAddress(toSafe)
nfts.clikOnNextBtn()
tx.executeFlow_2()
cy.wait(5000)
}
executeTransactionFlow(constants.SEPOLIA_TEST_SAFE_38_SEND_FUNDS_HP7, constants.SEPOLIA_TEST_SAFE_39_SEND_FUNDS_HP8)
executeTransactionFlow(constants.SEPOLIA_TEST_SAFE_39_SEND_FUNDS_HP8, constants.SEPOLIA_TEST_SAFE_38_SEND_FUNDS_HP7)
cy.wait(5000)
main.checkNFTBalance(constants.SEPOLIA_TEST_SAFE_38_SEND_FUNDS_HP7, constants.tokenAbbreviation.gtt, testToken)
main.checkTokenBalanceIsNull(constants.SEPOLIA_TEST_SAFE_39_SEND_FUNDS_HP8, constants.tokenAbbreviation.gtt)
})

it('Verify tx creation and execution of native token with relay', () => {
function executeTransactionFlow(fromSafe, toSafe, tokenAmount) {
visit(constants.BALANCE_URL + fromSafe)
assets.clickOnSendBtn(0)
loadsafe.inputOwnerAddress(0, toSafe)
assets.checkSelectedToken(constants.tokenAbbreviation.sep)
assets.enterAmount(tokenAmount)
navigation.clickOnNewTxBtnS()
tx.executeFlow_2()
cy.wait(5000)
}
main.fetchCurrentNonce(constants.SEPOLIA_TEST_SAFE_34_SEND_FUNDS_HP3).then((currentNonceSafe1) => {
main.fetchCurrentNonce(constants.SEPOLIA_TEST_SAFE_35_SEND_FUNDS_HP4).then((currentNonceSafe2) => {
executeTransactionFlow(
constants.SEPOLIA_TEST_SAFE_34_SEND_FUNDS_HP3,
constants.SEPOLIA_TEST_SAFE_35_SEND_FUNDS_HP4,
tokenAmount,
)
executeTransactionFlow(
constants.SEPOLIA_TEST_SAFE_35_SEND_FUNDS_HP4,
constants.SEPOLIA_TEST_SAFE_34_SEND_FUNDS_HP3,
tokenAmount,
)
cy.wait(5000)
main.verifyNonceChange(constants.SEPOLIA_TEST_SAFE_35_SEND_FUNDS_HP4, currentNonceSafe2 + 1)
main.verifyNonceChange(constants.SEPOLIA_TEST_SAFE_34_SEND_FUNDS_HP3, currentNonceSafe1 + 1)

main.checkTokenBalance(constants.SEPOLIA_TEST_SAFE_35_SEND_FUNDS_HP4, constants.tokenAbbreviation.eth, '0')
main.checkTokenBalance(
constants.SEPOLIA_TEST_SAFE_34_SEND_FUNDS_HP3,
constants.tokenAbbreviation.eth,
safeBalanceEth,
)
})
})
})
})
12 changes: 12 additions & 0 deletions cypress/e2e/pages/transactions.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export function selectConnectedWalletOption() {
cy.get(connectedWalletExecutionMethod).click()
}

export function selectRelayOtion() {
cy.get(connectedWalletExecutionMethod).prev().click()
}

export function clickOnExecuteBtn() {
cy.get('button').contains(executeBtnStr).click()
}
Expand All @@ -34,3 +38,11 @@ export function executeFlow_1() {
waitForTxToComplete()
clickOnFinishBtn()
}

export function executeFlow_2() {
selectExecuteNow()
selectRelayOtion()
clickOnExecuteBtn()
waitForTxToComplete()
clickOnFinishBtn()
}
11 changes: 11 additions & 0 deletions cypress/support/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ export const SEPOLIA_TEST_SAFE_30_SEND_NFT_HP1 = 'sep:0x6C7d3939Ae99dd3e4422D8b3
export const SEPOLIA_TEST_SAFE_31_SEND_NFT_HP2 = 'sep:0x97143f05ad523027b0F6F86FeD96E5e51F58DdAc'
export const SEPOLIA_TEST_SAFE_32_SEND_NATIVE_HP1 = 'sep:0xe5DC58EfDA6ebe93014AaE7A5a673C5F80118171'
export const SEPOLIA_TEST_SAFE_33_SEND_NATIVE_HP2 = 'sep:0x9DF284917ff80c0a95c20ea2151Eb2a39a13cf4E'

export const SEPOLIA_TEST_SAFE_34_SEND_FUNDS_HP3 = 'sep:0xFE8697FE746Ff566C4962675270F446a9F54a187'
export const SEPOLIA_TEST_SAFE_35_SEND_FUNDS_HP4 = 'sep:0x9711ad5B73Ae6B2e01031D1D798949a8e7E889a6'

export const SEPOLIA_TEST_SAFE_36_SEND_FUNDS_HP5 = 'sep:0x21074f7A5C7bc2BCfD818fFeFfB442ab4877D2d2'
export const SEPOLIA_TEST_SAFE_37_SEND_FUNDS_HP6 = 'sep:0xAd65717D60f7f2c65895c800148bc53eedC73c24'

export const SEPOLIA_TEST_SAFE_38_SEND_FUNDS_HP7 = 'sep:0xad23bd2D4cDB86FF2a6600c74995c01eA209AfC1'
export const SEPOLIA_TEST_SAFE_39_SEND_FUNDS_HP8 = 'sep:0xEbED8ABaAe1FCFA9D3343B34a2373a57A558abd1'

export const SEPOLIA_CONTRACT_SHORT = '0x11AB...34aF'
export const SEPOLIA_RECIPIENT_ADDR_SHORT = '0x4DD4...7bde'
export const GNO_TEST_SAFE = 'gno:0xB8d760a90a5ed54D3c2b3EFC231277e99188642A'
Expand Down Expand Up @@ -168,6 +178,7 @@ export const tokenAbbreviation = {
ttone: 'TTONE',
dor: 'DOR',
eth: 'ETH',
gtt: 'GTT',
}

export const currencies = {
Expand Down

0 comments on commit 549b964

Please sign in to comment.