-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added flextesa script only for drain-delegate and ballot ops (#2861)
* added flextesa script only for drain-delegate and ballot ops * changed flextesa from oxfordnet to nairobinet * update script * remove 1 test * adjusted script * added extra config * updated sandbox-env.sh file * added script to run test * added drain-delegate test * fixed test name in test script * addressed PR comments * removed tezos network type * updated rpc * reverted rpc
- Loading branch information
Showing
6 changed files
with
87 additions
and
273 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,210 +102,11 @@ To review the graphical report of the test run, open the index.html file in ~/ta | |
|
||
## Taquito Integration Tests with Flextesa | ||
|
||
:::warning | ||
Due to the discontinuation of Flextesa support from Protocol Oxford onwards, we unfortunately will not be testing against sandboxes anymore. | ||
|
||
> **Be sure to use a working NVM! such as lts/gallium or lts/hydrogen** | ||
> The recommended method to run tests is against testnets, not sandboxes. Running all tests against a sandbox can fail randomly, while individual tests usually pass. | ||
|
||
To prepare to run the integration tests against a local sandbox, perform the following steps: | ||
|
||
|
||
### 1. Set environment variables | ||
|
||
|
||
Execute | ||
|
||
|
||
```bash | ||
source integration-tests/sandbox-env.sh | ||
``` | ||
|
||
|
||
from the top level. This will export the following environment variables: | ||
|
||
|
||
```sh | ||
TEZOS_NETWORK_TYPE=sandbox | ||
RUN_OXFORDNET_WITH_SECRET_KEY=true | ||
SECRET_KEY=edsk3RFgDiCt7tWB2oe96w1eRw72iYiiqZPLu9nnEY23MYRp2d8Kkx | ||
TEZOS_RPC_OXFORDNET=http://localhost:20000 | ||
POLLING_INTERVAL_MILLISECONDS=100 | ||
RPC_CACHE_MILLISECONDS=0 | ||
TEZOS_BAKER=tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb | ||
``` | ||
|
||
|
||
### 2. Start a Flextesa sandbox to run a local Oxford testnet | ||
|
||
|
||
Start the docker container, which encapsulates the flextesa_sandbox: | ||
|
||
|
||
```sh | ||
docker run --rm --name flextesa_sandbox --detach -p 20000:20000 oxheadalpha/flextesa:latest oxfordbox start | ||
``` | ||
|
||
|
||
The default block time is 5 seconds. If we want to simulate Oxford block times, we could use | ||
|
||
|
||
```sh | ||
docker run --rm --name flextesa_sandbox --detach -e block_time=8 -p 20000:20000 oxheadalpha/flextesa:latest oxfordbox start | ||
``` | ||
|
||
|
||
The idea behind Flextesa is to be able to use block times of 1 second. However, the tests as presently written do not always support that rate. | ||
|
||
|
||
Flextesa is the "Flexible Tezos Sandbox" and effectively enables you to run a local emulation of the blockchain. Please find [more information about Flextesa here](https://tezos.gitlab.io/flextesa/). Several options are available for controlling block timings. | ||
|
||
|
||
### 3. Run the integration tests | ||
*Note: It is no longer necessary to `cd` into the `integration-tests/` directory* | ||
|
||
|
||
To run the integration tests, use the command `npm run integration-tests`. The integration test suite will execute all tests against the current Tezos protocol (Oxford) sandbox and typically also against the previous and next protocol testnets. You can find specific test targets in the `scripts` property in the `integration-tests/package.json` file. | ||
|
||
|
||
Remember that the first time you run the integration tests, `docker` will download the required image, which might take some time. | ||
|
||
|
||
Before running the tests, make sure the file `~/taquito/integration-tests/known-contracts-ProxfordY.ts` includes the following: | ||
|
||
|
||
```bash | ||
export const knownContractProxfordY = "KT1GrzF7DSNc7LrLmS7RNaLrBQqyYHyoMzwR"; | ||
export const knownBigMapContractProxfordY = "KT1Twd6GBBqHEFhzvBDEn4JiUopttq2WjdnF"; | ||
export const knownTzip12BigMapOffChainContractProxfordY = "KT1WZUqEKZ4TMW75FKpqod4HwB4ts7wbnsFh"; | ||
export const knownSaplingContractProxfordY = "KT1VNnD8NWx9ep2gxsHbzrmahrWsKpZb3xGY"; | ||
export const knownOnChainViewContractAddressProxfordY = "KT19eNryXTuVgH6s6cUc1a5LyjSamdBw4JXo"; | ||
``` | ||
|
||
|
||
These contracts will be originated when the tests are first run, but the file will be emptied afterward. You'll need to repopulate it if you want to rerun the tests. | ||
|
||
|
||
Next, set the required environment variables for the Flextesa run: | ||
|
||
|
||
```bash | ||
source integration-tests/sandbox-env.sh | ||
``` | ||
|
||
|
||
When running Flextesa tests, you must pass the Jest config `--runInBand`, as they only have one baking account, and tests must run sequentially. | ||
|
||
|
||
```bash | ||
npm -w integration-tests run test:originate-known-contracts && npm -w integration-tests run test:oxfordnet-secret-key --runInBand | ||
``` | ||
|
||
|
||
If you're running the tests for a second time in the same session, you don't need to originate the test contracts again. Instead, use the following: | ||
|
||
|
||
```bash | ||
npm -w --runInBand integration-tests run test:oxfordnet-secret-key | ||
``` | ||
|
||
|
||
Some tests might fail due to test data discrepancies, such as changes in RPC endpoints or estimated gas costs from one protocol to another. You can skip these tests using the following: | ||
|
||
|
||
```bash | ||
npm -w integration-tests run test:oxfordnet-secret-key -- --runInBand --testPathIgnorePatterns='ledger-signer-failing-tests.spec.ts|ledger-signer.spec.ts|contract-estimation-tests.spec.ts|rpc-get-protocol-constants.spec.ts|' | ||
``` | ||
|
||
|
||
You can also avoid slow-running tests. For example, if you want not to run the `sapling*.spec.ts` tests, run: | ||
|
||
|
||
```bash | ||
npm -w integration-tests run test:oxfordnet-secret-key -- --runInBand --testPathIgnorePatterns='ledger-signer-failing-tests.spec.ts|ledger-signer.spec.ts|contract-estimation-tests.spec.ts|rpc-get-protocol-constants.spec.ts|sapling-batched-transactions.spec.ts| sapling-transactions-contract-with-multiple-sapling-states.spec.ts|sapling-transactions-contract-with-single-state.spec.ts|sapling-transactions-proof-using-proving-key.spec.ts' | ||
``` | ||
|
||
|
||
Upon successfully starting the tests with contract origination, you should see the following output: | ||
|
||
|
||
```bash | ||
[email protected] test:originate-known-contracts | ||
node -r ts-node/register originate-known-contracts.ts | ||
ProxfordYmVfjWnRcgjWH36fW6PArwqykTFzotUxRs6gmTcZDuH | ||
knownContract address: KT1CX4Qbkfy4N9fgRD5L7RPZW9ByydfKxh5t | ||
::set-output name=knownContractAddress::KT1CX4Qbkfy4N9fgRD5L7RPZW9Byv2ycodEBUxHWoRkWHFBht | ||
knownBigMapContract address: KT1NN9wjEDzrpcXynvA1L97Y5JCT7ebyjPNj | ||
::set-output name=knownBigMapContractAddress::KT1NN9wjEDzrpcXynvA1L97Y5JCT7ebyjPNj | ||
knownTzip12BigMapOffChainContract address: KT1UXPQiyHR4AesmD4QYefprVXH21JrGefnQ | ||
::set-output name=knownTzip12BigMapOffChainContractAddress::KT1UXPQiyHR4AesmD4QYefprVXH21JrGefnQ | ||
knownSaplingContract address: KT1Hkdt7v2ycodEBUxHWoRkWHFBhtutgmVDU | ||
::set-output name=knownSaplingContractAddress::KT1Hkdt7v2ycodEBUxHWoRkWHFBhtutgmVDU | ||
knownOnChainViewContractAddress address: KT1JirmFdgjttrm6wgwRxFGfwrP3twT5Y7CT | ||
::set-output name=knownOnChainViewContractAddressAddress::KT1JirmFdgjttrm6wgwRxFGfwrP3twT5Y7CT | ||
|
||
Public Key Hash : tz1YPSCGWXwBdTncK2aCctSZAXWvGsGwVJqU | ||
Initial Balance : 90856887.13687 XTZ | ||
Final Balance : 90856909.589235 XTZ | ||
Total XTZ Spent : -22.452365 XTZ | ||
|
||
> [email protected] test:oxfordnet-secret-key | ||
> RUN_OXFORDNET_WITH_SECRET_KEY=true jest --runInBand | ||
RUNS ./contract-manager-scenario.spec.ts | ||
PASS ./contract-manager-scenario.spec.ts (6.167 s) | ||
``` | ||
|
||
## Testing Baking and Governance Operations with Flextesa | ||
|
||
We provide a shell script `integration-tests/sandbox-bakers.sh` for setting up and running a mini net of bakers with Flextesa. | ||
The default values for the sandbox include | ||
- blocks_per_voting_period=12 | ||
- extra_dummy_proposals_batch_size=2 | ||
- extra_dummy_proposals_batch_level=2,4 | ||
- number_of_bootstrap_accounts=2 | ||
|
||
Before running the script, make sure the file `~/taquito/integration-tests/known-contracts-ProxfordY.ts` is populated. Stop the `baking-sandbox` docker process before running the script again. | ||
|
||
To run this script, save it as `integration-tests/sandbox-bakers.sh` and execute it with the required arguments: | ||
|
||
```bash | ||
chmod +x sandbox-bakers.sh | ||
./sandbox-bakers.sh <flextesa_docker_image> <protocol> <testnet> <testnet_uppercase> | ||
``` | ||
for example, | ||
```bash | ||
./sandbox-bakers.sh oxheadalpha/flextesa:20230313 Oxford oxfordnet OXFORDNET | ||
``` | ||
|
||
Create an alias to make interacting with the flextesa node easier | ||
```bash! | ||
alias tcli='docker exec baking-sandbox octez-client' | ||
``` | ||
Then, various commands are run like so | ||
```bash! | ||
tcli get balance for alice | ||
tcli --wait none transfer 10 from alice to bob # Option `--wait` is IMPORTANT! | ||
tcli show address alice | ||
``` | ||
|
||
For baking, check for baking rights | ||
```bash! | ||
tcli show address alice # get the pkh | ||
tcli rpc get /chains/main/blocks/head/metadata | jq .level_info,.protocol # get the cycle | ||
tcli rpc get /chains/main/blocks/head/helpers/baking_rights\?cycle=<CYCLE>\&delegate=<PKH>\&max_round=7 | ||
``` | ||
Since the cycles fly by in this setup, check for rights a few cycles ahead .. | ||
|
||
Then | ||
```bash! | ||
tcli bake for alice | ||
``` | ||
You should see something like: | ||
```bash! | ||
May 11 20:14:39.014 - 017-ProxfordY.baker.transitions: received new head BLr6cAaj2oM2ibakFp8zZMNEbpcSAZ94WhzeV57njD7NrnaYrZU at | ||
May 11 20:14:39.014 - 017-ProxfordY.baker.transitions: level 1152, round 0 | ||
Block BLCjrRGMJxZEBoZaxafUHcTCNBnmGzRfX2Qf5qru2XtAhiNEsun (1153) injected | ||
``` | ||
The only sandbox tests we're running points to the latest Nairobibox to specifically test for the `ballot` and `drain_delegate` operation. | ||
::: | ||
|
||
## The Keygen API | ||
|
||
|
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,8 @@ | ||
import { KnownContracts } from './known-contracts'; | ||
export const knownContractsPtNairobi: KnownContracts = { | ||
contract: "", | ||
bigMapContract: "", | ||
tzip12BigMapOffChainContract: "", | ||
saplingContract: "", | ||
onChainViewContractAddress: "" | ||
}; |
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
Oops, something went wrong.