forked from paritytech/substrate-api-sidecar
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(e2e-tests): add e2e-tests for latest runtimes, and blocks (parit…
…ytech#1155) * test(e2e-tests): outline errors for the process * add correct error code when sidecar fails to build * reorg the tsconfig in e2e tests and where the entry file exists * add endpoints * change yarn script names to historical for init * change request format to return statusCode as well as data * add working script * some cleanup * organize naming * cleanup * fix tiny grumble * add license to file * add script to startup the e2e tests * fix small blunders, and add scripts to package.json * set runE2eTests to runHistoricalE2eTests * add --local to historical e2e tests * get local working, and fix resolving errors * fix is local to fail when a chain is not specified * DRY up code * update docs in scripts * docs in e2e-tests * cleanup * add all statemint end points * make `--local` take in an input * update release notes * add latest to readme * new lint
- Loading branch information
Showing
20 changed files
with
747 additions
and
124 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,36 @@ | ||
## Summary | ||
|
||
This is a helper library for Sidecar to run e2e tests against specific chains, at certain blocks. | ||
This is a helper library to run e2e tests. There are two types of tests to run: | ||
|
||
## Testing | ||
1. Historical: Tests that focus on the integrity of the api service with older runtimes. | ||
|
||
The below instructions are specific to running the e2e-tests against one chain. | ||
If you are looking to run the e2e-tests against all chains (Polkadot, Kusama, Westend, Statemine) then run `yarn test:init-e2e-tests` in | ||
the root directory of sidecar. | ||
2. Latest: Tests that focus on the integrity of the api service with the current runtime, and most recent block. | ||
|
||
### Polkadot | ||
### Historical | ||
|
||
To run the tests against a single chain, you may use the following below. For more examples, reference the `<ROOT>/package.json` | ||
Historical tests use jest to run the api service at specific blocks where the result is known. Jest compares the known result to what we receive, and operates like any other test. It requires having the api service running against a live chain (Archive nodes are preferred). | ||
|
||
`yarn test:init-e2e-tests:polkadot` | ||
To run the tests locally: | ||
|
||
That's it! | ||
All the tests should come back with green checkmarks. If you find a bug file an issue [here](https://github.com/paritytech/substrate-api-sidecar/issues). | ||
```bash | ||
$ yarn build:e2e-tests | ||
$ node ./e2e-tests/build/historical/historical.js --config=./e2e-tests/jest.config.js | ||
``` | ||
|
||
### Config | ||
`--chain`: The chain you would like to test against. It defaults to `polkadot`. | ||
`--config`: The path to the jest config. | ||
|
||
If you are looking to update the e2e-tests config, the file to do so exists in `<ROOT>/scripts/config.ts`. | ||
### Latest | ||
|
||
Latest tests run a set of known endpoints with the latest block against the chain. The tests will pass as long as all the responses are succesfull. If any test is 400 or above it will fail, and log each failed query along with its error. | ||
|
||
To run the tests locally: | ||
|
||
```bash | ||
$ yarn build:e2e-tests | ||
$ node ./e2e-tests/build/latest/index.js | ||
``` | ||
|
||
#### Flags | ||
|
||
`--chain`: The chain you would like to test against. It defaults to `polkadot`. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright 2017-2022 Parity Technologies (UK) Ltd. | ||
// This file is part of Substrate API Sidecar. | ||
// | ||
// Substrate API Sidecar is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
export * from './polkadot'; | ||
export * from './statemint'; |
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,182 @@ | ||
// Copyright 2017-2022 Parity Technologies (UK) Ltd. | ||
// This file is part of Substrate API Sidecar. | ||
// | ||
// Substrate API Sidecar is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
import { IConfig } from '../types/endpoints'; | ||
|
||
export const polkadot: IConfig = { | ||
'/accounts/{accountId}/balance-info': { | ||
path: '/accounts/12xtAYsRUrmbniiWQqJtECiBQrMn8AypQcXhnQAc6RB6XkLW/balance-info', | ||
queryParams: [ | ||
'denominated=true', | ||
'at={blockId}' | ||
], | ||
}, | ||
'/accounts/{accountId}/convert': { | ||
path: '/accounts/0xde1894014026720b9918b1b21b488af8a0d4f15953621233830946ec0b4d7b75/convert', | ||
queryParams: [], | ||
}, | ||
'/accounts/{accountId}/vesting-info': { | ||
path: '/accounts/15aKvwRqGVAwuBMaogtQXhuz9EQqUWsZJSAzomyb5xYwgBXA/vesting-info', | ||
queryParams: [ | ||
'at={blockId}', | ||
], | ||
}, | ||
'/accounts/{accountId}/staking-info': { | ||
path: '/accounts/12BnVhXxGBZXoq9QAkSv9UtVcdBs1k38yNx6sHUJWasTgYrm/staking-info', | ||
queryParams: [ | ||
'at={blockId}' | ||
] | ||
}, | ||
'/accounts/{accountId}/staking-payouts': { | ||
path: '/accounts/12BnVhXxGBZXoq9QAkSv9UtVcdBs1k38yNx6sHUJWasTgYrm/staking-payouts', | ||
queryParams: [ | ||
'at={blockId}', | ||
'unclaimedOnly=false', | ||
], | ||
}, | ||
'/accounts/{accountId}/validate': { | ||
path: '/accounts/DXgXPAT5zWtPHo6FhVvrDdiaDPgCNGxhJAeVBYLtiwW9hAc/validate', | ||
queryParams: [], | ||
}, | ||
'/blocks': { | ||
path: '/blocks?range=1-5', | ||
queryParams: [], | ||
}, | ||
'/blocks/{blockId}': { | ||
path: '/blocks/{blockId}', | ||
queryParams: [ | ||
'eventDocs=true', | ||
'extrinsicDocs=true', | ||
], | ||
}, | ||
'/blocks/{blockId}/header': { | ||
path: '/blocks/{blockId}/header', | ||
queryParams: [], | ||
}, | ||
'/blocks/{blockId}/extrinsics/{extrinsicIndex}': { | ||
path: `/blocks/{blockId}/extrinsics/0`, | ||
queryParams: [ | ||
'eventDocs=true', | ||
'extrinsicDocs=true', | ||
], | ||
}, | ||
'/blocks/head': { | ||
path: `/blocks/head`, | ||
queryParams: [ | ||
'eventDocs=true', | ||
'extrinsicDocs=true', | ||
], | ||
}, | ||
'/blocks/head/header': { | ||
path: '/blocks/head', | ||
queryParams: [], | ||
}, | ||
'/node/network': { | ||
path: '/node/network', | ||
queryParams: [], | ||
}, | ||
'/node/transaction-pool': { | ||
path: '/node/transaction-pool', | ||
queryParams: [ | ||
'includeFee=true', | ||
], | ||
}, | ||
'/node/version': { | ||
path: '/node/version', | ||
queryParams: [], | ||
}, | ||
'/pallets/staking/progress': { | ||
path: '/pallets/staking/progress', | ||
queryParams: [ | ||
'at={blockId}', | ||
], | ||
}, | ||
'/pallets/{palletId}/storage': { | ||
path: '/pallets/System/storage', | ||
queryParams: [ | ||
'onlyIds=true', | ||
'at={blockId}', | ||
], | ||
}, | ||
'/pallets/{palletId}/storage/{storageItemId}': { | ||
path: '/pallets/System/storage/BlockWeight', | ||
queryParams: [ | ||
'metadata=true', | ||
'at={blockId}', | ||
], | ||
}, | ||
'/runtime/metadata': { | ||
path: '/runtime/metadata', | ||
queryParams: [ | ||
'at={blockId}', | ||
], | ||
}, | ||
'/runtime/code': { | ||
path: '/runtime/code', | ||
queryParams: [ | ||
'at={blockId}', | ||
], | ||
}, | ||
'/runtime/spec': { | ||
path: '/runtime/spec', | ||
queryParams: [ | ||
'at={blockId}', | ||
], | ||
}, | ||
'/transaction/material': { | ||
path: '/transaction/material', | ||
queryParams: [ | ||
'noMeta=true', | ||
], | ||
}, | ||
'/paras': { | ||
path: '/paras', | ||
queryParams: [ | ||
'at={blockId}', | ||
], | ||
}, | ||
'/paras/leases/current': { | ||
path: '/paras/leases/current', | ||
queryParams: [ | ||
'at={blockId}', | ||
'currentLeaseHolders=false' | ||
], | ||
}, | ||
'/paras/auctions/current': { | ||
path: '/paras/auctions/current', | ||
queryParams: [ | ||
'at={blockId}', | ||
], | ||
}, | ||
'/paras/crowdloans': { | ||
path: '/paras/crowdloans', | ||
queryParams: [ | ||
'at={blockId}', | ||
], | ||
}, | ||
'/paras/{paraId}/crowdloan-info': { | ||
path: '/paras/2021/crowdloan-info', | ||
queryParams: [ | ||
'at={blockId}', | ||
], | ||
}, | ||
'/paras/{paraId}/lease-info': { | ||
path: '/paras/2021/lease-info', | ||
queryParams: [ | ||
'at={blockId}', | ||
], | ||
} | ||
} |
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,35 @@ | ||
// Copyright 2017-2022 Parity Technologies (UK) Ltd. | ||
// This file is part of Substrate API Sidecar. | ||
// | ||
// Substrate API Sidecar is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
export const statemint = { | ||
'/accounts/{accountId}/asset-balances': { | ||
path: '/accounts/1ULZhwpUPLLg5VRYiq6rBHY8XaShAmBW7kqGBfvHBqrgBcN/asset-balances', | ||
queryParams: [ | ||
'at={blockId}', | ||
'assets[]=100&assets[]=123' | ||
] | ||
}, | ||
'/accounts/{accountId}/asset-approvals': { | ||
path: '/accounts/13zCwRqhAj4D33czsm1G82EgHBNq58CCcWRsbwABaby64p1A/asset-approvals?at={blockId}&assetId=1984&delegate=12jU3Wn96uJgfiAe7Zk9s1vKWDz8SBNnqQ8t7s8kj1hDxMMc', | ||
queryParams: [], | ||
}, | ||
'/pallets/assets/{assetId}/asset-info': { | ||
path: '/pallets/assets/123/asset-info', | ||
queryParams: [ | ||
'at={blockId}' | ||
], | ||
}, | ||
}; |
Oops, something went wrong.