Skip to content

Commit

Permalink
Add more DEX dapp tests (sei-protocol#1809)
Browse files Browse the repository at this point in the history
* draft

* draft

* working protoype

* poc fix

* import

* imports issue

* use fund address

* amount

* expect

* working tests

* put package.json in dapp_tests

* dont commit artifacts

* no build

* run ci

* update package json

* more tests

* working tests

* wasm access

* wasmloc

* fix

* works with other chains

* add workflow

* path
  • Loading branch information
mj850 authored Aug 13, 2024
1 parent a901610 commit 556baab
Show file tree
Hide file tree
Showing 11 changed files with 536 additions and 174 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/dapp_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Run Dapp Tests

# Only runs when manually triggered
on:
workflow_dispatch:

jobs:
run-tests-devnet:
name: Run Tests on Devnet
runs-on: ubuntu-latest
environment:
name: devnet
needs: run-tests-testnet
steps:
- uses: actions/checkout@v3

- name: Run Dapp Tests Script on Devnet
run: |
chmod +x ./integration_test/dapp_tests/dapp_tests.sh
./integration_test/dapp_tests/dapp_tests.sh devnet
run-tests-testnet:
name: Run Tests on Testnet
runs-on: ubuntu-latest
environment:
name: testnet
steps:
- uses: actions/checkout@v3

- name: Run Dapp Tests Script on Testnet
run: |
chmod +x ./integration_test/dapp_tests/dapp_tests.sh
./integration_test/dapp_tests/dapp_tests.sh testnet
2 changes: 1 addition & 1 deletion .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ jobs:
{
name: "dApp Tests",
scripts: [
"./integration_test/dapp_tests/dapp_tests.sh"
"./integration_test/dapp_tests/dapp_tests.sh seilocal"
]
},
]
Expand Down
9 changes: 5 additions & 4 deletions contracts/test/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,15 @@ async function incrementPointerVersion(provider, pointerType, offset) {
}
}

async function createTokenFactoryTokenAndMint(name, amount, recipient) {
const command = `seid tx tokenfactory create-denom ${name} --from ${adminKeyName} --gas=5000000 --fees=1000000usei -y --broadcast-mode block -o json`
async function createTokenFactoryTokenAndMint(name, amount, recipient, from=adminKeyName) {
const command = `seid tx tokenfactory create-denom ${name} --from ${from} --gas=5000000 --fees=1000000usei -y --broadcast-mode block -o json`
const output = await execute(command);
const response = JSON.parse(output)
const token_denom = getEventAttribute(response, "create_denom", "new_token_denom")
const mint_command = `seid tx tokenfactory mint ${amount}${token_denom} --from ${adminKeyName} --gas=5000000 --fees=1000000usei -y --broadcast-mode block -o json`
const mint_command = `seid tx tokenfactory mint ${amount}${token_denom} --from ${from} --gas=5000000 --fees=1000000usei -y --broadcast-mode block -o json`
await execute(mint_command);

const send_command = `seid tx bank send ${adminKeyName} ${recipient} ${amount}${token_denom} --from ${adminKeyName} --gas=5000000 --fees=1000000usei -y --broadcast-mode block -o json`
const send_command = `seid tx bank send ${adminKeyName} ${recipient} ${amount}${token_denom} --from ${from} --gas=5000000 --fees=1000000usei -y --broadcast-mode block -o json`
await execute(send_command);
return token_denom
}
Expand Down Expand Up @@ -469,6 +469,7 @@ module.exports = {
deployErc721PointerForCw721,
registerPointerForERC20,
registerPointerForERC721,
getPointerForNative,
proposeCW20toERC20Upgrade,
importKey,
getNativeAccount,
Expand Down
12 changes: 10 additions & 2 deletions integration_test/dapp_tests/dapp_tests.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/bin/bash

# Check if a configuration argument is passed
if [ -z "$1" ]; then
echo "Please provide a chain (seilocal, devnet, or testnet)."
exit 1
fi

set -e

# Build contacts repo first since we rely on that for lib.js
Expand All @@ -11,5 +17,7 @@ npm ci

npx hardhat compile

npx hardhat test --network seilocal uniswap/uniswapTest.js
npx hardhat test --network seilocal steak/SteakTests.js
# Set the CONFIG environment variable
export DAPP_TEST_ENV=$1
npx hardhat test --network $1 uniswap/uniswapTest.js
npx hardhat test --network $1 steak/SteakTests.js
5 changes: 5 additions & 0 deletions integration_test/dapp_tests/hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,10 @@ module.exports = {
address: ["0xF87A299e6bC7bEba58dbBe5a5Aa21d49bCD16D52", "0x70997970C51812dc3A010C7d01b50e0d17dc79C8"],
accounts: ["0x57acb95d82739866a5c29e40b0aa2590742ae50425b7dd5b5d279a986370189e", "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"],
},
testnet: {
url: "https://evm-rpc-testnet.sei-apis.com",
address: ["0xF87A299e6bC7bEba58dbBe5a5Aa21d49bCD16D52", "0x70997970C51812dc3A010C7d01b50e0d17dc79C8"],
accounts: ["0x57acb95d82739866a5c29e40b0aa2590742ae50425b7dd5b5d279a986370189e", "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"],
},
},
};
23 changes: 22 additions & 1 deletion integration_test/dapp_tests/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion integration_test/dapp_tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
"@uniswap/v3-core": "^1.0.1",
"@uniswap/v3-periphery": "^1.4.4",
"chai": "^4.2.0",
"ethers": "^5.7.2",
"ethers": "^5.7.2"
},
"devDependencies": {
"it-each": "^0.5.0",
"hardhat": "^2.22.6",
"uuid": "^10.0.0"
}
Expand Down
24 changes: 24 additions & 0 deletions integration_test/dapp_tests/uniswap/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const tokenFactoryDenoms = {
"testnet": "factory/sei10xlj95ef20tczjrq5w5ah0vz8t5pxzeza4gaad/dapptest"
}

const cw20Addresses = {
"testnet": {"evm": "0xcD10A4FdeE9CefB7732161f4B20b018bA3F4e7fF", "sei": "sei1d5cs4y0cfdm8dvak4fnmcudqd9htgsnw0djryuvpwhhmyvywypmsxv7vnq"}
}

const rpcUrls = {
"testnet": "https://rpc-testnet.sei-apis.com",
"devnet": "https://rpc-arctic-1.sei-apis.com"
}

const chainIds = {
"testnet": "atlantic-2",
"devnet": "arctic-1"
}

module.exports = {
tokenFactoryDenoms,
cw20Addresses,
rpcUrls,
chainIds
}
Binary file not shown.
Loading

0 comments on commit 556baab

Please sign in to comment.