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

Add full end to end integration tests for web3 #10016

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0de1185
Added test containers
kurtisassad Nov 18, 2024
7b35403
Merge branch 'refs/heads/master' into ka.testcontainers
kurtisassad Nov 21, 2024
3a01cfe
Fixing tests
kurtisassad Nov 22, 2024
3ca12be
Refactored tests
kurtisassad Nov 22, 2024
90b9c17
Merge branch 'master' into ka.testcontainers
kurtisassad Nov 22, 2024
21aa38e
Minor fixes
kurtisassad Nov 22, 2024
be66356
Minor fixes
kurtisassad Nov 22, 2024
6f4db65
Fixed tests
kurtisassad Nov 22, 2024
8000a2a
Fixed tests
kurtisassad Nov 25, 2024
a06b9d9
Fixed implementation and finished e2e tests
kurtisassad Nov 25, 2024
294a8da
Merge branch 'master' into ka.testcontainers
kurtisassad Nov 25, 2024
838a5ec
Fixed bugs
kurtisassad Nov 25, 2024
410e304
Fixed tests
kurtisassad Nov 25, 2024
c031fc0
Added db cleanup at beggining of evme2e tests
kurtisassad Nov 25, 2024
2bd3e18
Added tests to CI
kurtisassad Nov 25, 2024
1444ae1
Added trade test
kurtisassad Nov 25, 2024
34c12c7
Added token buy to tests
kurtisassad Nov 26, 2024
755c4ea
Removed test debugging
kurtisassad Nov 26, 2024
09ca21e
Added migration script to update LpBondingCurveAbi
kurtisassad Nov 26, 2024
00b3dae
Merge branch 'refs/heads/master' into ka.testcontainers
kurtisassad Nov 27, 2024
6b39220
Fixed rmq adapter issue
kurtisassad Nov 27, 2024
2890055
Fixed rmq adapter issue
kurtisassad Nov 27, 2024
a8d7ec1
Removed test code
kurtisassad Nov 27, 2024
ffcf282
Increased test timeout
kurtisassad Nov 27, 2024
968b2a0
Fixed race condition in token trade event
kurtisassad Nov 27, 2024
dfd4cba
Merge branch 'master' into ka.testcontainers
kurtisassad Dec 2, 2024
16641bd
Re-added system actor
kurtisassad Dec 2, 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
38 changes: 38 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,44 @@ jobs:
- name: Run EVM Devnet tests
run: pnpm -F commonwealth test-devnet:evm --allowOnly=false


commonwealth-e2e-evm-tests:
name: EVM devnet integration Tests
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
node: [ 22 ]

services:
postgres:
image: hicommonwealth/cw_postgres:latest
env:
POSTGRES_USER: commonwealth
POSTGRES_DB: common_test
POSTGRES_PASSWORD: edgeware
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
redis:
image: redis:latest
ports:
- 6379:6379
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
with:
node-version: ${{ matrix.node }}

- name: Run EVM devnet integration tests
run: pnpm -F commonwealth test-devnet:integration --allowOnly=false

report-coverage:
name: Upload Test Coverage Report
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions libs/core/src/integration/chain-event.schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export const NamespaceDeployed = z.tuple([

export const LaunchpadTokenCreated = z.tuple([
z.string().describe('tokenAddress'),
ETHERS_BIG_NUMBER.describe('totalSupply'),
z.string().describe('name'),
z.string().describe('symbol'),
]);

export const LaunchpadTrade = z.tuple([
Expand Down
2 changes: 1 addition & 1 deletion libs/core/src/integration/events.schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export const ChainEventCreated = z.union([
ChainEventCreatedBase.extend({
eventSource: ChainEventCreatedBase.shape.eventSource.extend({
eventSignature: z.literal(
'0xd7ca5dc2f8c6bb37c3a4de2a81499b25f8ca8bbb3082010244fe747077d0f6cc',
'0xacba89c290ec5301484c0453f480dc9b83ab3a739c6b6e345ecd1b0525787d23',
),
}),
parsedArgs: LaunchpadTokenCreated,
Expand Down
9 changes: 9 additions & 0 deletions libs/evm-protocols/src/common-protocol/chainConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export enum ValidChains {
Optimism = 10,
Mainnet = 1,
Arbitrum = 42161,
Anvil = 31337,
}

export const STAKE_ID = 2;
Expand Down Expand Up @@ -71,4 +72,12 @@ export const factoryContracts = {
communityStake: '0xcc752fd15A7Dd0d5301b6A626316E7211352Cf62',
chainId: 42161,
},
[ValidChains.Anvil]: {
factory: '', //TODO: Fix, this is incorrect
communityStake: 'temp', //TODO: Fix, this is incorrect
launchpad: '0x7a2088a1bfc9d81c55368ae168c2c02570cb814f',
lpBondingCurve: '0xdc17c27ae8be831af07cc38c02930007060020f4',
tokenCommunityManager: '0x84ea74d481ee0a5332c457a4d796187f6ba67feb',
chainId: 31337,
},
} as const satisfies factoryContractsType;
8 changes: 8 additions & 0 deletions libs/evm-protocols/src/event-registry/eventRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,12 @@ export const EventRegistry = {
[factoryContracts[ValidChains.Arbitrum].communityStake]:
communityStakesSource,
},
[ValidChains.Anvil]: {
[factoryContracts[ValidChains.Anvil].factory]: namespaceFactorySource,
[factoryContracts[ValidChains.Anvil].communityStake]: communityStakesSource,
[factoryContracts[ValidChains.Anvil].launchpad]: launchpadSource,
[factoryContracts[ValidChains.Anvil].lpBondingCurve]: lpBondingCurveSource,
[factoryContracts[ValidChains.Anvil].tokenCommunityManager]:
tokenCommunityManagerSource,
},
} as const satisfies EventRegistryType;
2 changes: 1 addition & 1 deletion libs/evm-protocols/src/event-registry/eventSignatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const EvmEventSignatures = {
},
Launchpad: {
TokenLaunched:
'0xd7ca5dc2f8c6bb37c3a4de2a81499b25f8ca8bbb3082010244fe747077d0f6cc',
'0xacba89c290ec5301484c0453f480dc9b83ab3a739c6b6e345ecd1b0525787d23',
Trade: '0x9adcf0ad0cda63c4d50f26a48925cf6405df27d422a39c456b5f03f661c82982',
TokenRegistered:
'0xc2fe88a1a3c1957424571593960b97f158a519d0aa4cef9e13a247c64f1f4c35',
Expand Down
6 changes: 3 additions & 3 deletions libs/model/src/middleware/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,6 @@ async function findAddress(
if (!actor.address)
throw new InvalidActor(actor, 'Must provide an address to authorize');

if (!community_id)
throw new InvalidInput('Must provide a valid community id to authorize');

// Policies as system actors behave like super admins
// TODO: we can check if there is an address to load or fake it
if (actor.is_system_actor) {
Expand All @@ -152,6 +149,9 @@ async function findAddress(
};
}

if (!community_id)
throw new InvalidInput('Must provide a valid community id to authorize');

// Loads and tracks real user's address activity
const address = await models.Address.findOne({
where: {
Expand Down
28 changes: 17 additions & 11 deletions libs/model/src/token/CreateToken.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,23 @@ export function CreateToken(): Command<typeof schemas.CreateToken> {
);
}

const token = await models.Token.create({
token_address: tokenData.parsedArgs.tokenAddress.toLowerCase(),
namespace: tokenData.parsedArgs.namespace,
name: tokenInfo.name,
symbol: tokenInfo.symbol,
initial_supply: Number(tokenInfo.totalSupply / BigInt(1e18)),
liquidity_transferred: false,
launchpad_liquidity: tokenData.parsedArgs.launchpadLiquidity,
eth_market_cap_target: commonProtocol.getTargetMarketCap(),
description: description ?? null,
icon_url: icon_url ?? null,
const [token] = await models.Token.findOrCreate({
where: {
token_address: tokenData.parsedArgs.tokenAddress.toLowerCase(),
namespace: tokenData.parsedArgs.namespace,
},
defaults: {
token_address: tokenData.parsedArgs.tokenAddress.toLowerCase(),
namespace: tokenData.parsedArgs.namespace,
name: tokenInfo.name,
symbol: tokenInfo.symbol,
initial_supply: Number(tokenInfo.totalSupply / BigInt(1e18)),
liquidity_transferred: false,
launchpad_liquidity: tokenData.parsedArgs.launchpadLiquidity,
eth_market_cap_target: commonProtocol.getTargetMarketCap(),
description: description ?? null,
icon_url: icon_url ?? null,
},
});

return token!.toJSON() as unknown as z.infer<typeof TokenView>;
Expand Down
4 changes: 3 additions & 1 deletion packages/commonwealth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"test-api": "NODE_ENV=test vitest --config ../../vite.config.ts --coverage run ./test/integration/api",
"test-devnet:cosmos": "NODE_ENV=test vitest --config ../../vite.config.ts --coverage run ./test/devnet/cosmos",
"test-devnet:evm": "NODE_ENV=test vitest --config ../../vite.config.ts --coverage run ./test/devnet/evm",
"test-devnet:integration": "NODE_ENV=test vitest --config ../../vite.config.ts --coverage run ./test/devnet/integration",
"test-e2e": "NODE_OPTIONS='--import tsx/esm' NODE_ENV=test TEST_ENV=playwright npx playwright test -c ./test/e2e/playwright.config.ts --workers 1 ./test/e2e/e2eRegular/*",
"test-e2e-mature": "NODE_OPTIONS='--import tsx/esm' NODE_ENV=test TEST_ENV=playwright npx playwright test -c ./test/e2e/playwright.config.ts --workers 1 ./test/e2e/mature/*",
"test-e2e-serial": "NODE_OPTIONS='--import tsx/esm' NODE_ENV=test TEST_ENV=playwright npx playwright test --workers 1 ./test/e2e/e2eSerial/*",
Expand Down Expand Up @@ -289,6 +290,7 @@
"@types/passport-auth-token": "^1.0.4",
"@types/sinon": "^17.0.3",
"@types/uuid": "^9.0.7",
"sinon": "^17.0.2"
"sinon": "^17.0.2",
"testcontainers": "^10.14.0"
}
}
Loading
Loading