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

Updating integration tests to assert on latest ecosystems changes #42

Merged
merged 9 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 9 additions & 2 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
name: Frontend Tests
on:
pull_request:
paths: [frontend/**]
abhidtu2014 marked this conversation as resolved.
Show resolved Hide resolved
paths: [frontend/**, token-dispenser/**]
push:
branches: [main]
paths: [frontend/**]
paths: [frontend/**, token-dispenser/**]

jobs:
test:
runs-on: ubuntu-latest
container:
image: jetprotocol/builder:rust-1.68.0-node-18.15.0-solana-1.14.17-anchor-0.27.0-1
env:
ENDPOINT: http://localhost:8899

env:
PROGRAM_ID: Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS

defaults:
run:
Expand Down
2 changes: 1 addition & 1 deletion frontend/integration/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export async function handlerAmountAndProof(
} else {
res.status(200).json({
amount: result.amount,
proof: result.proof,
hashes: result.proof_of_inclusion,
address: identity,
})
}
Expand Down
92 changes: 12 additions & 80 deletions frontend/integration/integrationTest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,8 @@ import { ethers } from 'ethers'
import {
addTestWalletsToDatabase as addTestWalletsToInMemoryDb,
clearInMemoryDb,
getInMemoryDb,
} from './utils'

function getDatabasePool() {
return {
end: async () => {},
}
}

async function clearDatabase(..._: any[]) {}

async function addTestWalletsToDatabase(..._: any[]) {
return []
}

const pool = getDatabasePool()

describe('integration test', () => {
let root: Buffer
let maxAmount: anchor.BN
Expand Down Expand Up @@ -241,7 +226,7 @@ describe('integration test', () => {
).toBeTruthy()
}, 40000)

it('submits a cosmwasm claim', async () => {
it('submits a terra claim', async () => {
const { claimInfo, proofOfInclusion } = (await mockFetchAmountAndProof(
'terra',
testWallets.terra[0].address()
Expand Down Expand Up @@ -274,7 +259,7 @@ describe('integration test', () => {
const claimantFund = await mint.getAccountInfo(claimantFundPubkey)

expect(
claimantFund.amount.eq(new anchor.BN(3000000 + 6000000))
claimantFund.amount.eq(new anchor.BN(3000000 + 7000000))
).toBeTruthy()

const { txnEvents } =
Expand All @@ -301,7 +286,7 @@ describe('integration test', () => {

it('submits multiple claims at once', async () => {
const wallets = {
terra: testWallets.terra[0],
injective: testWallets.injective[0],
osmosis: testWallets.osmosis[0],
}

Expand Down Expand Up @@ -360,50 +345,11 @@ describe('integration test', () => {

expect(
claimantFund.amount.eq(
new anchor.BN(3000000 + 6000000 + 6100000 + 6200000)
new anchor.BN(3000000 + 7000000 + 8000000 + 9000000)
abhidtu2014 marked this conversation as resolved.
Show resolved Hide resolved
)
).toBeTruthy()
})

it('submits an injective claim', async () => {
sebastianscatularo marked this conversation as resolved.
Show resolved Hide resolved
const wallet = testWallets.injective[0]
const { claimInfo, proofOfInclusion } = (await mockFetchAmountAndProof(
'injective',
wallet.address()
))!
const signedMessage = await wallet.signMessage(
tokenDispenserProvider.generateAuthorizationPayload()
)

await Promise.all(
await tokenDispenserProvider.submitClaims(
[
{
claimInfo,
proofOfInclusion,
signedMessage,
},
],
mockfetchFundTransaction
)
)

expect(
await tokenDispenserProvider.isClaimAlreadySubmitted(claimInfo)
).toBeTruthy()

const claimantFundPubkey =
await tokenDispenserProvider.getClaimantFundAddress()

const claimantFund = await mint.getAccountInfo(claimantFundPubkey)

expect(
claimantFund.amount.eq(
new anchor.BN(3000000 + 6000000 + 6100000 + 6200000 + 7000000)
)
).toBeTruthy()
}, 40000)

it('submits an aptos claim', async () => {
const wallet = testWallets.aptos[0]
const { claimInfo, proofOfInclusion } = (await mockFetchAmountAndProof(
Expand Down Expand Up @@ -438,9 +384,7 @@ describe('integration test', () => {

expect(
claimantFund.amount.eq(
new anchor.BN(
3000000 + 6000000 + 6100000 + 6200000 + 7000000 + 5000000
)
new anchor.BN(3000000 + 7000000 + 8000000 + 9000000 + 6000000)
)
).toBeTruthy()
})
Expand Down Expand Up @@ -484,13 +428,7 @@ describe('integration test', () => {
expect(
claimantFund.amount.eq(
new anchor.BN(
3000000 +
6000000 +
6100000 +
6200000 +
7000000 +
5000000 +
1000000
3000000 + 7000000 + 8000000 + 9000000 + 6000000 + 1000000
)
)
).toBeTruthy()
Expand Down Expand Up @@ -530,14 +468,7 @@ describe('integration test', () => {
expect(
claimantFund.amount.eq(
new anchor.BN(
3000000 +
6000000 +
6100000 +
6200000 +
7000000 +
5000000 +
1000000 +
2000000
3000000 + 7000000 + 8000000 + 9000000 + 6000000 + 1000000 + 2000000
)
)
).toBeTruthy()
Expand Down Expand Up @@ -579,18 +510,18 @@ describe('integration test', () => {
claimantFund.amount.eq(
new anchor.BN(
3000000 +
6000000 +
6100000 +
6200000 +
7000000 +
5000000 +
8000000 +
9000000 +
6000000 +
1000000 +
2000000 +
4000000
)
)
).toBeTruthy()
}, 40000)

it('fails to submit a duplicate claim', async () => {
const wallet = testWallets.sui[0]
const { claimInfo, proofOfInclusion } = (await mockFetchAmountAndProof(
Expand All @@ -615,6 +546,7 @@ describe('integration test', () => {
)
expect(JSON.stringify(res[0]).includes('InstructionError')).toBeTruthy()
})

it('eventSubscriber parses error transaction logs', async () => {
const { txnEvents, failedTxnInfos } =
await tokenDispenserEventSubscriber.parseTransactionLogs()
Expand Down
9 changes: 2 additions & 7 deletions frontend/integration/utils.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import 'dotenv/config' // Load environment variables from .env file
import * as anchor from '@coral-xyz/anchor'
import {
TestEvmWallet,
TestSolanaWallet,
TestWallet,
} from '../claim_sdk/testWallets'
import { TestWallet } from '../claim_sdk/testWallets'
import { ClaimInfo, Ecosystem, Ecosystems } from '../claim_sdk/claim'
import { getMaxAmount } from '../claim_sdk/claim'
import { MerkleTree } from '../claim_sdk/merkleTree'

const CHUNK_SIZE = 1000
const SOLANA_ECOSYSTEM_INDEX = 2
const EVM_ECOSYSTEM_INDEX = 3

export const EVM_CHAINS = [
'optimism-mainnet',
'arbitrum-mainnet',
Expand Down
4 changes: 3 additions & 1 deletion frontend/pages/verify-eligibility/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ export default function VerifyEligibilityPage() {
<BoxTitle> Verify Eligibility</BoxTitle>
<div className="px-4 py-8 text-base sm:px-10 sm:text-base16">
<p className="mb-6">
Please connect all wallets based on the networks you chose in the previous step. Feel free to go back and adjust any selections if necessary.
Please connect all wallets based on the networks you chose in the
previous step. Feel free to go back and adjust any selections if
necessary.
</p>
<p>
{`Note that you won't be able to move on to the next step and claim your W unless all your wallets or Discord account are successfully connected.`}
Expand Down
1 change: 0 additions & 1 deletion frontend/scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ function stop_anchor_localnet() {
if [ -n "$solana_pid" ]; then
echo "killing solana-test-validator with pid: $solana_pid"
kill -9 "$solana_pid"
pgrep -f 'solana-test-validator' | xargs kill -9
else
echo "No solana-test-validator process found to stop"
fi
Expand Down
4 changes: 1 addition & 3 deletions frontend/sections/ClaimStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ export const ClaimStatus = ({
<Box>
<BoxTitle>
<div className="flex items-center justify-between ">
<h4 className=" text-[20px] sm:text-[28px]">
Sign and Claim
</h4>
<h4 className=" text-[20px] sm:text-[28px]">Sign and Claim</h4>
<div className="flex gap-4">
<ProceedButton
onProceed={onProceed}
Expand Down
8 changes: 4 additions & 4 deletions frontend/sections/LogInWithSolana.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ export const LogInWithSolana = ({ onBack, onProceed }: StepProps) => {
</BoxTitle>
<div className="px-4 py-8 text-base sm:px-10 sm:text-base16">
<p className="mb-6">
W is native to the Solana network. To receive your W, a Solana wallet is required. The W you claim will be sent to the Solana wallet you link during this process.
</p>
<p className="">
Below, you'll find a list of popular Solana wallets.
W is native to the Solana network. To receive your W, a Solana wallet
is required. The W you claim will be sent to the Solana wallet you
link during this process.
</p>
<p className="">Below, you'll find a list of popular Solana wallets.</p>
{wallet === null ? (
<SelectWallets />
) : (
Expand Down
4 changes: 3 additions & 1 deletion frontend/sections/LoggedInSolana.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ export const LoggedInSolana = ({ onBack, onProceed }: StepProps) => {
</BoxTitle>
<div className="px-4 py-8 text-base sm:px-10 sm:text-base16">
<p className="mb-6">
W is native to the Solana network. To receive your W, a Solana wallet is required. The W you claim will be sent to the Solana wallet you link during this process.
W is native to the Solana network. To receive your W, a Solana wallet
is required. The W you claim will be sent to the Solana wallet you
link during this process.
</p>
<p className="">
To change the connected wallet please go to the previous step.
Expand Down
3 changes: 2 additions & 1 deletion frontend/sections/PastActivity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ export const PastActivity = ({ onBack, onProceed }: StepProps) => {
<BoxTitle> {`Activity Review`}</BoxTitle>
<div className="px-4 py-8 text-base sm:px-10 sm:text-base16">
<p className="mb-6">
Please tick the appropriate boxes below that reflect your wallet usage and participation in the Wormhole ecosystem.
Please tick the appropriate boxes below that reflect your wallet
usage and participation in the Wormhole ecosystem.
</p>

<p className="mb-6 font-light">Active on:</p>
Expand Down
7 changes: 5 additions & 2 deletions frontend/sections/SignAndClaim.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ export const SignAndClaim = ({ onBack, onProceed }: SignAndClaimProps) => {
{`Please proceed to sign your connected wallets. Press the “Sign” button next to each wallet and confirm in the pop-up window.`}
</p>
<p className="mb-6">
Signing with your Solana wallet will be done at a later step. Discord requires no further action.
Signing with your Solana wallet will be done at a later step.
Discord requires no further action.
</p>
<p>Your W will be claimed to the following Solana wallet:</p>
<div className="mt-8 flex items-center justify-between gap-4">
Expand Down Expand Up @@ -253,7 +254,9 @@ function ClaimAirdropModal({
Claim W
</h3>
<p className="mx-auto max-w-[454px] font-body text-base16">
Please make sure you’ve connected all required wallets and Discord accounts. You have the option to go through the claim process again using different wallets.
Please make sure you’ve connected all required wallets and Discord
accounts. You have the option to go through the claim process again
using different wallets.
</p>
<div className="mt-12 flex justify-center gap-4">
<BackButton onBack={onBack} />
Expand Down
4 changes: 1 addition & 3 deletions frontend/sections/SignForEligibleWallets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ export const SignForEligibleWallets = ({
<Box>
<BoxTitle>
<div className="flex items-center justify-between ">
<span className=" text-[20px] sm:text-[28px]">
Sign and Claim
</span>
<span className=" text-[20px] sm:text-[28px]">Sign and Claim</span>
<div className="flex gap-1 sm:gap-4">
<BackButton onBack={onBack} hideText={isMobile} />
<ProceedButton
Expand Down
11 changes: 8 additions & 3 deletions frontend/sections/Welcome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@ export const Welcome = ({ onProceed }: { onProceed: () => void }) => {
<BoxTitle> Welcome to the Wormhole Airdrop</BoxTitle>
<div className="px-4 py-8 text-base sm:px-10 sm:text-base16">
<p className="mb-6">
The Wormhole platform is on a road of further decentralization. This airdrop is constructed to support that vision and meaningfully decentralize stakeholders from the start.
The Wormhole platform is on a road of further decentralization. This
airdrop is constructed to support that vision and meaningfully
decentralize stakeholders from the start.
</p>
<p className="mb-6">
Eligibility for this W airdrop may apply to you if you've interacted with ecosystem chains, applications, or the community within the Wormhole ecosystem in the past. The snapshot for this airdrop has already been taken as of February 6, 2024, 23:59 UTC.
Eligibility for this W airdrop may apply to you if you've interacted
with ecosystem chains, applications, or the community within the
Wormhole ecosystem in the past. The snapshot for this airdrop has
already been taken as of February 6, 2024, 23:59 UTC.
</p>
<p className="mb-6">
Please proceed to check your eligibility and claim your W.
Please proceed to check your eligibility and claim your W.
</p>
<div className="mt-12 flex justify-end">
<ProceedButton onProceed={onProceed} />
Expand Down
Loading