watcher-ts/packages/test
Nabarun Gogoi b9a899aec1
Implement switching endpoints after slow eth_getLogs RPC requests (#525)
* Switch upstream endpoint if getLogs requests are too slow

* Refactor methods for switching client to indexer

* Update codegen indexer template

* Add dummy methods in graph-node test Indexer

* Upgrade package versions to 0.2.101

---------

Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
2024-06-20 17:57:01 +05:30
..
abis Add test package (#164) 2022-08-19 11:06:11 +05:30
environments Add test package (#164) 2022-08-19 11:06:11 +05:30
src Add a CLI in eden-watcher to fill state for a given range (#176) 2022-09-09 16:23:41 +05:30
.eslintignore Add test package (#164) 2022-08-19 11:06:11 +05:30
.eslintrc.json Upgrade dependency versions to remove vulnerabilities from dependabot (#343) 2023-03-28 13:17:53 +05:30
.mocharc.yml Add test package (#164) 2022-08-19 11:06:11 +05:30
package.json Implement switching endpoints after slow eth_getLogs RPC requests (#525) 2024-06-20 17:57:01 +05:30
README.md Add test package (#164) 2022-08-19 11:06:11 +05:30
tsconfig.json Add test package (#164) 2022-08-19 11:06:11 +05:30

test

Setup

  • Run the following command to install required packages:

    yarn
    

Test Snapshot

  • The snapshot test suite compares results for eth-calls and getStorageAt calls to the provided endpoints.

  • Contracts considered:

    • UniswapV2 Factory
    • UniswapV2 Pair
    • USDC
    • Compound
    • Dai / Maker
  • Edit the config file:

    Eg:

    blockTag = "0xB5FFFF" # block tag to perform eth-call and getStorageAt call with (eg. block number in hex)
    
    [endpoints]
      endpoint1 = "http://127.0.0.1:8545" # endpoint1 URL
      endpoint2 = "http://127.0.0.1:8082" # endpoint2 URL
    
  • Run the following command to run the snapshot test suite:

    yarn test:snapshot
    

Individual Calls

  • Run the following to make an eth-call:

    yarn eth-call -e <endpoint> -c <contract> -a <abi> -m <method-name> --method-args [method-args] -b [block-tag]
    
    • endpoint (e): Endpoint to perform eth-call against

    • contract (c): Contract address

    • abi (a): Contract ABI path

    • method-name (m): Contract method to call

    • method-args: Contract method arguments

    • block-tag (b): Block tag to make eth-call with (block number (hex) / block hash)

      Eg.

      yarn eth-call -e http://127.0.0.1:8545 -c 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f -a abis/UniswapV2Factory.json -m allPairs --method-args 100 -b 0xB5FFFF
      
  • Run the following to make a getStorageAt call:

    yarn get-storage-at -e <endpoint> -c <contract> -s <slot> -b [block-tag]
    
    • endpoint (e): Endpoint to perform getStorageAt call against

    • contract (c): Contract address

    • slot (s): Storge slot

    • block-tag (b): Block tag to make getStorageAt call with (block number (hex) / block hash)

      Eg.

      yarn get-storage-at -e http://127.0.0.1:8545 -c 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f -s 0x1 -b 0xB5FFFF