Skip to content

Commit

Permalink
fix test, add downgrade verifier script, sync (#865)
Browse files Browse the repository at this point in the history
upgrade playwright
upgrade to node 20.18.0
  • Loading branch information
0xBigBoss authored Nov 14, 2024
1 parent 6b4ca79 commit c648f18
Show file tree
Hide file tree
Showing 25 changed files with 970 additions and 231 deletions.
32 changes: 22 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,12 @@ jobs:
has_errors=$(tilt dump engine | jq '
.ManifestTargets
| to_entries
| map(select(.value.State.RuntimeState.Status == "error"))
| map(
select(
.value.State.RuntimeState.Status == "error" or
(.value.State.BuildHistory | length > 0 and .[0].Error != null)
)
)
| length > 0
')
Expand All @@ -205,7 +210,12 @@ jobs:
tilt dump engine | jq '
.ManifestTargets
| to_entries
| map(select(.value.State.RuntimeState.Status == "error"))
| map(
select(
.value.State.RuntimeState.Status == "error" or
(.value.State.BuildHistory | length > 0 and .[0].Error != null)
)
)
| map(.key)
'
exit 1
Expand All @@ -216,14 +226,16 @@ jobs:
break
else
echo "Tilt not ready, retrying..."
tilt dump engine | jq '
.ManifestTargets
| to_entries
| map({key: (.value.State.RuntimeState.Status // "in_progress"), value: .key})
| group_by(.key)
| map({key: .[0].key, value: map(.value)})
| from_entries
'
if [ "${{runner.debug}}" == "1" ]; then
tilt dump engine | jq '
.ManifestTargets
| to_entries
| map({key: (.value.State.RuntimeState.Status // "in_progress"), value: .key})
| group_by(.key)
| map({key: .[0].key, value: map(.value)})
| from_entries
'
fi
fi
if ((i == max_attempts)); then
echo "Reached maximum attempts, exiting"
Expand Down
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v20.15.0
v20.18.0
6 changes: 2 additions & 4 deletions packages/api/src/routers/tag.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import type { PostgrestError } from '@supabase/supabase-js'
import { TRPCError } from '@trpc/server'
import { reward, total } from 'app/data/sendtags'
import {
fetchReferrer,
fetchSendtagCheckoutReceipts,
} from 'app/features/account/sendtag/checkout/checkout-utils'
import { fetchReferrer } from 'app/features/account/sendtag/checkout/checkout-utils'
import { fetchSendtagCheckoutReceipts } from 'app/features/account/sendtag/checkout/checkout-utils.fetchSendtagCheckoutReceipts'
import { assert } from 'app/utils/assert'
import { hexToBytea } from 'app/utils/hexToBytea'
import { supabaseAdmin } from 'app/utils/supabase/admin'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { Database } from '@my/supabase/database.types'
import type { SupabaseClient } from '@supabase/supabase-js'

/**
* Fetches the sendtag checkout receipts.
* Returns an array of receipts with numerics converted to strings to avoid overflows.
*
* @note this function is in it's own file to avoid playwright importing unnecessary modules
*
* @param supabase
* @returns The sendtag checkout receipts.
*/
export function fetchSendtagCheckoutReceipts(supabase: SupabaseClient<Database>) {
return supabase.from('sendtag_checkout_receipts').select(`
event_id,
amount::text,
referrer,
reward::text,
tx_hash
`)
}
17 changes: 1 addition & 16 deletions packages/app/features/account/sendtag/checkout/checkout-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { useUSDCFees } from 'app/utils/useUSDCFees'
import { useUser } from 'app/utils/useUser'
import { useMemo } from 'react'
import { encodeFunctionData, erc20Abi, zeroAddress } from 'viem'
import { fetchSendtagCheckoutReceipts } from './checkout-utils.fetchSendtagCheckoutReceipts'

export const verifyAddressMsg = (a: string | `0x${string}`) =>
`I am the owner of the address: ${a}.
Expand Down Expand Up @@ -142,22 +143,6 @@ export function useReferralReward({ tags }: { tags: { name: string }[] }) {
})
}

/**
* Fetches the sendtag checkout receipts.
* Returns an array of receipts with numerics converted to strings to avoid overflows.
* @param supabase
* @returns The sendtag checkout receipts.
*/
export function fetchSendtagCheckoutReceipts(supabase: SupabaseClient<Database>) {
return supabase.from('sendtag_checkout_receipts').select(`
event_id,
amount::text,
referrer,
reward::text,
tx_hash
`)
}

function sendtagCheckoutReceiptsQueryOptions(supabase: SupabaseClient<Database>) {
return queryOptions({
queryKey: ['sendtag_checkout_transfers', supabase] as const,
Expand Down

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions packages/contracts/script/DowngradeFjordSendVerifier.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.20;

import {Script, console2} from "forge-std/Script.sol";
import {Helper} from "../src/Helper.sol";

import {SendVerifier, SendVerifierProxy} from "../src/SendVerifier.sol";

/**
* Downgrades the SendVerifierProxy to the legacy verifier implementation.
*/
contract DowngradeFjordSendVerifierScript is Script, Helper {
function setUp() public {
this.labels();
}

function run() public {
address svpAddr = vm.envAddress("SVP_ADDRESS"); // send verifier proxy address

require(svpAddr != address(0), "SVP_ADDRESS env variable not set");

vm.startBroadcast();

SendVerifier sv = SendVerifier(svpAddr);
sv.upgradeTo(0xE269194e41Cd50E2986f82Fc23A2B95D8bAFED2B);

// solhint-disable-next-line no-console
console2.log("Downgraded SendVerifierProxy address:", address(sv));

vm.stopBroadcast();
}
}
2 changes: 1 addition & 1 deletion packages/contracts/script/anvil-base-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ await $`docker run --rm \
--network=supabase_network_send \
-p=0.0.0.0:8546:8546 \
--name=sendapp-anvil-base \
ghcr.io/foundry-rs/foundry "anvil \
ghcr.io/foundry-rs/foundry:nightly "anvil \
--host=0.0.0.0 \
--port=8546 \
--chain-id=$NEXT_PUBLIC_BASE_CHAIN_ID \
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"@my/snaplet": "workspace:*",
"@my/supabase": "workspace:*",
"@my/wagmi": "workspace:*",
"@playwright/test": "^1.45.1",
"@playwright/test": "^1.48.2",
"@supabase/supabase-js": "2.44.2",
"@types/bun": "^1.1.6",
"@types/jsonwebtoken": "^9.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ test('can visit rewards page', async ({ page }) => {
await page.goto('/account/rewards')
await expect(page).toHaveURL('/account/rewards')
await expect(page.getByText('Rewards', { exact: true })).toBeVisible()
await expect(page.getByRole('heading', { name: 'Claim Your Network Benefits' })).toBeVisible()
await expect(page.getByRole('heading', { name: 'Invest Time, EARN Send' })).toBeVisible()
})
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import { test as snapletTest } from '@my/playwright/fixtures/snaplet'
import { userOnboarded, type SeedClient } from '@my/snaplet'
import type { Database } from '@my/supabase/database.types'
import { usdcAddress } from '@my/wagmi'
import type { Page } from '@playwright/test'
import { devices, mergeTests } from '@playwright/test'
import { devices, mergeTests, type Page } from '@playwright/test'
import type { SupabaseClient } from '@supabase/supabase-js'
import { price, pricing, reward, total } from 'app/data/sendtags'
import { fetchSendtagCheckoutReceipts } from 'app/features/account/sendtag/checkout/checkout-utils'
import { fetchSendtagCheckoutReceipts } from 'app/features/account/sendtag/checkout/checkout-utils.fetchSendtagCheckoutReceipts'
import { assert } from 'app/utils/assert'
import { hexToBytea } from 'app/utils/hexToBytea'
import debug from 'debug'
Expand Down Expand Up @@ -192,7 +191,7 @@ test('can confirm a tag', async ({ checkoutPage, supabase, user: { profile: myPr
await addPendingTag(checkoutPage, tagName)
await confirmTags(checkoutPage, [tagName])
await verifyTagsInDatabase(supabase, [tagName])
await expect(checkoutPage.page).toHaveTitle('Send | Sendtag')
await expect(checkoutPage.page).toHaveTitle('Send | Sendtags')

const receiptEvent = {
event_name: 'tag_receipt_usdc',
Expand Down
3 changes: 2 additions & 1 deletion packages/playwright/tests/activity.onboarded.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import crypto from 'node:crypto'
import { zeroAddress } from 'viem'
import { expect, test } from './fixtures/send-accounts'
import { testBaseClient } from './fixtures/viem'
import { shorten } from 'app/utils/strings'

let log: debug.Debugger

Expand Down Expand Up @@ -265,7 +266,7 @@ test('can visit activity page and see correct activity feed', async ({
// Deposit
await expect.soft(activityRows.nth(9)).toContainText('Deposit')
await expect.soft(activityRows.nth(9)).toContainText('0.019032 USDC')
await expect.soft(activityRows.nth(9)).toContainText(anotherSendAccount.address)
await expect.soft(activityRows.nth(9)).toContainText(shorten(anotherSendAccount.address, 5, 4))
})

test('can search on activity page', async ({ page, context }) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright/tests/fixtures/checkout/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class CheckoutPage {
await this.page.getByRole('button', { name: 'Pricing' }).hover()
}

async confirmTags(expect: Expect<CheckoutPage>) {
async confirmTags(expect: Expect) {
// sign transaction
log('sign transaction')
const confirmTagsRequest = this.page.waitForRequest(
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright/tests/fixtures/profiles/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class ProfilePage {
this.sendButton = page.getByRole('link', { name: 'SEND' })
}

async visit(tag: string, expect?: Expect<ProfilePage>) {
async visit(tag: string, expect?: Expect) {
await this.page.goto(`/${tag}`)
const title = await this.page.title()
expect?.(title).toBe('Send | Profile')
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright/tests/fixtures/send-accounts/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class OnboardingPage {

public readonly accountName = `test-${Math.floor(Math.random() * 1000000)}`

async completeOnboarding(expect: Expect<OnboardingPage>) {
async completeOnboarding(expect: Expect) {
await this.page.goto('/')
expect(this.page).toHaveURL('/auth/onboarding') // no send accounts redirects to onboarding page

Expand Down
2 changes: 1 addition & 1 deletion packages/playwright/tests/fixtures/send/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class SendPage {
}

async fillAndSubmitForm(amount: string) {
await this.expect(this.page.getByText('Enter Amount')).toBeVisible()
await this.expect(this.page.locator('h2', { hasText: 'Enter Amount' })).toBeVisible()
await this.expect(this.amountInput).toBeVisible()
await this.amountInput.fill(amount)
await this.expect(this.continueButton).toBeVisible()
Expand Down
1 change: 0 additions & 1 deletion packages/playwright/tests/fixtures/snaplet/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { copycat } from '@snaplet/copycat'
import { createSeedClient } from '@snaplet/seed'
import debug from 'debug'
import pg from 'pg'
import { SeedPg } from '@snaplet/seed/adapter-pg'

let log: debug.Debugger

Expand Down
15 changes: 11 additions & 4 deletions packages/playwright/tests/home.onboarded.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { mockUsdcTransfers } from 'app/features/home/utils/__mocks__/mock-usdc-t
import { SUPABASE_URL } from 'app/utils/supabase/admin'
import debug from 'debug'
import { expect, test } from './fixtures/send-accounts'
import { shorten } from 'app/utils/strings'

let log: debug.Debugger

Expand Down Expand Up @@ -35,8 +36,10 @@ test('can visit token detail page', async ({ context, page }) => {

const history = page.getByTestId('TokenDetailsHistory')

await expect.soft(history.getByText('Sent')).toBeVisible()
await expect.soft(history.getByText('0x93F2FA7A16a7365e3895b0F6E6Ac7a832d6c761a')).toBeVisible()
await expect.soft(history.getByText('Withdraw')).toBeVisible()
await expect
.soft(history.getByText(shorten('0x93F2FA7A16a7365e3895b0F6E6Ac7a832d6c761a', 5, 4)))
.toBeVisible()
await expect.soft(history.getByText('10 USDC')).toBeVisible()

// Button and label
Expand All @@ -45,9 +48,13 @@ test('can visit token detail page', async ({ context, page }) => {
await expect.soft(history.getByText('/alice')).toBeVisible()
await expect.soft(history.getByText('Received')).toBeVisible()
await expect.soft(history.getByText('20 USDC')).toBeVisible()
await expect.soft(history.getByText('0xa71CE00000000000000000000000000000000000')).toBeVisible()
await expect
.soft(history.getByText(shorten('0xa71CE00000000000000000000000000000000000', 5, 4)))
.toBeVisible()
await expect.soft(history.getByText('30 USDC')).toBeVisible()
await expect.soft(history.getByText('0x93F2FA7A16a7365e3895b0F6E6Ac7a832d6c761a')).toBeVisible()
await expect
.soft(history.getByText(shorten('0x93F2FA7A16a7365e3895b0F6E6Ac7a832d6c761a', 5, 4)))
.toBeVisible()

expect(page.getByTestId('TokenDetailsHistory')).toBeVisible()
// expect(await page.getByTestId('TokenDetailsHistory').textContent()).toMatchSnapshot(
Expand Down
4 changes: 2 additions & 2 deletions packages/playwright/tests/profile.onboarded.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ test('can visit other user profile and send by tag', async ({ page, seed }) => {
recipient: tag.name,
idType: 'tag',
})
await expect(page.getByText('Enter Amount')).toBeVisible()
await expect(page.locator('h2', { hasText: 'Enter Amount' })).toBeVisible()

// visit another user but without a sendtag
const plan2 = await seed.users([{ ...userOnboarded, tags: [] }])
Expand All @@ -53,7 +53,7 @@ test('can visit other user profile and send by tag', async ({ page, seed }) => {
recipient: profile2?.send_id.toString(),
idType: 'sendid',
})
await expect(page.getByText('Enter Amount')).toBeVisible()
await expect(page.locator('h2', { hasText: 'Enter Amount' })).toBeVisible()

// can visit profile withouth the @ prefix
await page.goto(`/${tag.name}`)
Expand Down
6 changes: 4 additions & 2 deletions packages/playwright/tests/send.onboarded.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { hexToBytea } from 'app/utils/hexToBytea'
import { shorten } from 'app/utils/strings'
import { setERC20Balance } from 'app/utils/useSetErc20Balance'
import debug from 'debug'
import { parseUnits } from 'viem'
import { isAddress, parseUnits } from 'viem'
import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts'
import { ProfilePage } from './fixtures/profiles'
import { SendPage } from './fixtures/send'
Expand Down Expand Up @@ -274,6 +274,8 @@ async function handleTokenTransfer({
const history = page.getByTestId('TokenDetailsHistory')
await expect(history).toBeVisible()
await expect(history.getByText(`${decimalAmount} ${token.symbol}`)).toBeVisible()
await expect(history.getByText(counterparty)).toBeVisible()
await expect(
history.getByText(isAddress(counterparty) ? shorten(counterparty ?? '', 5, 4) : counterparty)
).toBeVisible()
}
}
Loading

0 comments on commit c648f18

Please sign in to comment.