mirror of
https://github.com/cerc-io/watcher-ts
synced 2025-01-22 02:59:06 +00:00
Test decoder using hardhat RPC, geth-statediff RPC and ipld-eth-server GQL endpoints for fetching storage slots (#77)
* Implement test for getStorageValue with geth server. * Wait for transaction to complete in tests. * Implement tests with ipld-eth-client using graphql endpoint. Co-authored-by: nikugogoi <95nikass@gmail.com>
This commit is contained in:
parent
6a33c704b8
commit
c9bf002675
3
packages/solidity-mapper/.env.example
Normal file
3
packages/solidity-mapper/.env.example
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
ETH_RPC_URL=http://127.0.0.1:8545
|
||||||
|
|
||||||
|
GQL_ENDPOINT=http://127.0.0.1:8083/graphql
|
3
packages/solidity-mapper/.gitignore
vendored
3
packages/solidity-mapper/.gitignore
vendored
@ -6,3 +6,6 @@ artifacts
|
|||||||
|
|
||||||
#yarn
|
#yarn
|
||||||
yarn-error.log
|
yarn-error.log
|
||||||
|
|
||||||
|
#Environment variables
|
||||||
|
.env
|
||||||
|
@ -10,10 +10,23 @@ Get value of state variable from storage for a solidity contract.
|
|||||||
|
|
||||||
## Instructions
|
## Instructions
|
||||||
|
|
||||||
Run the tests using the following command
|
* Create environment variable file
|
||||||
```bash
|
```bash
|
||||||
$ yarn test
|
$ cp .env.example .env
|
||||||
```
|
```
|
||||||
|
|
||||||
|
* Run the tests using the following command
|
||||||
|
```bash
|
||||||
|
$ yarn test
|
||||||
|
|
||||||
|
# For testing on private network using RPC getStorageAt.
|
||||||
|
# Set ETH_RPC_URL in .env
|
||||||
|
$ yarn test:geth-rpc
|
||||||
|
|
||||||
|
# For testing on private network using ipld-eth-client getStorageAt.
|
||||||
|
# Set GQL_ENDPOINT in .env
|
||||||
|
$ yarn test:ipld-gql
|
||||||
|
```
|
||||||
|
|
||||||
## Different Types
|
## Different Types
|
||||||
|
|
||||||
@ -26,7 +39,7 @@ $ yarn test
|
|||||||
* [x] Fixed-size byte arrays
|
* [x] Fixed-size byte arrays
|
||||||
* [x] Enums
|
* [x] Enums
|
||||||
* [ ] Function Types
|
* [ ] Function Types
|
||||||
* [x] Reference Types
|
* [ ] Reference Types
|
||||||
* [x] Arrays
|
* [x] Arrays
|
||||||
* [x] Get all elements in array
|
* [x] Get all elements in array
|
||||||
* [x] Get element in array by index
|
* [x] Get element in array by index
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import 'dotenv/config';
|
||||||
import { task, HardhatUserConfig } from 'hardhat/config';
|
import { task, HardhatUserConfig } from 'hardhat/config';
|
||||||
import '@nomiclabs/hardhat-waffle';
|
import '@nomiclabs/hardhat-waffle';
|
||||||
|
|
||||||
@ -35,6 +36,14 @@ const config: HardhatUserConfig = {
|
|||||||
paths: {
|
paths: {
|
||||||
sources: './test/contracts',
|
sources: './test/contracts',
|
||||||
tests: './src'
|
tests: './src'
|
||||||
|
},
|
||||||
|
networks: {
|
||||||
|
private: {
|
||||||
|
url: process.env.ETH_RPC_URL
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mocha: {
|
||||||
|
timeout: 50000
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
"@types/mocha": "^8.2.2",
|
"@types/mocha": "^8.2.2",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.25.0",
|
"@typescript-eslint/eslint-plugin": "^4.25.0",
|
||||||
"@typescript-eslint/parser": "^4.25.0",
|
"@typescript-eslint/parser": "^4.25.0",
|
||||||
|
"@vulcanize/ipld-eth-client": "^0.1.0",
|
||||||
"chai": "^4.3.4",
|
"chai": "^4.3.4",
|
||||||
"eslint": "^7.27.0",
|
"eslint": "^7.27.0",
|
||||||
"eslint-config-semistandard": "^15.0.1",
|
"eslint-config-semistandard": "^15.0.1",
|
||||||
@ -29,7 +30,11 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"test": "hardhat test",
|
"test": "hardhat test",
|
||||||
|
"test:geth-rpc": "hardhat --network private test",
|
||||||
|
"test:ipld-gql": "IPLD_GQL=true hardhat --network private test",
|
||||||
"lint": "eslint ."
|
"lint": "eslint ."
|
||||||
},
|
},
|
||||||
"dependencies": {}
|
"dependencies": {
|
||||||
|
"dotenv": "^10.0.0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
|
import '@nomiclabs/hardhat-ethers';
|
||||||
import { artifacts, ethers } from 'hardhat';
|
import { artifacts, ethers } from 'hardhat';
|
||||||
|
|
||||||
import { getEventNameTopics } from './logs';
|
import { getEventNameTopics } from './logs';
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,5 @@
|
|||||||
import { ContractInterface } from '@ethersproject/contracts';
|
import { ContractInterface } from '@ethersproject/contracts';
|
||||||
|
import '@nomiclabs/hardhat-ethers';
|
||||||
import { artifacts, ethers } from 'hardhat';
|
import { artifacts, ethers } from 'hardhat';
|
||||||
import { CompilerOutput, CompilerOutputBytecode } from 'hardhat/types';
|
import { CompilerOutput, CompilerOutputBytecode } from 'hardhat/types';
|
||||||
|
|
||||||
@ -68,3 +69,13 @@ export const getStorageAt: GetStorageAt = async ({ blockHash, contract, slot })
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate array of dummy addresses of specified length.
|
||||||
|
* @param length
|
||||||
|
*/
|
||||||
|
export const generateDummyAddresses = (length: number): Array<string> => {
|
||||||
|
return Array.from({ length }, () => {
|
||||||
|
return ethers.utils.hexlify(ethers.utils.randomBytes(20));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
@ -5229,6 +5229,11 @@ dot-prop@^6.0.1:
|
|||||||
dependencies:
|
dependencies:
|
||||||
is-obj "^2.0.0"
|
is-obj "^2.0.0"
|
||||||
|
|
||||||
|
dotenv@^10.0.0:
|
||||||
|
version "10.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-10.0.0.tgz#3d4227b8fb95f81096cdd2b66653fb2c7085ba81"
|
||||||
|
integrity sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==
|
||||||
|
|
||||||
dotenv@^8.2.0:
|
dotenv@^8.2.0:
|
||||||
version "8.6.0"
|
version "8.6.0"
|
||||||
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.6.0.tgz#061af664d19f7f4d8fc6e4ff9b584ce237adcb8b"
|
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.6.0.tgz#061af664d19f7f4d8fc6e4ff9b584ce237adcb8b"
|
||||||
|
Loading…
Reference in New Issue
Block a user