diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 66bf8f6df9..dfaf4baccb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -63,70 +63,63 @@ jobs: # Ternary operator workaround TEZOS_RPC_${{ matrix.testnet_uppercase }}: ${{ github.event.pull_request.head.repo.fork && format('https://{0}.ecadinfra.com', matrix.testnet) || null }} - # integration-tests-flextesa: - # runs-on: ubuntu-latest - # continue-on-error: true - # strategy: - # matrix: - # include: - # - protocol: Oxford - # testnet: oxfordnet - # testnet_uppercase: OXFORDNET - # flextesa_docker_image: oxheadalpha/flextesa:latest - # steps: - # - uses: actions/checkout@v3 - # - uses: actions/setup-node@v3 - # with: - # node-version: lts/hydrogen + integration-tests-flextesa: + runs-on: ubuntu-latest + continue-on-error: true + strategy: + matrix: + include: + - protocol: Nairobi + testnet: nairobinet + testnet_uppercase: NAIROBINET + flextesa_docker_image: oxheadalpha/flextesa:20230607 + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: lts/hydrogen - # ## The 4 Bootstrap Accounts (alias, pk, pkh, sk) - # # alice,edpkvGfYw3LyB1UcCahKQk4rF2tvbMUk8GFiTuMjL75uGXrpvKXhjn,tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb,unencrypted:edsk3QoqBuvdamxouPhin7swCvkQNgq4jP5KZPbwWNnwdZpSpJiEbq - # # bob,edpkurPsQ8eUApnLUJ9ZPDvu98E8VNj4KtJa1aZr16Cr5ow5VHKnz4,tz1aSkwEot3L2kmUvcoxzjMomb9mvBNuzFK6,unencrypted:edsk3RFfvaFaxbHx8BMtEW1rKQcPtDML3LXjNqMNLCzC3wLC1bWbAt - # # charlie,edpkuvMuRuZ6ZbAquJH1XxBFfUmuBFz1zp9ENEqjCVgLp3NcY3Ww9M,tz1RDVcKmFcqzvTpJirvg4JaUVgZbjtnRT26,unencrypted:edsk3RgWvbKKA1atEUcaGwivge7QtckHkTL9nQJUXQKY5r8WKp4pF4 - # # donald,edpkvXGp1BMZxHkwg3mKnWfJYS6HTJ5JtufD8YXxLtH8UKqLZkZVun,tz1eSWp4B9s1qhtNMMNXAkaf2oqCnDHd2iAm,unencrypted:edsk3S8mG2sSBmSRbikAcZVLCz4SrCq4DjmsQRic6MGktqNFijfrS2 - # - name: Generate Flextesa bootstrap accounts - # run: |- - # echo "alice=$(docker run --rm ${{ matrix.flextesa_docker_image }} flextesa key alice)" >> $GITHUB_ENV - # echo "bob=$(docker run --rm ${{ matrix.flextesa_docker_image }} flextesa key bob)" >> $GITHUB_ENV - # echo "charlie=$(docker run --rm ${{ matrix.flextesa_docker_image }} flextesa key charlie)" >> $GITHUB_ENV - # echo "donald=$(docker run --rm ${{ matrix.flextesa_docker_image }} flextesa key donald)" >> $GITHUB_ENV - # - name: Provision Flextesa ${{ matrix.protocol }} container - # run: |- - # docker run \ - # --rm \ - # --name my-sandbox \ - # --detach \ - # -p 20000:20000 \ - # ${{ matrix.flextesa_docker_image }} \ - # flextesa mini-net \ - # --root /tmp/mini-box --size 1 \ - # --set-history-mode N000:archive \ - # --number-of-b 1 \ - # --balance-of-bootstrap-accounts tez:100_000_000 \ - # --time-b 1 \ - # --add-bootstrap-account="${alice}@2_000_000_000_000" \ - # --add-bootstrap-account="${bob}@2_000_000_000_000" \ - # --add-bootstrap-account="${charlie}@2_000_000_000_000" \ - # --add-bootstrap-account="${donald}@2_000_000_000_000" \ - # --no-daemons-for=donald \ - # --until-level 200_000_000 \ - # --protocol-kind ${{ matrix.protocol }} - # - run: npm ci - # - run: npm run build - # - run: source ./integration-tests/sandbox-env.sh - # - run: npm -w integration-tests run originate-known-contracts && npm -w integration-tests run test:${{ matrix.testnet }}-secret-key -- --testPathIgnorePatterns ledger-signer-failing-tests.spec.ts ledger-signer.spec.ts contract-estimation-tests.spec.ts rpc-get-protocol-constants.spec.ts sandbox-ballot-operation.spec.ts contract-batch-high-number-of-operations.spec.ts contract-pair-as-key.spec.ts --detectOpenHandles --runInBand - # env: - # RUN_${{ matrix.testnet_uppercase }}_WITH_SECRET_KEY: true - # SECRET_KEY: edsk3S8mG2sSBmSRbikAcZVLCz4SrCq4DjmsQRic6MGktqNFijfrS2 - # TEZOS_RPC_${{ matrix.testnet_uppercase }}: http://localhost:20000 - # POLLING_INTERVAL_MILLISECONDS: 100 - # RPC_CACHE_MILLISECONDS: 0 - # TEZOS_BAKER: tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb - # - run: npm -w integration-tests run test:${{ matrix.testnet }}-secret-key sandbox-ballot-operation.spec.ts - # env: - # RUN_${{ matrix.testnet_uppercase }}_WITH_SECRET_KEY: true - # SECRET_KEY: edsk3QoqBuvdamxouPhin7swCvkQNgq4jP5KZPbwWNnwdZpSpJiEbq - # TEZOS_RPC_${{ matrix.testnet_uppercase }}: http://localhost:20000 - # POLLING_INTERVAL_MILLISECONDS: 100 - # RPC_CACHE_MILLISECONDS: 0 - # TEZOS_BAKER: tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb + ## The 4 Bootstrap Accounts (alias, pk, pkh, sk) + # alice,edpkvGfYw3LyB1UcCahKQk4rF2tvbMUk8GFiTuMjL75uGXrpvKXhjn,tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb,unencrypted:edsk3QoqBuvdamxouPhin7swCvkQNgq4jP5KZPbwWNnwdZpSpJiEbq + # bob,edpkurPsQ8eUApnLUJ9ZPDvu98E8VNj4KtJa1aZr16Cr5ow5VHKnz4,tz1aSkwEot3L2kmUvcoxzjMomb9mvBNuzFK6,unencrypted:edsk3RFfvaFaxbHx8BMtEW1rKQcPtDML3LXjNqMNLCzC3wLC1bWbAt + # charlie,edpkuvMuRuZ6ZbAquJH1XxBFfUmuBFz1zp9ENEqjCVgLp3NcY3Ww9M,tz1RDVcKmFcqzvTpJirvg4JaUVgZbjtnRT26,unencrypted:edsk3RgWvbKKA1atEUcaGwivge7QtckHkTL9nQJUXQKY5r8WKp4pF4 + # donald,edpkvXGp1BMZxHkwg3mKnWfJYS6HTJ5JtufD8YXxLtH8UKqLZkZVun,tz1eSWp4B9s1qhtNMMNXAkaf2oqCnDHd2iAm,unencrypted:edsk3S8mG2sSBmSRbikAcZVLCz4SrCq4DjmsQRic6MGktqNFijfrS2 + - name: Generate Flextesa bootstrap accounts + run: |- + echo "alice=$(docker run --rm ${{ matrix.flextesa_docker_image }} flextesa key alice)" >> $GITHUB_ENV + echo "bob=$(docker run --rm ${{ matrix.flextesa_docker_image }} flextesa key bob)" >> $GITHUB_ENV + echo "charlie=$(docker run --rm ${{ matrix.flextesa_docker_image }} flextesa key charlie)" >> $GITHUB_ENV + echo "donald=$(docker run --rm ${{ matrix.flextesa_docker_image }} flextesa key donald)" >> $GITHUB_ENV + - name: Provision Flextesa ${{ matrix.protocol }} container + run: |- + docker run \ + --rm \ + --name my-sandbox \ + --detach \ + -p 20000:20000 \ + ${{ matrix.flextesa_docker_image }} \ + flextesa mini-net \ + --root /tmp/mini-box --size 1 \ + --set-history-mode N000:archive \ + --number-of-b 1 \ + --balance-of-bootstrap-accounts tez:100_000_000 \ + --time-b 1 \ + --add-bootstrap-account="${alice}@2_000_000_000_000" \ + --add-bootstrap-account="${bob}@2_000_000_000_000" \ + --add-bootstrap-account="${charlie}@2_000_000_000_000" \ + --add-bootstrap-account="${donald}@2_000_000_000_000" \ + --no-daemons-for=donald \ + --until-level 200_000_000 \ + --protocol-kind ${{ matrix.protocol }} + - run: npm ci + - run: npm run build + - run: source ./integration-tests/sandbox-env.sh + - run: npm -w integration-tests run test:nairobinet-secret-key sandbox-ballot-operation.spec.ts + - run: npm -w integration-tests run test:nairobinet-secret-key sandbox-drain-delegate-operation.spec.ts + env: + RUN_${{ matrix.testnet_uppercase }}_WITH_SECRET_KEY: true + SECRET_KEY: edsk3QoqBuvdamxouPhin7swCvkQNgq4jP5KZPbwWNnwdZpSpJiEbq + TEZOS_RPC_${{ matrix.testnet_uppercase }}: http://localhost:20000 + POLLING_INTERVAL_MILLISECONDS: 100 + RPC_CACHE_MILLISECONDS: 0 + TEZOS_BAKER: tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb diff --git a/integration-tests/README.md b/integration-tests/README.md index 87c70423ab..65e60ff3c7 100644 --- a/integration-tests/README.md +++ b/integration-tests/README.md @@ -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 -integration-tests@16.1.2 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 - -> integration-tests@16.1.2 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 -``` -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=\&delegate=\&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 diff --git a/integration-tests/config.ts b/integration-tests/config.ts index 69a8e8fdd3..c68bd5607b 100644 --- a/integration-tests/config.ts +++ b/integration-tests/config.ts @@ -8,6 +8,7 @@ import { KnownContracts } from './known-contracts'; import { knownContractsProtoALph } from './known-contracts-ProtoALph'; import { knownContractsPtGhostnet } from './known-contracts-PtGhostnet'; import { knownContractsProxfordY } from './known-contracts-ProxfordY'; +import { knownContractsPtNairobi } from './known-contracts-PtNairobi'; const nodeCrypto = require('crypto'); @@ -140,6 +141,15 @@ const oxfordnetEphemeral: Config = const oxfordnetSecretKey: Config = { ...oxfordnetEphemeral, ...{ signerConfig: defaultSecretKey }, ...{ defaultRpc: 'http://ecad-oxfordnet-full:8732' } }; +const nairobinetSecretKey: Config = + defaultConfig({ + networkName: 'NAIROBINET', + protocol: Protocols.PtNairobi, + defaultRpc: 'http://ecad-nairobinet-full:8732', + knownContracts: knownContractsPtNairobi, + signerConfig: defaultSecretKey + }) + const ghostnetEphemeral: Config = defaultConfig({ networkName: 'GHOSTNET', @@ -172,6 +182,8 @@ if (process.env['RUN_WITH_SECRET_KEY']) { providers.push(oxfordnetSecretKey); } else if (process.env['RUN_GHOSTNET_WITH_SECRET_KEY']) { providers.push(ghostnetSecretKey); +} else if(process.env['RUN_NAIROBINET_WITH_SECRET_KEY']) { + providers.push(nairobinetSecretKey); } else if (process.env['RUN_WEEKLYNET_WITH_SECRET_KEY']) { providers.push(weeklynetSecretKey); } else if (process.env['OXFORDNET']) { diff --git a/integration-tests/known-contracts-PtNairobi.ts b/integration-tests/known-contracts-PtNairobi.ts new file mode 100644 index 0000000000..b830cd3f4b --- /dev/null +++ b/integration-tests/known-contracts-PtNairobi.ts @@ -0,0 +1,8 @@ +import { KnownContracts } from './known-contracts'; +export const knownContractsPtNairobi: KnownContracts = { + contract: "", + bigMapContract: "", + tzip12BigMapOffChainContract: "", + saplingContract: "", + onChainViewContractAddress: "" +}; \ No newline at end of file diff --git a/integration-tests/package.json b/integration-tests/package.json index f8d58fc617..9ad2a2907c 100644 --- a/integration-tests/package.json +++ b/integration-tests/package.json @@ -5,6 +5,7 @@ "test:secret-key": "RUN_WITH_SECRET_KEY=true jest --runInBand", "test:oxfordnet": "OXFORDNET=true jest", "test:oxfordnet-secret-key": "RUN_OXFORDNET_WITH_SECRET_KEY=true jest --runInBand", + "test:nairobinet-secret-key": "RUN_NAIROBINET_WITH_SECRET_KEY=true jest --runInBand", "test:weeklynet": "WEEKLYNET=true jest", "test:weeklynet-secret-key": "RUN_WEEKLYNET_WITH_SECRET_KEY=true jest --runInBand", "test:ghostnet": "GHOSTNET=true jest", diff --git a/integration-tests/sandbox-env.sh b/integration-tests/sandbox-env.sh index 6749cbabad..f450dc2f28 100755 --- a/integration-tests/sandbox-env.sh +++ b/integration-tests/sandbox-env.sh @@ -1,8 +1,7 @@ #!/bin/sh -export TEZOS_NETWORK_TYPE=sandbox -export RUN_OXFORDNET_WITH_SECRET_KEY=true +export RUN_NAIROBINET_WITH_SECRET_KEY=true export SECRET_KEY=edsk3RFgDiCt7tWB2oe96w1eRw72iYiiqZPLu9nnEY23MYRp2d8Kkx -export TEZOS_RPC_OXFORDNET=http://localhost:20000 +export TEZOS_RPC_NAIROBINET=http://localhost:20000 export POLLING_INTERVAL_MILLISECONDS=100 export RPC_CACHE_MILLISECONDS=0 -export TEZOS_BAKER=tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb +export TEZOS_BAKER=tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb \ No newline at end of file