BuidlGuidl / abi.ninja

Interact with any contract on Ethereum.
https://abi.ninja
MIT License
179 stars 69 forks source link

Sample basic test example contracts #137

Closed technophile-04 closed 1 month ago

technophile-04 commented 1 month ago

Description

I think it will nice to have a document / or maybe comment on this issue with list of contract address from different chains which we can use for testing PR's.

I usually do this:

portdeveloper commented 1 month ago

proxy something on base: 0xca808b3eada02d53073e129b25f74b31d8647ae0

unverif on sepolia eth: 0x759c0e9d7858566df8ab751026bedce462ff42df

bnb chain verified: 0x79eE0771dCa47a68a19053DfDd5eEb84FDcfB650

parex chain details: chainId: 322202 rpc: https://mainnet-rpc.parex.network
verified contract: 0x6058518142C6AD506530F5A62dCc58050bf6fC28 block explorer: https://scan.parex.network/

link to test for parex:

http://localhost:3000/0x6058518142C6AD506530F5A62dCc58050bf6fC28/322202

These are how I currently test if something is working or not.

carletex commented 1 month ago

having some functional automated testing for this would be amazing too :P

portdeveloper commented 1 month ago

@carletex

https://github.com/user-attachments/assets/24d530cf-4503-49d0-962a-49d3db553524

I was playing around with cypress and it works fine! But we may try playwright as well.

technophile-04 commented 1 month ago

This is really cool @portdeveloper!!!! and will make our testing sooo easy!! Could create an PR? I am not well versed with testing at all, so excited to learn!

I was playing around with cypress and it works fine! But we may try playwright as well.

Reading couple of articles, I think cypress could be just perfect for us it works in CI we also have very basic poc working.

Both playwright and cypress has their pros and cons, but playwright pros seems a bit overpowered and not that needed for us. So lets go with cypress for now 🙌

Also just want to throw out here that we were also planning to add some test to SE-2 just in CI, so this learnings will also help us their!

carletex commented 1 month ago

you are on :fire: @portdeveloper nothing can't stop you now :P Great stuff.

Cypress is really cool (I've never used playwright tho).


So the idea would be to our CI (when PRing to main) to run cypress with the test, right? I guess we should spin up a local CI abi ninja instance an running it there (we'd need some secrets for the envvars). Not sure if it'd be possible to run it on the Vercel preview (which might have less config overhead for us)

portdeveloper commented 1 month ago

@carletex The changes that implement a CI workflow that trigger on push and pr are ready at https://github.com/portdeveloper/abi.ninja.

However, the tests are not perfect. I had to use cy.wait() at multiple places to ensure we wait for things to appear and sometimes, for heimdall-rs backend to boot up.

Here is an example PR that has a cypress e2e CI workflow: https://github.com/portdeveloper/abi.ninja/pull/3

Maybe what we could do here is to open some PRs over the weekend to ensure everything is working smoothly and on Tuesday or Wednesday, we merge this to main.

technophile-04 commented 1 month ago

TYSM Port !!

However, the tests are not perfect. I had to use cy.wait() at multiple places to ensure we wait for things to appear and sometimes, for heimdall-rs backend to boot up.

I think its fine? we could always iterate over it to find better solution also it won't affect the prod so maybe lets try it out

portdeveloper commented 1 month ago

Yes! Test in prod is the best. Maybe we could do a call to heimdall to boot it up before the tests to eliminate one of those waits.