-
Notifications
You must be signed in to change notification settings - Fork 362
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Coin-tester tool engine + EVM coin-tester (#6530)
* coin-tester engine * coin-tester script * coin-evm coin-tester implementation * lockfile * defaultNanoApp * lockfile * scenario before/afterall * add assertions on ethereum transactions * add expects in polygon test * remove unused dependencies * upgrade docker-compose config versions * extract initAccount functions * lockfile * fix clearInterval type * signers folder * docker.ts -> anvil.ts * use docker 2.4 * use initAccount in ethereum transactions * polygon expects * nft expects * improve transactions expects * add logs * polygon expects * impersonate account helper function * clean * fix synchronization tests * timeout * simpler ethereum nft expects * lockfile * beforeAll * Move `impersonateAccount` to coin-evm test helpers * Unify Ethereum & Polygon scenarii * api node test * Remove coin-tester "test" script --------- Co-authored-by: 0xkvn <[email protected]>
- Loading branch information
1 parent
434262d
commit a27a64e
Showing
31 changed files
with
2,864 additions
and
1,123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ node_modules | |
.eslintcache | ||
tsconfig.tsbuildinfo | ||
rce | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
libs/coin-modules/coin-evm/src/__tests__/coin-tester/.env.example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# https://iancoleman.io/bip39/ | ||
SEED=your 12/15/24 words | ||
# has to be a token classic | ||
GH_TOKEN=gh_p | ||
API_PORT=4040 | ||
# Only needed if you are on a apple chip | ||
SPECULOS_IMAGE=speculos |
55 changes: 55 additions & 0 deletions
55
libs/coin-modules/coin-evm/src/__tests__/coin-tester/anvil.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { v2 as compose } from "docker-compose"; | ||
import chalk from "chalk"; | ||
import { killSpeculos } from "@ledgerhq/coin-tester/lib/signers/speculos"; | ||
|
||
const cwd = __dirname; | ||
|
||
const delay = (timing: number): Promise<void> => | ||
new Promise(resolve => setTimeout(resolve, timing)); | ||
|
||
export const spawnAnvil = async (rpc: string): Promise<void> => { | ||
console.log("Starting anvil..."); | ||
await compose.upOne("anvil", { | ||
cwd, | ||
log: true, | ||
env: { | ||
...process.env, | ||
RPC: rpc, | ||
}, | ||
}); | ||
|
||
const checkAnvilLogs = async (): Promise<void> => { | ||
const { out } = await compose.logs("anvil", { | ||
cwd, | ||
env: { | ||
...process.env, | ||
RPC: rpc, | ||
}, | ||
}); | ||
|
||
if (out.includes("Listening on 0.0.0.0:")) { | ||
console.log(chalk.bgBlueBright(" - ANVIL READY ✅ - ")); | ||
return; | ||
} | ||
|
||
await delay(200); | ||
return checkAnvilLogs(); | ||
}; | ||
|
||
await checkAnvilLogs(); | ||
}; | ||
|
||
export const killAnvil = async (): Promise<void> => { | ||
console.log("Stopping anvil..."); | ||
await compose.down({ | ||
cwd, | ||
log: true, | ||
env: process.env, | ||
}); | ||
}; | ||
|
||
["exit", "SIGINT", "SIGQUIT", "SIGTERM", "SIGUSR1", "SIGUSR2", "uncaughtException"].map(e => | ||
process.on(e, async () => { | ||
await Promise.all([killAnvil(), killSpeculos()]); | ||
}), | ||
); |
9 changes: 9 additions & 0 deletions
9
libs/coin-modules/coin-evm/src/__tests__/coin-tester/docker-compose.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
version: '2.4' | ||
|
||
services: | ||
anvil: | ||
image: ghcr.io/foundry-rs/foundry:latest | ||
container_name: anvil | ||
ports: | ||
- "8545:8545" | ||
command: -c "anvil --host 0.0.0.0 --fork-url ${RPC} --no-storage-caching --steps-tracing --mnemonic='${SEED}'" |
43 changes: 43 additions & 0 deletions
43
libs/coin-modules/coin-evm/src/__tests__/coin-tester/helpers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { ethers } from "ethers"; | ||
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies"; | ||
import { getTokenById } from "@ledgerhq/cryptoassets/tokens"; | ||
import ERC20ABI from "../../abis/erc20.abi.json"; | ||
import ERC721ABI from "../../abis/erc721.abi.json"; | ||
import ERC1155ABI from "../../abis/erc1155.abi.json"; | ||
|
||
export const ethereum = getCryptoCurrencyById("ethereum"); | ||
export const polygon = getCryptoCurrencyById("polygon"); | ||
export const ERC20Interface = new ethers.utils.Interface(ERC20ABI); | ||
export const ERC721Interface = new ethers.utils.Interface(ERC721ABI); | ||
export const ERC1155Interface = new ethers.utils.Interface(ERC1155ABI); | ||
export const USDC_ON_ETHEREUM = getTokenById("ethereum/erc20/usd__coin"); | ||
export const USDC_ON_POLYGON = getTokenById("polygon/erc20/usd_coin_(pos)"); | ||
|
||
export const impersonnateAccount = async ({ | ||
provider, | ||
addressToImpersonnate, | ||
to, | ||
data, | ||
}: { | ||
provider: ethers.providers.JsonRpcProvider; | ||
addressToImpersonnate: string; | ||
to: string; | ||
data: string; | ||
}) => { | ||
await provider.send("anvil_impersonateAccount", [addressToImpersonnate]); | ||
const impersonatedAccount = { | ||
from: addressToImpersonnate, | ||
to, | ||
data, | ||
value: ethers.BigNumber.from(0).toHexString(), | ||
gas: ethers.BigNumber.from(1_000_000).toHexString(), | ||
type: "0x0", | ||
gasPrice: (await provider.getGasPrice()).toHexString(), | ||
nonce: "0x" + (await provider.getTransactionCount(addressToImpersonnate)).toString(16), | ||
chainId: "0x" + (await provider.getNetwork()).chainId.toString(16), | ||
}; | ||
|
||
const hash = await provider.send("eth_sendTransaction", [impersonatedAccount]); | ||
await provider.send("anvil_stopImpersonatingAccount", [addressToImpersonnate]); | ||
await provider.waitForTransaction(hash); | ||
}; |
Oops, something went wrong.
a27a64e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Bot] Evm on Staging 💰 3 miss funds ($0.00) ⏲ 15.8s
Please increase the account target to at least 4 accounts
Please increase the account target to at least 4 accounts
Details of the 0 mutations
Spec Ethereum (failed)
Spec Ethereum Sepolia (10)
Spec Ethereum Holesky (failed)
Details of the 9 uncovered mutations
Spec Ethereum (3)
Spec Ethereum Sepolia (3)
Spec Ethereum Holesky (3)
Portfolio ($0.00) – Details of the 3 currencies
0x8a6Af0dD602db0A78EaD07cE9e2595815383FD5D
0x8a6Af0dD602db0A78EaD07cE9e2595815383FD5D
0x8a6Af0dD602db0A78EaD07cE9e2595815383FD5D
Performance ⏲ 15.8s
Time spent for each spec: (total across mutations)
a27a64e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Bot] Bitcoin on Staging ✅ 6 txs ❌ 1 txs 💰 3 miss funds ($13.09) ⏲ 2min 37s
12 critical spec errors
Spec Bitcoin failed!
Spec Bitcoin Cash failed!
Spec Dash failed!
Spec Digibyte failed!
Spec DogeCoin failed!
Spec Komodo failed!
Spec Litecoin failed!
Spec Peercoin failed!
Spec PivX failed!
Spec Vertcoin failed!
Spec Viacoin failed!
Spec Decred failed!
❌ 1 mutation errors
Please increase the account target to at least 6 accounts
Please increase the account target to at least 6 accounts
Details of the 7 mutations
Spec Bitcoin (failed)
Spec Bitcoin Testnet (11)
Spec Bitcoin Cash (failed)
Spec Bitcoin Gold (6)
Spec Dash (failed)
Spec Digibyte (failed)
Spec DogeCoin (failed)
Spec Komodo (failed)
Spec Litecoin (failed)
Spec Peercoin (failed)
Spec PivX (failed)
Spec Qtum (6)
Spec Vertcoin (failed)
Spec Viacoin (failed)
Spec ZCash (5)
Spec Horizen (5)
Spec Decred (failed)
Details of the 78 uncovered mutations
Spec Bitcoin (5)
Spec Bitcoin Testnet (5)
Spec Bitcoin Cash (5)
Spec Bitcoin Gold (2)
Spec Dash (5)
Spec Digibyte (5)
Spec DogeCoin (5)
Spec Komodo (5)
Spec Litecoin (5)
Spec Peercoin (5)
Spec PivX (5)
Spec Qtum (5)
Spec Vertcoin (5)
Spec Viacoin (5)
Spec ZCash (5)
Spec Horizen (1)
Spec Decred (5)
Portfolio ($13.09) – Details of the 17 currencies
tb1qufuqle89w3z4mvzrht4wf7a8ppl3tzuaxp722u
ANTNNyHDm1AkCyStmrgu97LX9GoyJU8Rnv
MVYo3tWmufMkw8y12XoyFbx4dSyKYt5p94
t1W1vCEVTr16Tw1J6qV9M89dUbrfRsNUwAH
znjx2z5fyDBKygDt8RmaVtFDrmd7oJQ4jYB
Performance ⏲ 2min 37s
Time spent for each spec: (total across mutations)
a27a64e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Bot] Daily non-reg on develop with 'Nitrogen' ✅ 165 txs ❌ 19 txs 💰 8 miss funds ($1,322.16) ⏲ 33min 11s
3 critical spec errors
Spec injective failed!
Spec Solana failed!
Spec Polygon zkEVM Testnet failed!
❌ 19 mutation errors
Please increase the account target to at least 8 accounts
Please increase the account target to at least 6 accounts
Please increase the account target to at least 6 accounts
Please increase the account target to at least 6 accounts
Please increase the account target to at least 6 accounts
Please increase the account target to at least 6 accounts
Please increase the account target to at least 4 accounts
Please increase the account target to at least 4 accounts
Portfolio ($1,322.16) – Details of the 67 currencies
02026B93627Ed2F76551E7CeF0466468B12db8Fab806266107b69947D9c95CEd9E7c
0x246FFDB387F1F8c48072E1C13443540017bC71b7
osmo1rs97j43nfyvc689y5rjvnnhrq3tes6ghn8m44l
desmos1rs97j43nfyvc689y5rjvnnhrq3tes6gh0y9454
dydx1rs97j43nfyvc689y5rjvnnhrq3tes6ghj9xpr6
umee1rs97j43nfyvc689y5rjvnnhrq3tes6ghf2468l
persistence1rs97j43nfyvc689y5rjvnnhrq3tes6gh4swkdf
quick1rs97j43nfyvc689y5rjvnnhrq3tes6ghscch6l
onomy1rs97j43nfyvc689y5rjvnnhrq3tes6ghpaunjg
sei1rs97j43nfyvc689y5rjvnnhrq3tes6ghksen9v
stars1rs97j43nfyvc689y5rjvnnhrq3tes6gh0qlcgu
core1rs97j43nfyvc689y5rjvnnhrq3tes6ghgjs7yk
cro14zpaxs3msrdnx5ch3m3y3yue0wwwevrf2hmwra
erd18n5sk95fq9dtgdsa9m9q5ddp66ch9cq5lpjflwn5j9z8x2e9h0qqrvk5qp
0.0.3663977
f2ed4c9253d3aca7d679bfa9f528d13e85c7f522b8857e094c850a157b750209
r9etPtq3oboweMPju5gdYufmvwhH2euz8z
SP2J4VHFRAT94KY6NFT6129HBA382S6R98W9ABFG2
GDJPZPOWITPCBX3TIHB6N7E4WCHS6JBZKSNWGU34QYCJXKWBTUZY5RYC
tz1aDK1uFAmnUXZ7KJPEmcCEFeYHiVZ56zVF
0xc4B17901FECf86932c3bb296BB00E7c6816Fd416
0xc4B17901FECf86932c3bb296BB00E7c6816Fd416
TM4WJOS4MZ2TD775W7GSXZMBUF74YT6SKSBXCZY3N7OUIAPXE54MZ5FCD4
tb1qhuate7antla8zjv3x5kdcsuwk4tqgae4x4r3gw
qq98cxz489welufjr9zaha5gtlal5t3xau5eq7ch9z
AHDk2qcRS91TBnSmerqo3EvkXkPG4Drhv7
Xthr4G5Bh4CakEzFZniRhBWyvwSHhk2D5d
dgb1q3x8mq5sd2glk05nffvcxjdcw9tl62unljrd4vp
DTjV5D5meeZhep2LuJ5rvTnqDauGYjqcaD
RMBswLjzvWgrm5weWqEoaYYkGNNQPi12vG
ltc1qpvxjd95mgw7h0f8xhy58cvet3lu32qdgmt56lg
PCJwkHpZdYsmvnJn83aobNm3YX2zA5vAdg
DDdumK92U7gphTnRsJrDkvRo7L4dRTsdqw
336D8FJKPAWxG8XkwkUfaBziPNL381Lqzh
ELztJThibtCTsHRDXtERMx6BZE5gggwYqA
t1SDpcaNZmbCH5TCCb5vNAh5bXs3isDtA5h
znSZMMEdgQZaHWK7tLkMqi6DG7KSP1XrxHE
0x7584df0780C5eB83b26aE55abBc265014f8bf897
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0xe404f128644459C5A0F6FAc6824AdA8F94798c8f
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0573d7a9c745fa9fe224b080832aa93d740760b94f192c9c141c709945e9aaaf
Performance ⏲ 33min 11s
Time spent for each spec: (total across mutations)
a27a64e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Bot] Weekly non-reg on develop with 'Oxygen' ✅ 31 txs ❌ 5 txs 💰 2 miss funds ($484.83) ⏲ 12min 29s
2 critical spec errors
Spec secret_network failed!
Spec Polkadot failed!
❌ 5 mutation errors
Please increase the account target to at least 7 accounts
Please increase the account target to at least 6 accounts
Please increase the account target to at least 4 accounts
Details of the 36 mutations
Spec cardano (5)
Spec axelar (15)
Spec cosmos (11)
Spec secret_network (failed)
Spec Filecoin (13)
Spec Tron (6)
Spec Qtum (6)
Spec Decred (5)
Spec Avalanche C-Chain (10)
Spec Binance Smart Chain (10)
Spec Cronos (6)
Spec Fantom (6)
Spec Boba (failed)
Spec Telos (5)
Spec Polygon zkEVM (5)
Spec Polkadot (failed)
Details of the 34 uncovered mutations
Spec cardano (2)
Spec axelar (2)
Spec cosmos (3)
Spec secret_network (6)
Spec Filecoin (1)
Spec Qtum (1)
Spec Decred (2)
Spec Binance Smart Chain (1)
Spec Cronos (3)
Spec Fantom (1)
Spec Boba (3)
Spec Telos (1)
Spec Polygon zkEVM (1)
Spec Polkadot (7)
Portfolio ($484.83) – Details of the 16 currencies
addr1q8udfky8pcz2mkyq9rgfnj2ks8hu59um3qzkscayklu4ye8gyf2nkgrrlvjz49cn9cqr4el6y74l85d0z3jfj75gmamqzwtvc4
axelar123r3dwfylykx0fugawn6mu2h2smq3047pn5n9g
cosmos123r3dwfylykx0fugawn6mu2h2smq30479azmwf
f1a57ukatezm5aiuahhdrip3eyf7hzoj73u3ieyrq
TT2eHJXo5tRV2wYyZExr9W18mXghe6NFM1
M955teSFh5KAwwnSNhu4w25idt24t1nSQV
DsUHtmXM1kBvg7zNpGrCzm6BExKA27Q41Nw
0x731477De13B323A0cA90C1FE194EA5A0412937c2
0x731477De13B323A0cA90C1FE194EA5A0412937c2
0x731477De13B323A0cA90C1FE194EA5A0412937c2
0x731477De13B323A0cA90C1FE194EA5A0412937c2
0x731477De13B323A0cA90C1FE194EA5A0412937c2
0x731477De13B323A0cA90C1FE194EA5A0412937c2
0x731477De13B323A0cA90C1FE194EA5A0412937c2
Performance ⏲ 12min 29s
Time spent for each spec: (total across mutations)