Skip to content

Commit

Permalink
test: adjusted estimation assertions, improve staking test and test c…
Browse files Browse the repository at this point in the history
…onfig for beta release
  • Loading branch information
hui-an-yang committed Dec 9, 2024
1 parent a46d360 commit ada6f0a
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 45 deletions.
48 changes: 24 additions & 24 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,27 +67,27 @@ jobs:
env:
# Ternary operator workaround
TEZOS_RPC_${{ matrix.testnet_uppercase }}: ${{ github.event.pull_request.head.repo.fork && matrix.rpc_url || null }}
integration-tests-quebec-secret-key:
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
include:
- testnet: quebecnet
testnet_uppercase: QUEBECNET
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/iron
- run: npm ci
- run: npm run build
- if: ${{ !github.event.pull_request.head.repo.fork }}
name: Tailscale
uses: tailscale/github-action@v1
with:
authkey: ${{ secrets.TAILSCALE_AUTHKEY }}
version: 1.32.2
- run: npm -w integration-tests run test:quebecnet-secret-key
env:
RUN_${{ matrix.testnet_uppercase }}_WITH_SECRET_KEY: true
# integration-tests-quebec-secret-key:
# runs-on: ubuntu-latest
# continue-on-error: true
# strategy:
# matrix:
# include:
# - testnet: quebecnet
# testnet_uppercase: QUEBECNET
# steps:
# - uses: actions/checkout@v4
# - uses: actions/setup-node@v4
# with:
# node-version: lts/iron
# - run: npm ci
# - run: npm run build
# - if: ${{ !github.event.pull_request.head.repo.fork }}
# name: Tailscale
# uses: tailscale/github-action@v1
# with:
# authkey: ${{ secrets.TAILSCALE_AUTHKEY }}
# version: 1.32.2
# - run: npm -w integration-tests run test:quebecnet-secret-key
# env:
# RUN_${{ matrix.testnet_uppercase }}_WITH_SECRET_KEY: true
10 changes: 5 additions & 5 deletions integration-tests/__tests__/contract/estimation-tests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ CONFIGS().forEach(({ lib, setup, knownBaker, createAddress, rpc }) => {
it('Verify .estimate.transfer for internal transfer to allocated implicit', async () => {
const tx = contract.methods.do(MANAGER_LAMBDA.transferImplicit(knownBaker, 5)).toTransferParams();
const estimate = await LowAmountTez.estimate.transfer(tx);
expect(estimate.gasLimit).toEqual(1456);
expect(estimate.gasLimit).toEqual(1457);
expect(estimate.storageLimit).toEqual(0);
expect(estimate.suggestedFeeMutez).toEqual(394);
expect(estimate.burnFeeMutez).toEqual(0);
expect(estimate.minimalFeeMutez).toEqual(374);
expect(estimate.totalCost).toEqual(374);
expect(estimate.usingBaseFeeMutez).toEqual(374);
expect(estimate.consumedMilligas).toEqual(1455970);
expect(estimate.consumedMilligas).toEqual(1456056);
});

it('Verify .estimate.transfer for multiple internal transfers to unallocated account', async () => {
Expand All @@ -119,7 +119,7 @@ CONFIGS().forEach(({ lib, setup, knownBaker, createAddress, rpc }) => {
expect(estimate.minimalFeeMutez).toEqual(445);
expect(estimate.totalCost).toEqual(133945);
expect(estimate.usingBaseFeeMutez).toEqual(445);
expect(estimate.consumedMilligas).toEqual(1570499);
expect(estimate.consumedMilligas).toEqual(1570585);
});

it('Verify .estimate.transfer for internal origination', async () => {
Expand All @@ -132,7 +132,7 @@ CONFIGS().forEach(({ lib, setup, knownBaker, createAddress, rpc }) => {
expect(estimate.minimalFeeMutez).toEqual(421);
expect(estimate.totalCost).toEqual(84671);
expect(estimate.usingBaseFeeMutez).toEqual(421);
expect(estimate.consumedMilligas).toEqual(1866594);
expect(estimate.consumedMilligas).toEqual(1866680);
});

it('Verify .estimate.transfer for multiple internal originations', async () => {
Expand All @@ -145,7 +145,7 @@ CONFIGS().forEach(({ lib, setup, knownBaker, createAddress, rpc }) => {
expect(estimate.minimalFeeMutez).toEqual(539);
expect(estimate.totalCost).toEqual(164039);
expect(estimate.usingBaseFeeMutez).toEqual(539);
expect(estimate.consumedMilligas).toEqual(2391747);
expect(estimate.consumedMilligas).toEqual(2391833);
// Do the actual operation
const op2 = await contract.methods.do(originate2()).send();
await op2.confirmation();
Expand Down
10 changes: 3 additions & 7 deletions integration-tests/__tests__/contract/operations/staking.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { openAsBlob } from "fs";
import { CONFIGS } from "../../../config";
import { InvalidStakingAddressError, InvalidFinalizeUnstakeAmountError } from '@taquito/core';

Expand All @@ -9,13 +8,10 @@ CONFIGS().forEach(({ lib, rpc, setup }) => {
await setup(true);
try{
const address = await Tezos.signer.publicKeyHash()
if(await Tezos.rpc.getDelegate(address) !== address){
const delegateOp = await Tezos.contract.setDelegate({
delegate: 'tz1TGKSrZrBpND3PELJ43nVdyadoeiM1WMzb', // is a delegate receiving stake on parisnet and ghostnet
source: address
});
if(!await Tezos.rpc.getDelegate(address)){
const delegateOp = await Tezos.contract.registerDelegate({});
await delegateOp.confirmation();
};
}
}catch(e){console.log}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@ CONFIGS().forEach(({ lib, rpc, setup }) => {
await setup(true);
try{
const address = await Tezos.signer.publicKeyHash()
if(await Tezos.rpc.getDelegate(address) !== address){
const delegateOp = await Tezos.contract.setDelegate({
delegate: 'tz1TGKSrZrBpND3PELJ43nVdyadoeiM1WMzb', // is a delegate receiving stake on parisnet and ghostnet
source: address
});
if(!await Tezos.rpc.getDelegate(address)){
const delegateOp = await Tezos.contract.registerDelegate({});
await delegateOp.confirmation();
};
}
}catch(e){console.log}
});

Expand Down
6 changes: 3 additions & 3 deletions integration-tests/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ const defaultConfig = ({
rpc: process.env[`TEZOS_RPC_${networkName}`] || defaultRpc,
pollingIntervalMilliseconds: process.env[`POLLING_INTERVAL_MILLISECONDS`] || undefined,
rpcCacheMilliseconds: process.env[`RPC_CACHE_MILLISECONDS`] || '1000',
knownBaker: process.env[`TEZOS_BAKER`] || (networkName === 'QUEBECNET' ? 'tz3Q1fwk1vh3zm5LqyUV9e2wZBdaEXcovh2r' : 'tz1TGKSrZrBpND3PELJ43nVdyadoeiM1WMzb'),
knownBaker: process.env[`TEZOS_BAKER`] || (networkName === 'QUEBECNET' ? 'tz1cjyja1TU6fiyiFav3mFAdnDsCReJ12hPD' : 'tz1TGKSrZrBpND3PELJ43nVdyadoeiM1WMzb'),
knownContract: process.env[`TEZOS_${networkName}_CONTRACT_ADDRESS`] || knownContracts.contract,
knownBigMapContract: process.env[`TEZOS_${networkName}_BIGMAPCONTRACT_ADDRESS`] || knownContracts.bigMapContract,
knownTzip1216Contract: process.env[`TEZOS_${networkName}_TZIP1216CONTRACT_ADDRESS`] || knownContracts.tzip12BigMapOffChainContract,
Expand Down Expand Up @@ -180,7 +180,7 @@ const weeklynetSecretKey: Config =
const providers: Config[] = [];

if (process.env['RUN_WITH_SECRET_KEY']) {
providers.push(parisnetSecretKey);
providers.push(quebecnetSecretKey);
} else if (process.env['RUN_PARISNET_WITH_SECRET_KEY']) {
providers.push(parisnetSecretKey);
} else if (process.env['RUN_GHOSTNET_WITH_SECRET_KEY']) {
Expand All @@ -198,7 +198,7 @@ if (process.env['RUN_WITH_SECRET_KEY']) {
} else if (process.env['WEEKLYNET']) {
providers.push(weeklynetEphemeral);
} else {
providers.push(parisnetEphemeral);
providers.push(quebecnetEphemeral);
}

const setupForger = (Tezos: TezosToolkit, forger: ForgerType): void => {
Expand Down

0 comments on commit ada6f0a

Please sign in to comment.