From d3ae08f3d567cacc81c1d54d15268d82a2ca71fd Mon Sep 17 00:00:00 2001 From: huianyang Date: Thu, 12 Dec 2024 14:41:51 -0800 Subject: [PATCH 01/10] fix: fix prepareProvier ballot and proposal bug and add sandbox test back --- .github/workflows/main.yml | 29 +++- cspell.json | 2 + .../flextesa/sandbox-ballot-operation.spec.ts | 83 ------------ .../sandbox-drain-delegate-operation.spec.ts | 63 --------- .../sandbox-drain-delegate-operation.spec.ts | 85 ++++++++++++ ...dbox-proposal-and-ballot-operation.spec.ts | 104 ++++++++++++++ integration-tests/package.json | 1 + .../sandbox-override-parameters.hjson | 128 ++++++++++++++++++ package-lock.json | 34 +---- packages/taquito/src/operations/types.ts | 2 + .../taquito/src/prepare/prepare-provider.ts | 8 +- .../test/prepare/prepare-provider.spec.ts | 2 + 12 files changed, 359 insertions(+), 182 deletions(-) delete mode 100644 integration-tests/__tests__/flextesa/sandbox-ballot-operation.spec.ts delete mode 100644 integration-tests/__tests__/flextesa/sandbox-drain-delegate-operation.spec.ts create mode 100644 integration-tests/__tests__/tezbox/sandbox-drain-delegate-operation.spec.ts create mode 100644 integration-tests/__tests__/tezbox/sandbox-proposal-and-ballot-operation.spec.ts create mode 100644 integration-tests/sandbox-override-parameters.hjson diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f1b8ddde52..77e8bfe54e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,7 +18,7 @@ jobs: matrix: node: - 'lts/iron' - - '22' + - lts/hydrogen steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 @@ -49,7 +49,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: lts/iron + node-version: lts/hydrogen - run: npm ci - run: npm run build - if: ${{ !github.event.pull_request.head.repo.fork }} @@ -62,3 +62,28 @@ jobs: env: # 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-tezbox: + runs-on: ubuntu-latest + continue-on-error: true + strategy: + matrix: + include: + - testnet: parisnet + testnet_uppercase: PARISNET + flextesa_docker_image: + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: lts/hydrogen + - name: Provision Tezbox ${{ matrix.testnet }} container + run: npm -w integration-tests run sandbox:${{ matrix.testnet }} + - run: npm ci + - run: npm run build + - run: npm -w integration-tests run test __tests__/tezbox/integration-tests/__tests__/tezbox/sandbox-proposal-and-ballot-operation.spec.ts + env: + TEZOS_RPC_${{ matrix.testnet_uppercase }}: http://localhost:8732 + - run: npm -w integration-tests run test __tests__/tezbox/sandbox-drain-delegate-operation.spec + env: + TEZOS_RPC_${{ matrix.testnet_uppercase }}: http://localhost:8732 diff --git a/cspell.json b/cspell.json index 4d32d01c48..96d9172df5 100644 --- a/cspell.json +++ b/cspell.json @@ -105,6 +105,8 @@ "tcli", "testbox", "testchain", + "tezbox", + "tezboxnet", "tezbridge", "tezos", "Thanos", diff --git a/integration-tests/__tests__/flextesa/sandbox-ballot-operation.spec.ts b/integration-tests/__tests__/flextesa/sandbox-ballot-operation.spec.ts deleted file mode 100644 index 30e469917b..0000000000 --- a/integration-tests/__tests__/flextesa/sandbox-ballot-operation.spec.ts +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This test is not being run by any runner, - * will keep for future reference if an alternative sandbox is available - */ - -import { VotingPeriodBlockResult } from '@taquito/rpc'; -import { InMemorySigner } from '@taquito/signer'; -import { TezosToolkit } from '@taquito/taquito'; -import { CONFIGS, isSandbox, sleep } from '../../config'; - -CONFIGS().forEach(async ({ lib, rpc, protocol, setup }) => { - const flextesanet = isSandbox({ rpc }) ? test : test.skip; - let blocksPerVotingPeriod: number; - let blockTime: number; - let currentPeriod: VotingPeriodBlockResult; - - // Our ci flextesa script have 3 bakers Alice, Bob and Charlie (.github/workflows/main.yml) - const Alice = lib; // Alice's secret key is passed through the command to run test is configured by integration-tests/config.ts - const Bob = new TezosToolkit(rpc); - Bob.setSignerProvider(new InMemorySigner('edsk3RFfvaFaxbHx8BMtEW1rKQcPtDML3LXjNqMNLCzC3wLC1bWbAt')); - const Charlie = new TezosToolkit(rpc); - Charlie.setSignerProvider(new InMemorySigner('edsk3RgWvbKKA1atEUcaGwivge7QtckHkTL9nQJUXQKY5r8WKp4pF4')); - - describe(`Test Proposal and Ballot operation in ${protocol.substring(0, 8)} with flextesa`, () => { - beforeAll(async () => { - await setup(); - let constants = await Alice.rpc.getConstants(); - blocksPerVotingPeriod = constants.blocks_per_cycle * constants.cycles_per_voting_period!; - blockTime = constants.minimal_block_delay!.toNumber(); - }); - - flextesanet('Should be able to inject proposal operation in proposal period', async () => { - - // double check if it's proposal period so that we can inject proposal operation - currentPeriod = await Alice.rpc.getCurrentPeriod(); - if (currentPeriod.voting_period.kind === 'proposal') { - const proposalsOp = await Alice.contract.proposals({ - proposals: ['ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK'] - }); - await proposalsOp.confirmation(); - - expect(proposalsOp.operationResults).toBeDefined(); - expect(proposalsOp.operationResults?.kind).toEqual('proposals'); - expect(proposalsOp.operationResults?.proposals).toEqual(['ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK']); - expect(proposalsOp.includedInBlock).toBeDefined(); - expect(proposalsOp.hash).toBeDefined(); - - // injecting 2 more proposals from baker Bob and Charlie to reach above quorum - const BobOp = await Bob.contract.proposals({ - proposals: ['ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK'] - }); - await BobOp.confirmation(); - const CharlieOp = await Charlie.contract.proposals({ - proposals: ['ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK'] - }); - await CharlieOp.confirmation(); - } - }); - - flextesanet('Should be able to inject ballot operation in exploration period', async () => { - // if it's still proposal period make the test sleep to get into exploration period to inject ballot operation - currentPeriod = await Alice.rpc.getCurrentPeriod(); - if (currentPeriod.voting_period.kind === 'proposal') { - await sleep(((currentPeriod.remaining + 1) * blockTime) * 1000) - }; - currentPeriod = await Alice.rpc.getCurrentPeriod(); - if (currentPeriod.voting_period.kind === 'exploration') { - const explorationBallotOp = await Alice.contract.ballot({ - proposal: 'ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK', - ballot: 'yay' - }); - await explorationBallotOp.confirmation(); - - expect(explorationBallotOp.operationResults).toBeDefined(); - expect(explorationBallotOp.operationResults?.kind).toEqual('ballot'); - expect(explorationBallotOp.operationResults?.proposal).toEqual('ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK'); - expect(explorationBallotOp.operationResults?.ballot).toEqual('yay'); - expect(explorationBallotOp.includedInBlock).toBeDefined(); - expect(explorationBallotOp.hash).toBeDefined(); - } - }); - }); -}); diff --git a/integration-tests/__tests__/flextesa/sandbox-drain-delegate-operation.spec.ts b/integration-tests/__tests__/flextesa/sandbox-drain-delegate-operation.spec.ts deleted file mode 100644 index ae46c94696..0000000000 --- a/integration-tests/__tests__/flextesa/sandbox-drain-delegate-operation.spec.ts +++ /dev/null @@ -1,63 +0,0 @@ -/** - * This test is not being run by any runner, - * will keep for future reference if an alternative sandbox is available - */ - -import { TezosToolkit } from "@taquito/taquito"; -import { CONFIGS, sleep, isSandbox } from "../../config"; - -CONFIGS().forEach(({ lib, rpc, protocol, setup, createAddress }) => { - const Tezos = lib; - const flextesanet = isSandbox({ rpc }) ? test : test.skip; - - describe(`Test Drain Delegate in ${protocol}`, () => { - let Delegate: TezosToolkit; - let delegatePkh: string; - let Destination: TezosToolkit; - let destinationPkh: string; - beforeAll(async () => { - await setup(); - - try { - Delegate = await createAddress(); - delegatePkh = await Delegate.signer.publicKeyHash();; - Destination = await createAddress(); - destinationPkh = await Destination.signer.publicKeyHash(); - - // fund the delegate - const transferOp = await Tezos.contract.transfer({ to: delegatePkh, amount: 5 }); - await transferOp.confirmation(); - - // register as delegate - const registerOp = await Delegate.contract.registerDelegate({}); - await registerOp.confirmation(); - - // update consensus key to destination - const updateOp = await Delegate.contract.updateConsensusKey({ pk: await Destination.signer.publicKey() }); - await updateOp.confirmation(); - - // wait for more than preserved_cycles + 1 for consensus_key to be active - const constants = await Delegate.rpc.getConstants(); - await sleep(((constants.preserved_cycles + 2) * constants.blocks_per_cycle * (constants.minimal_block_delay!.toNumber())) * 1000); - - } catch (e) { - console.log(JSON.stringify(e)); - } - }) - flextesanet('Should be able to inject drain_delegate operation', async () => { - expect((await Delegate.rpc.getBalance(delegatePkh)).toNumber()).toBeGreaterThan(0); - let destinationBalanceBefore = (await Destination.rpc.getBalance(destinationPkh)).toNumber(); - - const drainOp = await Destination.contract.drainDelegate({ - consensus_key: destinationPkh, - delegate: delegatePkh, - destination: destinationPkh, - }); - await drainOp.confirmation(); - - expect(drainOp.includedInBlock).toBeDefined() - expect((await Delegate.rpc.getBalance(delegatePkh)).toNumber()).toEqual(0); - expect((await Destination.rpc.getBalance(destinationPkh)).toNumber()).toBeGreaterThan(destinationBalanceBefore); - }); - }); -}) diff --git a/integration-tests/__tests__/tezbox/sandbox-drain-delegate-operation.spec.ts b/integration-tests/__tests__/tezbox/sandbox-drain-delegate-operation.spec.ts new file mode 100644 index 0000000000..0d4523928e --- /dev/null +++ b/integration-tests/__tests__/tezbox/sandbox-drain-delegate-operation.spec.ts @@ -0,0 +1,85 @@ +import { CONFIGS, sleep, isSandbox } from "../../config"; +import { TezosToolkit } from "@taquito/taquito"; +import { InMemorySigner } from '@taquito/signer'; +import { OperationContentsAndResultDrainDelegate } from '@taquito/rpc'; + +CONFIGS().forEach(({ rpc, protocol, createAddress }) => { + const tezboxnet = isSandbox({ rpc }) ? test : test.skip; + const alice = new TezosToolkit(rpc); + let alicePkh: string; + let delegate: TezosToolkit; + let delegatePkh: string; + let destination: TezosToolkit; + let destinationPkh: string; + + describe(`Test Drain Delegate in ${protocol.substring(0, 8)}`, () => { + beforeAll(async () => { + // tezbox provision Alice account with balance, ref https://github.com/tez-capital/tezbox/blob/main/configuration/accounts.hjson + alice.setSignerProvider(new InMemorySigner('edsk3QoqBuvdamxouPhin7swCvkQNgq4jP5KZPbwWNnwdZpSpJiEbq')); + alicePkh = await alice.signer.publicKeyHash(); + delegate = await createAddress(); + delegatePkh = await delegate.signer.publicKeyHash();; + destination = await createAddress(); + destinationPkh = await destination.signer.publicKeyHash(); + // fund the delegate + const transferOp = await alice.contract.transfer({ to: delegatePkh, amount: 5 }); + await transferOp.confirmation(); + // register as delegate + const registerOp = await delegate.contract.registerDelegate({}); + await registerOp.confirmation(); + // update consensus key to destination + const updateOp = await delegate.contract.updateConsensusKey({ pk: await destination.signer.publicKey() }); + await updateOp.confirmation(); + }) + + tezboxnet('Should be able to prepare drainDelegate operations accepted by preapply endpoint', async () => { + // wait for more than preserved_cycles + 1 for consensus_key to be active to perform drainDelegate operation + const constants = await alice.rpc.getConstants(); + await sleep(((constants.consensus_rights_delay + 2) * (constants.blocks_per_cycle) * (constants.minimal_block_delay!.toNumber())) * 1000); + + const drainPrepared = await destination.prepare.drainDelegate({ + consensus_key: destinationPkh, + delegate: delegatePkh, + destination: destinationPkh, + }) + const drainPreapplied = await destination.rpc.preapplyOperations(await destination.prepare.toPreapply(drainPrepared)); + + expect(drainPreapplied).toBeInstanceOf(Array) + expect(drainPreapplied[0].contents).toBeInstanceOf(Array) + expect(drainPreapplied[0].contents[0].kind).toEqual('drain_delegate') + expect((drainPreapplied[0].contents[0] as OperationContentsAndResultDrainDelegate).consensus_key).toEqual(destinationPkh) + expect((drainPreapplied[0].contents[0] as OperationContentsAndResultDrainDelegate).delegate).toEqual(delegatePkh) + expect((drainPreapplied[0].contents[0] as OperationContentsAndResultDrainDelegate).destination).toEqual(destinationPkh) + expect((drainPreapplied[0].contents[0] as OperationContentsAndResultDrainDelegate).metadata).toBeDefined() + }); + tezboxnet('Should be able to inject drain_delegate operation', async () => { + // get the delegate and destination balance before drainDelegate operation + let delegateBeforeBalance = (await delegate.rpc.getBalance(delegatePkh)).toNumber() + let destinationBeforeBalance = (await destination.rpc.getBalance(destinationPkh)).toNumber(); + + const drainOp = await destination.contract.drainDelegate({ + consensus_key: destinationPkh, + delegate: delegatePkh, + destination: destinationPkh, + }); + await drainOp.confirmation(); + + // get the delegate and destination balance after drainDelegate operation + let delegateAfterBalance = (await destination.rpc.getBalance(delegatePkh)).toNumber() + let destinationAfterBalance = (await destination.rpc.getBalance(destinationPkh)).toNumber() + + expect(drainOp.includedInBlock).toBeDefined() + expect(drainOp.status).toBeDefined() + expect(drainOp.hash).toBeDefined() + expect(drainOp.operationResults).toBeDefined() + expect(drainOp.consensusKey).toEqual(destinationPkh) + expect(drainOp.delegate).toEqual(delegatePkh) + expect(drainOp.destination).toEqual(destinationPkh) + + expect(delegateBeforeBalance).toBeGreaterThan(0); + expect(delegateAfterBalance).toBe(0); + expect(destinationBeforeBalance).toBe(0); + expect(destinationAfterBalance).toBeGreaterThan(0); + }); + }); +}) diff --git a/integration-tests/__tests__/tezbox/sandbox-proposal-and-ballot-operation.spec.ts b/integration-tests/__tests__/tezbox/sandbox-proposal-and-ballot-operation.spec.ts new file mode 100644 index 0000000000..f1376734ac --- /dev/null +++ b/integration-tests/__tests__/tezbox/sandbox-proposal-and-ballot-operation.spec.ts @@ -0,0 +1,104 @@ +import { CONFIGS, isSandbox, sleep } from '../../config'; +import { TezosToolkit } from '@taquito/taquito'; +import { InMemorySigner } from '@taquito/signer'; +import { OperationContentsAndResultBallot, OperationContentsAndResultProposals, VotingPeriodBlockResult, OperationContentsProposals } from '@taquito/rpc'; + +CONFIGS().forEach(async ({ rpc, protocol }) => { + const tezboxnet = isSandbox({ rpc }) ? test : test.skip; + const baker1 = new TezosToolkit(rpc); + const baker2 = new TezosToolkit(rpc); + const baker3 = new TezosToolkit(rpc); + const proposal = 'ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK'; + const ballot = 'yay'; + let blockTime: number + let currentPeriod: VotingPeriodBlockResult; + + describe(`Test Proposal and Ballot operation in ${protocol.substring(0, 8)} with tezbox`, () => { + beforeAll(async () => { + // tezbox provision of 3 bakers, ref https://github.com/tez-capital/tezbox/blob/main/configuration/bakers.hjson + baker1.setSignerProvider(new InMemorySigner('edsk4ArLQgBTLWG5FJmnGnT689VKoqhXwmDPBuGx3z4cvwU9MmrPZZ')); + baker2.setSignerProvider(new InMemorySigner('edsk39qAm1fiMjgmPkw1EgQYkMzkJezLNewd7PLNHTkr6w9XA2zdfo')); + baker3.setSignerProvider(new InMemorySigner('edsk2uqQB9AY4FvioK2YMdfmyMrer5R8mGFyuaLLFfSRo8EoyNdht3')); + + // get block time from protocol constants + const constants = await baker1.rpc.getConstants(); + blockTime = constants.minimal_block_delay!.toNumber(); + }); + + tezboxnet('Should be able to prepare proposal accepted by preapply endpoint', async () => { + // check if it's in proposal period to start proposal test + currentPeriod = await baker1.rpc.getCurrentPeriod(); + while (currentPeriod.voting_period.kind !== 'proposal') { + await sleep(((currentPeriod.remaining + 1) * blockTime) * 1000) + currentPeriod = await baker1.rpc.getCurrentPeriod() + } + + const proposalPrepared = await baker1.prepare.proposals({ proposals: [proposal] }); + const proposalPreapplied = await baker1.rpc.preapplyOperations(await baker1.prepare.toPreapply(proposalPrepared)); + + expect(proposalPreapplied).toBeInstanceOf(Array); + expect(proposalPreapplied[0].contents).toBeInstanceOf(Array); + expect(proposalPreapplied[0].contents[0].kind).toBe('proposals'); + expect((proposalPreapplied[0].contents[0] as OperationContentsAndResultProposals).source).toBe(await baker1.signer.publicKeyHash()); + expect((proposalPreapplied[0].contents[0] as OperationContentsAndResultProposals).period).toBe((proposalPrepared.opOb.contents[0] as OperationContentsProposals).period); + expect((proposalPreapplied[0].contents[0] as OperationContentsAndResultProposals).proposals).toBeInstanceOf(Array); + expect((proposalPreapplied[0].contents[0] as OperationContentsAndResultProposals).proposals[0]).toEqual(proposal); + }); + + tezboxnet('Should be able to inject proposal operation in proposal period', async () => { + const proposalsOp = await baker1.contract.proposals({ + proposals: [proposal] + }); + await proposalsOp.confirmation(); + + expect(proposalsOp.includedInBlock).toBeDefined(); + expect(proposalsOp.status).toBeDefined(); + expect(proposalsOp.hash).toBeDefined(); + expect(proposalsOp.operationResults).toBeDefined(); + expect(proposalsOp.proposals).toEqual([proposal]); + expect(proposalsOp.period).toBeDefined(); + + // injecting 2 more proposals from baker baker2 and baker3 to reach above quorum + const baker2Op = await baker2.contract.proposals({ proposals: [proposal] }); + await baker2Op.confirmation(); + expect(baker2Op.includedInBlock).toBeDefined(); + const baker3Op = await baker3.contract.proposals({ proposals: [proposal] }); + await baker3Op.confirmation(); + expect(baker3Op.includedInBlock).toBeDefined(); + }); + + tezboxnet('Should be able to prepare ballot operations accepted by preapply endpoint', async () => { + // if it's still proposal period make the test sleep to get into exploration period to inject ballot operation + while (currentPeriod.voting_period.kind !== 'exploration') { + await sleep(((currentPeriod.remaining + 1) * blockTime) * 1000) + currentPeriod = await baker1.rpc.getCurrentPeriod() + } + + const ballotPrepared = await baker1.prepare.ballot({ proposal, ballot }); + const preappliedBallot = await baker1.rpc.preapplyOperations(await baker1.prepare.toPreapply(ballotPrepared)); + + expect(preappliedBallot).toBeInstanceOf(Array); + expect(preappliedBallot[0].contents).toBeInstanceOf(Array); + expect(preappliedBallot[0].contents[0].kind).toEqual('ballot'); + expect((preappliedBallot[0].contents[0] as OperationContentsAndResultBallot).source).toEqual(await baker1.signer.publicKeyHash()); + expect((preappliedBallot[0].contents[0] as OperationContentsAndResultBallot).proposal).toEqual(proposal); + expect((preappliedBallot[0].contents[0] as OperationContentsAndResultBallot).ballot).toEqual(ballot); + }); + + tezboxnet('Should be able to inject ballot operation in exploration period', async () => { + const explorationBallotOp = await baker1.contract.ballot({ + proposal, + ballot + }); + await explorationBallotOp.confirmation(); + + expect(explorationBallotOp.includedInBlock).toBeDefined(); + expect(explorationBallotOp.status).toBeDefined(); + expect(explorationBallotOp.hash).toBeDefined(); + expect(explorationBallotOp.operationResults).toBeDefined(); + expect(explorationBallotOp.proposal).toBe(proposal); + expect(explorationBallotOp.period).toBeDefined(); + expect(explorationBallotOp.ballot).toBe(ballot); + }); + }); +}); diff --git a/integration-tests/package.json b/integration-tests/package.json index 54beb40b45..a1e7cc7d57 100644 --- a/integration-tests/package.json +++ b/integration-tests/package.json @@ -10,6 +10,7 @@ "test:weeklynet-secret-key": "RUN_WEEKLYNET_WITH_SECRET_KEY=true jest --runInBand", "test:ghostnet": "GHOSTNET=true jest", "test:ghostnet-secret-key": "RUN_GHOSTNET_WITH_SECRET_KEY=true jest --runInBand", + "sandbox:parisnet": "docker run -d -p 0.0.0.0:8732:8732 -v $(pwd)/sandbox-override-parameters.hjson:/tezbox/configuration/protocols/PsParisC/sandbox-parameters.hjson --name sandbox ghcr.io/tez-capital/tezbox:tezos-v21.0 parisbox", "originate-known-contracts": "node -r ts-node/register originate-known-contracts.ts", "originate-known-contracts-and-run-test": "node -r ts-node/register originate-known-contracts.ts && jest" }, diff --git a/integration-tests/sandbox-override-parameters.hjson b/integration-tests/sandbox-override-parameters.hjson new file mode 100644 index 0000000000..8f4dbf9354 --- /dev/null +++ b/integration-tests/sandbox-override-parameters.hjson @@ -0,0 +1,128 @@ +{ + "consensus_rights_delay": 1, + "blocks_preservation_cycles": 1, + "delegate_parameters_activation_delay": 3, + "blocks_per_cycle": 10, + "blocks_per_commitment": 15, + "nonce_revelation_threshold": 5, + "cycles_per_voting_period": 1, + "hard_gas_limit_per_operation": "1040000", + "hard_gas_limit_per_block": "1733333", + "proof_of_work_threshold": "281474976710655", + "minimal_stake": "6000000000", + "minimal_frozen_stake": "600000000", + "vdf_difficulty": "10000000000", + "origination_size": 257, + "issuance_weights": { + "base_total_issued_per_minute": "80007812", + "baking_reward_fixed_portion_weight": 5120, + "baking_reward_bonus_weight": 5120, + "attesting_reward_weight": 10240, + "seed_nonce_revelation_tip_weight": 1, + "vdf_revelation_tip_weight": 1 + }, + "cost_per_byte": "250", + "hard_storage_limit_per_operation": "60000", + "quorum_min": 2000, + "quorum_max": 7000, + "min_proposal_quorum": 500, + "liquidity_baking_subsidy": "5000000", + "liquidity_baking_toggle_ema_threshold": 1000000000, + "max_operations_time_to_live": 360, + "minimal_block_delay": "1", + "delay_increment_per_round": "2", + "consensus_committee_size": 7000, + "consensus_threshold": 4667, + "minimal_participation_ratio": { + "numerator": 2, + "denominator": 3 + }, + "limit_of_delegation_over_baking": 9, + "percentage_of_frozen_deposits_slashed_per_double_baking": 500, + "percentage_of_frozen_deposits_slashed_per_double_attestation": 5000, + "max_slashing_per_block": 10000, + "max_slashing_threshold": 2334, + "testnet_dictator": "tz1Xf8zdT3DbAX9cHw3c3CXh79rc4nK4gCe8", + "cache_script_size": 100000000, + "cache_stake_distribution_cycles": 8, + "cache_sampler_state_cycles": 8, + "dal_parametric": { + "feature_enable": true, + "incentives_enable": false, + "number_of_slots": 32, + "attestation_lag": 8, + "attestation_threshold": 66, + "redundancy_factor": 8, + "page_size": 3967, + "slot_size": 126944, + "number_of_shards": 512 + }, + "smart_rollup_arith_pvm_enable": false, + "smart_rollup_origination_size": 6314, + "smart_rollup_challenge_window_in_blocks": 241920, + "smart_rollup_stake_amount": "10000000000", + "smart_rollup_commitment_period_in_blocks": 180, + "smart_rollup_max_lookahead_in_blocks": 518400, + "smart_rollup_max_active_outbox_levels": 241920, + "smart_rollup_max_outbox_messages_per_level": 100, + "smart_rollup_number_of_sections_in_dissection": 32, + "smart_rollup_timeout_period_in_blocks": 120960, + "smart_rollup_max_number_of_cemented_commitments": 5, + "smart_rollup_max_number_of_parallel_games": 32, + "smart_rollup_reveal_activation_level": { + "raw_data": { + "Blake2B": 0 + }, + "metadata": 0, + "dal_page": 6422529, + "dal_parameters": 6422529, + "dal_attested_slots_validity_lag": 241920 + }, + "smart_rollup_private_enable": true, + "smart_rollup_riscv_pvm_enable": false, + "zk_rollup_enable": false, + "zk_rollup_origination_size": 4000, + "zk_rollup_min_pending_to_process": 10, + "zk_rollup_max_ticket_payload_size": 2048, + "global_limit_of_staking_over_baking": 5, + "edge_of_staking_over_delegation": 2, + "adaptive_issuance_launch_ema_threshold": 0, + "adaptive_rewards_params": { + "issuance_ratio_final_min": { + "numerator": "1", + "denominator": "400" + }, + "issuance_ratio_final_max": { + "numerator": "1", + "denominator": "10" + }, + "issuance_ratio_initial_min": { + "numerator": "9", + "denominator": "200" + }, + "issuance_ratio_initial_max": { + "numerator": "11", + "denominator": "200" + }, + "initial_period": 10, + "transition_period": 50, + "max_bonus": "50000000000000", + "growth_rate": { + "numerator": "1", + "denominator": "100" + }, + "center_dz": { + "numerator": "1", + "denominator": "2" + }, + "radius_dz": { + "numerator": "1", + "denominator": "50" + } + }, + "adaptive_issuance_activation_vote_enable": true, + "autostaking_enable": true, + "adaptive_issuance_force_activation": false, + "ns_enable": true, + "direct_ticket_spending_enable": false +} diff --git a/package-lock.json b/package-lock.json index c1936b4ffd..244a6a1df4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,7 @@ "requires": true, "packages": { "": { + "name": "taquito", "workspaces": [ "packages/*", "packages/taquito-michel-codec/pack-test-tool", @@ -3612,27 +3613,6 @@ "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==", "license": "MIT" }, - "node_modules/@ethersproject/signing-key/node_modules/elliptic": { - "version": "6.6.0", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.6.0.tgz", - "integrity": "sha512-dpwoQcLc/2WLQvJvLRHKZ+f9FgOdjnq11rurqwekGQygGPsYSK29OMMD2WalatiqQ+XGFDglTNixpPfI+lpaAA==", - "license": "MIT", - "dependencies": { - "bn.js": "^4.11.9", - "brorand": "^1.1.0", - "hash.js": "^1.0.0", - "hmac-drbg": "^1.0.1", - "inherits": "^2.0.4", - "minimalistic-assert": "^1.0.1", - "minimalistic-crypto-utils": "^1.0.1" - } - }, - "node_modules/@ethersproject/signing-key/node_modules/elliptic/node_modules/bn.js": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", - "license": "MIT" - }, "node_modules/@ethersproject/strings": { "version": "5.7.0", "resolved": "https://registry.npmjs.org/@ethersproject/strings/-/strings-5.7.0.tgz", @@ -12098,9 +12078,9 @@ } }, "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", "license": "MIT", "dependencies": { "path-key": "^3.1.0", @@ -21018,9 +20998,9 @@ "license": "ISC" }, "node_modules/nanoid": { - "version": "3.3.7", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", - "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.8.tgz", + "integrity": "sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==", "dev": true, "funding": [ { diff --git a/packages/taquito/src/operations/types.ts b/packages/taquito/src/operations/types.ts index e6f860ad4f..eea7f06573 100644 --- a/packages/taquito/src/operations/types.ts +++ b/packages/taquito/src/operations/types.ts @@ -67,6 +67,8 @@ export type RPCOpWithFee = | RPCSmartRollupOutboxMessageOperation; export type RPCOpWithSource = + | RPCBallotOperation + | RPCProposalsOperation | RPCTransferOperation | RPCOriginationOperation | RPCDelegateOperation diff --git a/packages/taquito/src/prepare/prepare-provider.ts b/packages/taquito/src/prepare/prepare-provider.ts index 1989137e74..ffa59b6de5 100644 --- a/packages/taquito/src/prepare/prepare-provider.ts +++ b/packages/taquito/src/prepare/prepare-provider.ts @@ -269,19 +269,13 @@ export class PrepareProvider extends Provider implements PreparationProvider { ...this.getFee(op, pkh, headCounter), }; case OpKind.BALLOT: - if (currentVotingPeriod === undefined) { - throw new RPCResponseError(`Failed to get the current voting period index`); - } - return { - ...op, - period: currentVotingPeriod?.voting_period.index, - }; case OpKind.PROPOSALS: if (currentVotingPeriod === undefined) { throw new RPCResponseError(`Failed to get the current voting period index`); } return { ...op, + ...this.getSource(op, pkh, source), period: currentVotingPeriod?.voting_period.index, }; default: diff --git a/packages/taquito/test/prepare/prepare-provider.spec.ts b/packages/taquito/test/prepare/prepare-provider.spec.ts index 89b4d309cf..a01842f23f 100644 --- a/packages/taquito/test/prepare/prepare-provider.spec.ts +++ b/packages/taquito/test/prepare/prepare-provider.spec.ts @@ -970,6 +970,7 @@ describe('PrepareProvider test', () => { kind: 'ballot', period: 103, proposal: 'PtKathmankSpLLDALzWw7CGD2j2MtyveTwboEYokqUCP4a1LxMg', + source: 'tz1gvF4cD2dDtqitL3ZTraggSR1Mju2BKFEM', }, ], protocol: 'test_protocol', @@ -1018,6 +1019,7 @@ describe('PrepareProvider test', () => { kind: 'proposals', period: 103, proposals: ['PtKathmankSpLLDALzWw7CGD2j2MtyveTwboEYokqUCP4a1LxMg'], + source: 'tz1gvF4cD2dDtqitL3ZTraggSR1Mju2BKFEM', }, ], protocol: 'test_protocol', From d70c99736134c1918a5bf23c217452dfc6ca7e5f Mon Sep 17 00:00:00 2001 From: huianyang Date: Thu, 12 Dec 2024 14:53:14 -0800 Subject: [PATCH 02/10] ci: updated ci sandbox-proposal-and-ballot test file path --- .github/workflows/main.yml | 2 +- package-lock.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 77e8bfe54e..11cae015d1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -81,7 +81,7 @@ jobs: run: npm -w integration-tests run sandbox:${{ matrix.testnet }} - run: npm ci - run: npm run build - - run: npm -w integration-tests run test __tests__/tezbox/integration-tests/__tests__/tezbox/sandbox-proposal-and-ballot-operation.spec.ts + - run: npm -w integration-tests run test __tests__/tezbox/sandbox-proposal-and-ballot-operation.spec.ts env: TEZOS_RPC_${{ matrix.testnet_uppercase }}: http://localhost:8732 - run: npm -w integration-tests run test __tests__/tezbox/sandbox-drain-delegate-operation.spec diff --git a/package-lock.json b/package-lock.json index 244a6a1df4..ac7ddb6e18 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,7 +4,6 @@ "requires": true, "packages": { "": { - "name": "taquito", "workspaces": [ "packages/*", "packages/taquito-michel-codec/pack-test-tool", From 4fb008c5e2e11307e972173eaff50e1cbccaca88 Mon Sep 17 00:00:00 2001 From: huianyang Date: Thu, 12 Dec 2024 15:25:47 -0800 Subject: [PATCH 03/10] chore: tried downgrade node to avoid socket hang up error in tezbox --- .nvmrc | 2 +- packages/taquito-beacon-wallet/package.json | 2 +- packages/taquito-contracts-library/package.json | 2 +- packages/taquito-core/package.json | 2 +- packages/taquito-http-utils/package.json | 2 +- packages/taquito-ledger-signer/package.json | 2 +- packages/taquito-local-forging/package.json | 2 +- packages/taquito-michel-codec/package.json | 2 +- packages/taquito-michelson-encoder/package.json | 2 +- packages/taquito-remote-signer/package.json | 2 +- packages/taquito-rpc/package.json | 2 +- packages/taquito-sapling/package.json | 2 +- packages/taquito-signer/package.json | 2 +- packages/taquito-timelock/package.json | 2 +- packages/taquito-tzip12/package.json | 2 +- packages/taquito-tzip16/package.json | 2 +- packages/taquito-utils/package.json | 2 +- packages/taquito-wallet-connect/package.json | 2 +- packages/taquito/package.json | 2 +- 19 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.nvmrc b/.nvmrc index 85aee5a534..0828ab7947 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -v20 \ No newline at end of file +v18 \ No newline at end of file diff --git a/packages/taquito-beacon-wallet/package.json b/packages/taquito-beacon-wallet/package.json index 2fb7747f0d..eb1dada006 100644 --- a/packages/taquito-beacon-wallet/package.json +++ b/packages/taquito-beacon-wallet/package.json @@ -24,7 +24,7 @@ }, "license": "Apache-2.0", "engines": { - "node": ">=20" + "node": ">=18" }, "scripts": { "test": "jest --coverage", diff --git a/packages/taquito-contracts-library/package.json b/packages/taquito-contracts-library/package.json index 44b5306257..d8035b7ff4 100644 --- a/packages/taquito-contracts-library/package.json +++ b/packages/taquito-contracts-library/package.json @@ -22,7 +22,7 @@ }, "license": "Apache-2.0", "engines": { - "node": ">=20" + "node": ">=18" }, "scripts": { "test": "jest --coverage", diff --git a/packages/taquito-core/package.json b/packages/taquito-core/package.json index 8621c2a901..e2404b9899 100644 --- a/packages/taquito-core/package.json +++ b/packages/taquito-core/package.json @@ -23,7 +23,7 @@ }, "license": "Apache-2.0", "engines": { - "node": ">=20" + "node": ">=18" }, "scripts": { "lint": "eslint --ext .js,.ts .", diff --git a/packages/taquito-http-utils/package.json b/packages/taquito-http-utils/package.json index 8b6b6034f1..241b459b8d 100644 --- a/packages/taquito-http-utils/package.json +++ b/packages/taquito-http-utils/package.json @@ -22,7 +22,7 @@ }, "license": "Apache-2.0", "engines": { - "node": ">=20" + "node": ">=18" }, "scripts": { "lint": "eslint --ext .js,.ts .", diff --git a/packages/taquito-ledger-signer/package.json b/packages/taquito-ledger-signer/package.json index c6eaedce9e..8854b09ed4 100644 --- a/packages/taquito-ledger-signer/package.json +++ b/packages/taquito-ledger-signer/package.json @@ -20,7 +20,7 @@ }, "license": "Apache-2.0", "engines": { - "node": ">=20" + "node": ">=18" }, "scripts": { "lint": "eslint --ext .js,.ts .", diff --git a/packages/taquito-local-forging/package.json b/packages/taquito-local-forging/package.json index 9ade8d6514..0dfbc770c5 100644 --- a/packages/taquito-local-forging/package.json +++ b/packages/taquito-local-forging/package.json @@ -24,7 +24,7 @@ }, "license": "Apache-2.0", "engines": { - "node": ">=20" + "node": ">=18" }, "scripts": { "test": "jest --coverage", diff --git a/packages/taquito-michel-codec/package.json b/packages/taquito-michel-codec/package.json index e0fe927332..7269a46f4a 100644 --- a/packages/taquito-michel-codec/package.json +++ b/packages/taquito-michel-codec/package.json @@ -24,7 +24,7 @@ }, "license": "Apache-2.0", "engines": { - "node": ">=20" + "node": ">=18" }, "scripts": { "test": "jest --coverage", diff --git a/packages/taquito-michelson-encoder/package.json b/packages/taquito-michelson-encoder/package.json index d93569785d..8755114afe 100644 --- a/packages/taquito-michelson-encoder/package.json +++ b/packages/taquito-michelson-encoder/package.json @@ -25,7 +25,7 @@ }, "license": "Apache-2.0", "engines": { - "node": ">=20" + "node": ">=18" }, "scripts": { "test": "jest --coverage", diff --git a/packages/taquito-remote-signer/package.json b/packages/taquito-remote-signer/package.json index 5b0c99bcc5..757dd551d8 100644 --- a/packages/taquito-remote-signer/package.json +++ b/packages/taquito-remote-signer/package.json @@ -23,7 +23,7 @@ }, "license": "Apache-2.0", "engines": { - "node": ">=20" + "node": ">=18" }, "scripts": { "test": "jest --coverage", diff --git a/packages/taquito-rpc/package.json b/packages/taquito-rpc/package.json index ffe36dc71e..66c640717e 100644 --- a/packages/taquito-rpc/package.json +++ b/packages/taquito-rpc/package.json @@ -24,7 +24,7 @@ }, "license": "Apache-2.0", "engines": { - "node": ">=20" + "node": ">=18" }, "scripts": { "test": "jest --coverage", diff --git a/packages/taquito-sapling/package.json b/packages/taquito-sapling/package.json index b3fe15d348..4c4015098e 100644 --- a/packages/taquito-sapling/package.json +++ b/packages/taquito-sapling/package.json @@ -24,7 +24,7 @@ }, "license": "Apache-2.0", "engines": { - "node": ">=20" + "node": ">=18" }, "scripts": { "test": "jest --coverage", diff --git a/packages/taquito-signer/package.json b/packages/taquito-signer/package.json index f7410805c9..92708a0cf6 100644 --- a/packages/taquito-signer/package.json +++ b/packages/taquito-signer/package.json @@ -24,7 +24,7 @@ }, "license": "Apache-2.0", "engines": { - "node": ">=20" + "node": ">=18" }, "scripts": { "test": "jest --coverage", diff --git a/packages/taquito-timelock/package.json b/packages/taquito-timelock/package.json index d660400099..a2bac44978 100644 --- a/packages/taquito-timelock/package.json +++ b/packages/taquito-timelock/package.json @@ -19,7 +19,7 @@ }, "license": "Apache-2.0", "engines": { - "node": ">=20" + "node": ">=18" }, "scripts": { "test": "jest --coverage", diff --git a/packages/taquito-tzip12/package.json b/packages/taquito-tzip12/package.json index bbad2c719c..1f4b5a2221 100644 --- a/packages/taquito-tzip12/package.json +++ b/packages/taquito-tzip12/package.json @@ -24,7 +24,7 @@ }, "license": "Apache-2.0", "engines": { - "node": ">=20" + "node": ">=18" }, "scripts": { "lint": "eslint --ext .js,.ts .", diff --git a/packages/taquito-tzip16/package.json b/packages/taquito-tzip16/package.json index fdf75853df..1b71c1c18b 100644 --- a/packages/taquito-tzip16/package.json +++ b/packages/taquito-tzip16/package.json @@ -24,7 +24,7 @@ }, "license": "Apache-2.0", "engines": { - "node": ">=20" + "node": ">=18" }, "scripts": { "lint": "eslint --ext .js,.ts .", diff --git a/packages/taquito-utils/package.json b/packages/taquito-utils/package.json index fb6580e03c..cf329b1d50 100644 --- a/packages/taquito-utils/package.json +++ b/packages/taquito-utils/package.json @@ -25,7 +25,7 @@ }, "license": "Apache-2.0", "engines": { - "node": ">=20" + "node": ">=18" }, "scripts": { "lint": "eslint --ext .js,.ts .", diff --git a/packages/taquito-wallet-connect/package.json b/packages/taquito-wallet-connect/package.json index a242e9d39b..30dfddd272 100644 --- a/packages/taquito-wallet-connect/package.json +++ b/packages/taquito-wallet-connect/package.json @@ -24,7 +24,7 @@ }, "license": "Apache-2.0", "engines": { - "node": ">=20" + "node": ">=18" }, "scripts": { "test": "jest --coverage", diff --git a/packages/taquito/package.json b/packages/taquito/package.json index 7102893494..602fca7c0d 100644 --- a/packages/taquito/package.json +++ b/packages/taquito/package.json @@ -28,7 +28,7 @@ }, "license": "Apache-2.0", "engines": { - "node": ">=20" + "node": ">=18" }, "scripts": { "test": "jest --coverage", From 65daa370a0648d061abfb7adc9d3799b53514f73 Mon Sep 17 00:00:00 2001 From: huianyang Date: Thu, 12 Dec 2024 15:53:54 -0800 Subject: [PATCH 04/10] ci: try changing localhost to 0.0.0.0 in tezbox script to fix ECONNREFUSED --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 11cae015d1..66c7c7f5fa 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -83,7 +83,7 @@ jobs: - run: npm run build - run: npm -w integration-tests run test __tests__/tezbox/sandbox-proposal-and-ballot-operation.spec.ts env: - TEZOS_RPC_${{ matrix.testnet_uppercase }}: http://localhost:8732 + TEZOS_RPC_${{ matrix.testnet_uppercase }}: http://0.0.0.0:8732 - run: npm -w integration-tests run test __tests__/tezbox/sandbox-drain-delegate-operation.spec env: - TEZOS_RPC_${{ matrix.testnet_uppercase }}: http://localhost:8732 + TEZOS_RPC_${{ matrix.testnet_uppercase }}: http://0.0.0.0:8732 From b044a0338df12e49ccfd17e228e3a719cebf5a6e Mon Sep 17 00:00:00 2001 From: huianyang Date: Thu, 12 Dec 2024 22:25:42 -0800 Subject: [PATCH 05/10] test: originated knownTicketContract to be used in several tests --- ...-between-implicit-and-originated-accounts.spec.ts | 12 +++++------- integration-tests/__tests__/rpc/nodes.spec.ts | 2 +- .../wallet/transfer-ticket-operation.spec.ts | 6 ++---- integration-tests/config.ts | 8 ++++++-- integration-tests/known-contracts-ProtoALph.ts | 11 ++++++----- integration-tests/known-contracts-PsParisCZ.ts | 1 + integration-tests/known-contracts-PtGhostnet.ts | 3 ++- integration-tests/known-contracts-PtNairobi.ts | 3 ++- integration-tests/known-contracts.ts | 1 + integration-tests/originate-known-contracts.ts | 9 ++++++++- 10 files changed, 34 insertions(+), 22 deletions(-) diff --git a/integration-tests/__tests__/contract/operations/transfer-ticket-between-implicit-and-originated-accounts.spec.ts b/integration-tests/__tests__/contract/operations/transfer-ticket-between-implicit-and-originated-accounts.spec.ts index 86681a14d6..1fa5ca8abb 100644 --- a/integration-tests/__tests__/contract/operations/transfer-ticket-between-implicit-and-originated-accounts.spec.ts +++ b/integration-tests/__tests__/contract/operations/transfer-ticket-between-implicit-and-originated-accounts.spec.ts @@ -1,9 +1,9 @@ import { CONFIGS } from "../../../config"; import { DefaultContractType, TezosToolkit } from "@taquito/taquito"; -import { ticketsSendTz, ticketsBagTz, ticketsBlackholeTz } from "../../../data/code_with_ticket_transfer"; +import { ticketsBagTz, ticketsBlackholeTz } from "../../../data/code_with_ticket_transfer"; import { RpcClient, TicketTokenParams } from '@taquito/rpc'; -CONFIGS().forEach(({ lib, rpc, setup, createAddress }) => { +CONFIGS().forEach(({ lib, rpc, setup, createAddress, knownTicketContract }) => { const Tezos1 = lib; const client = new RpcClient(rpc); @@ -25,9 +25,7 @@ CONFIGS().forEach(({ lib, rpc, setup, createAddress }) => { tezos2Pkh = await Tezos2.signer.publicKeyHash(); // ticketSend contract has one default entrypoint which accepts an address to issue tickets to - const ticketSendOrigination = await Tezos1.contract.originate({ code: ticketsSendTz, storage: null }); - await ticketSendOrigination.confirmation(); - ticketSendContract = await ticketSendOrigination.contract(); + ticketSendContract = await Tezos1.contract.at(knownTicketContract) // ticketBag contract has two entrypoints, one is "save" to receive tickets and the other is "send" to send tickets out const ticketBagOrigination = await Tezos1.contract.originate({ code: ticketsBagTz, storage: [] }); @@ -46,7 +44,7 @@ CONFIGS().forEach(({ lib, rpc, setup, createAddress }) => { }); it('will send 3 tickets from an originated to an implicit account', async () => { - const ticketSendToImplicitOp = await ticketSendContract.methods.default(tezos1Pkh, '3').send(); + const ticketSendToImplicitOp = await ticketSendContract.methodsObject.default({ 0: tezos1Pkh, 1: '3' }).send(); await ticketSendToImplicitOp.confirmation(); expect(ticketSendToImplicitOp.status).toEqual('applied'); @@ -92,7 +90,7 @@ CONFIGS().forEach(({ lib, rpc, setup, createAddress }) => { }); it('will send 1 ticket from an origianted to another originated account to dispose', async () => { - const ticketSendOriginatedOp = await ticketBagContract.methods.send(ticketBlackholeContract.address).send(); + const ticketSendOriginatedOp = await ticketBagContract.methodsObject.send(ticketBlackholeContract.address).send(); await ticketSendOriginatedOp.confirmation(); expect(ticketSendOriginatedOp.status).toEqual('applied'); diff --git a/integration-tests/__tests__/rpc/nodes.spec.ts b/integration-tests/__tests__/rpc/nodes.spec.ts index 082d689a80..182948d0ba 100644 --- a/integration-tests/__tests__/rpc/nodes.spec.ts +++ b/integration-tests/__tests__/rpc/nodes.spec.ts @@ -35,7 +35,7 @@ CONFIGS().forEach( await ticketOp.confirmation(); ticketContract = await ticketOp.contract(); // contract call to issue tickets - const ticketCallOp = await ticketContract.methods.auto_call(1).send(); + const ticketCallOp = await ticketContract.methodsObject.auto_call(1).send(); await ticketCallOp.confirmation(); } catch (e) { console.log('Failed to originate ticket contract', JSON.stringify(e)); diff --git a/integration-tests/__tests__/wallet/transfer-ticket-operation.spec.ts b/integration-tests/__tests__/wallet/transfer-ticket-operation.spec.ts index f1f0fbd7a5..76106e1a94 100644 --- a/integration-tests/__tests__/wallet/transfer-ticket-operation.spec.ts +++ b/integration-tests/__tests__/wallet/transfer-ticket-operation.spec.ts @@ -3,7 +3,7 @@ import { DefaultContractType, TezosToolkit } from '@taquito/taquito'; import { ticketsSendTz } from '../../data/code_with_ticket_transfer'; import { RpcClient, TicketTokenParams } from '@taquito/rpc'; -CONFIGS().forEach(({ lib, rpc, setup, createAddress }) => { +CONFIGS().forEach(({ lib, rpc, setup, createAddress, knownTicketContract }) => { const Tezos = lib; const client = new RpcClient(rpc); @@ -28,10 +28,8 @@ CONFIGS().forEach(({ lib, rpc, setup, createAddress }) => { const fundSender = await Tezos.contract.transfer({ to: senderPkh, amount: 5 }); await fundSender.confirmation(); - const ticketSendOrigination = await Tezos.contract.originate({ code: ticketsSendTz, storage: null }); - await ticketSendOrigination.confirmation(); - ticketSendContract = await ticketSendOrigination.contract(); + ticketSendContract = await Tezos.contract.at(knownTicketContract); ticketToken = { ticketer: ticketSendContract.address, content_type: { prim: 'string' }, content: { string: 'Ticket' } }; // Send 3 tickets from the originated contract to sender diff --git a/integration-tests/config.ts b/integration-tests/config.ts index 290e13880b..a5148ffbbb 100644 --- a/integration-tests/config.ts +++ b/integration-tests/config.ts @@ -46,6 +46,7 @@ interface Config { knownTzip1216Contract: string; knownSaplingContract: string; knownViewContract: string; + knownTicketContract: string; protocol: Protocols; signerConfig: EphemeralConfig | SecretKeyConfig; networkType: NetworkType; @@ -123,6 +124,7 @@ const defaultConfig = ({ knownTzip1216Contract: process.env[`TEZOS_${networkName}_TZIP1216CONTRACT_ADDRESS`] || knownContracts.tzip12BigMapOffChainContract, knownSaplingContract: process.env[`TEZOS_${networkName}_SAPLINGCONTRACT_ADDRESS`] || knownContracts.saplingContract, knownViewContract: process.env[`TEZOS_${networkName}_ON_CHAIN_VIEW_CONTRACT`] || knownContracts.onChainViewContractAddress, + knownTicketContract: process.env[`TEZOS_${networkName}_TICKET_CONTRACT_ADDRESS`] || knownContracts.ticketContract, protocol: protocol, signerConfig: signerConfig, networkType: networkType @@ -153,7 +155,7 @@ const nairobinetSecretKey: Config = const ghostnetEphemeral: Config = defaultConfig({ networkName: 'GHOSTNET', - protocol: Protocols.PtParisBx, + protocol: Protocols.PsParisCZ, defaultRpc: 'http://ecad-tezos-ghostnet-rolling-1.i.ecadinfra.com/', knownContracts: knownContractsPtGhostnet, signerConfig: defaultEphemeralConfig('https://keygen.ecadinfra.com/ghostnet') @@ -166,7 +168,7 @@ const weeklynetEphemeral: Config = defaultConfig({ networkName: 'WEEKLYNET', protocol: Protocols.ProtoALpha, - defaultRpc: 'https://rpc.weeklynet-2024-09-04.teztnets.com', + defaultRpc: 'https://rpc.weeklynet-2024-12-11.teztnets.com', knownContracts: knownContractsProtoALph, signerConfig: defaultEphemeralConfig('http://key-gen-1.i.tez.ie:3010/mondaynet') }); @@ -283,6 +285,7 @@ export const CONFIGS = () => { knownTzip1216Contract, knownSaplingContract, knownViewContract, + knownTicketContract, signerConfig, networkType }) => { @@ -305,6 +308,7 @@ export const CONFIGS = () => { knownTzip1216Contract, knownSaplingContract, knownViewContract, + knownTicketContract, signerConfig, networkType, setup: async (preferFreshKey: boolean = false) => { diff --git a/integration-tests/known-contracts-ProtoALph.ts b/integration-tests/known-contracts-ProtoALph.ts index d8a8b93389..10a3be9f33 100644 --- a/integration-tests/known-contracts-ProtoALph.ts +++ b/integration-tests/known-contracts-ProtoALph.ts @@ -1,8 +1,9 @@ import { KnownContracts } from './known-contracts'; export const knownContractsProtoALph: KnownContracts = { - contract: "KT1XXrWDuK77kQWX55zjD347Wh6bwgmJDfJ8", - bigMapContract: "KT1NSDEhMTWoX2Vie98NCtQV4fVYoPfqfAN3", - tzip12BigMapOffChainContract: "KT1X4c8BCVSDE7dtf5jPRtpYtYcaSFknwzN5", - saplingContract: "KT1JKC49zUSCXJGKT2p1bHVWmg47rAgF53ff", - onChainViewContractAddress: "KT1FVjUZeH5KM8tMwYvrVCMC3QFyDRUBFNLk", + contract: "KT1JY7jZXxkCAh4uzCFkfx5i7WmBA8Jm1XMd", + bigMapContract: "KT1JWueskLs8x6YwgEn8m482oXis6xPEwnKt", + tzip12BigMapOffChainContract: "KT1V9ncPbtXm9811GE8FV5MJRtYDssCnZqwe", + saplingContract: "KT1Boe7jgyBWe9nmNrABpbi1Rr8CyLRp1RKo", + onChainViewContractAddress: "KT1DPEUrR9o4uBmGvF2EAMLiy1ehCQESTrzc", + ticketContract: "KT1EHcggVnBSEY2ypdyLy6yyr9HfuYWr7qH9", }; diff --git a/integration-tests/known-contracts-PsParisCZ.ts b/integration-tests/known-contracts-PsParisCZ.ts index b0023382d3..d0ca2efd16 100644 --- a/integration-tests/known-contracts-PsParisCZ.ts +++ b/integration-tests/known-contracts-PsParisCZ.ts @@ -5,4 +5,5 @@ export const knownContractsPsParisCZ: KnownContracts = { tzip12BigMapOffChainContract: "KT1WCxQmh7C3mBySMwPtGG3yt7jAyboUBHkb", saplingContract: "KT1MPrPW9qL4VSNmy55Pi6wJN5gVNHQzbEZi", onChainViewContractAddress: "KT1FXE4bisom2L7V8WC7DJ9NLkNYfwHFmD1h", + ticketContract: "KT1ByEfqipu4xP6LV9NKza1ctCgGKAJA1Ntw", }; diff --git a/integration-tests/known-contracts-PtGhostnet.ts b/integration-tests/known-contracts-PtGhostnet.ts index 72f9e4e32c..7fe2cc926e 100644 --- a/integration-tests/known-contracts-PtGhostnet.ts +++ b/integration-tests/known-contracts-PtGhostnet.ts @@ -5,4 +5,5 @@ export const knownContractsPtGhostnet: KnownContracts = { tzip12BigMapOffChainContract: "KT1JQQipASBXEvdWxRjUPjmTY6z4o8UWmZtA", saplingContract: "KT1F8BoKHeFTPDsTwSQmThwjSBjAjYgGgAGy", onChainViewContractAddress: "KT1LdBJDGN9svUfootxSGksoC7d78gNuzVXV", -} + ticketContract: "KT1Cb91wY3JdGtdM9JVJvGkzCVtCu4jH5ubf", +}; diff --git a/integration-tests/known-contracts-PtNairobi.ts b/integration-tests/known-contracts-PtNairobi.ts index b830cd3f4b..7ff72ab8e7 100644 --- a/integration-tests/known-contracts-PtNairobi.ts +++ b/integration-tests/known-contracts-PtNairobi.ts @@ -4,5 +4,6 @@ export const knownContractsPtNairobi: KnownContracts = { bigMapContract: "", tzip12BigMapOffChainContract: "", saplingContract: "", - onChainViewContractAddress: "" + onChainViewContractAddress: "", + ticketContract: "", }; \ No newline at end of file diff --git a/integration-tests/known-contracts.ts b/integration-tests/known-contracts.ts index 229b82a38e..fdc50ddf5f 100644 --- a/integration-tests/known-contracts.ts +++ b/integration-tests/known-contracts.ts @@ -4,4 +4,5 @@ export type KnownContracts = { onChainViewContractAddress: string; saplingContract: string; tzip12BigMapOffChainContract: string; + ticketContract: string; } diff --git a/integration-tests/originate-known-contracts.ts b/integration-tests/originate-known-contracts.ts index 946ed90d83..348d496611 100644 --- a/integration-tests/originate-known-contracts.ts +++ b/integration-tests/originate-known-contracts.ts @@ -1,5 +1,5 @@ import { CONFIGS } from './config'; -import { MichelsonMap, OriginateParams, RpcForger, TezosToolkit } from '@taquito/taquito'; +import { MichelsonMap, OriginateParams, RpcForger, TezosToolkit, UnitValue } from '@taquito/taquito'; import { singleSaplingStateContractJProtocol } from './data/single_sapling_state_contract_jakarta_michelson'; import { fa2ForTokenMetadataView } from './data/fa2-for-token-metadata-view'; import { stringToBytes } from '@taquito/utils'; @@ -7,6 +7,7 @@ import BigNumber from 'bignumber.js'; import { codeViewsTopLevel } from './data/contract_views_top_level'; import { knownBigMapContract } from './data/knownBigMapContract'; import { knownContract } from './data/knownContract'; +import { ticketsSendTz } from './data/code_with_ticket_transfer'; import * as fs from 'fs/promises'; const MUTEZ_UNIT = new BigNumber(1000000); @@ -174,6 +175,12 @@ CONFIGS().forEach(({ lib, setup, protocol }) => { storage: 2 }); + // knownTicketContract + await originateKnownContract('ticketContract', tezos, { + code: ticketsSendTz, + storage: UnitValue, + }); + await appendOutput('};'); await outputFile.close(); From 6a15d4bf3c05a67cb755c85bef10a48820194205 Mon Sep 17 00:00:00 2001 From: huianyang Date: Mon, 16 Dec 2024 14:44:35 -0800 Subject: [PATCH 06/10] test: rewrite prepare integration test and improve increasePaidStorage ux --- cspell.json | 1 + .../__tests__/prepare-operation.spec.ts | 472 ++++++++++++++---- packages/taquito-core/src/errors.ts | 6 +- .../src/contract/rpc-contract-provider.ts | 4 +- .../taquito/src/prepare/prepare-provider.ts | 16 +- 5 files changed, 394 insertions(+), 105 deletions(-) diff --git a/cspell.json b/cspell.json index 96d9172df5..f50522dcec 100644 --- a/cspell.json +++ b/cspell.json @@ -75,6 +75,7 @@ "oxheadalpha", "parisnet", "Pkhfrom", + "preapplied", "preattestation", "precommit", "preendorsement", diff --git a/integration-tests/__tests__/prepare-operation.spec.ts b/integration-tests/__tests__/prepare-operation.spec.ts index ba8e2aef8d..fb47e2c9ca 100644 --- a/integration-tests/__tests__/prepare-operation.spec.ts +++ b/integration-tests/__tests__/prepare-operation.spec.ts @@ -1,162 +1,438 @@ -import { OperationContentsBallot, OperationContentsTransaction } from '@taquito/rpc'; -import { OpKind } from '@taquito/taquito'; +import { OperationContentsAndResultDelegation, OperationContentsAndResultIncreasePaidStorage, OperationContentsAndResultOrigination, OperationContentsAndResultRegisterGlobalConstant, OperationContentsAndResultReveal, OperationContentsAndResultSmartRollupAddMessages, OperationContentsAndResultSmartRollupOriginate, OperationContentsAndResultTransaction, OperationContentsAndResultTransferTicket, OperationContentsAndResultUpdateConsensusKey, PvmKind } from '@taquito/rpc'; +import { OpKind, UnitValue, PreparedOperation } from '@taquito/taquito'; import { CONFIGS } from '../config'; import { LocalForger } from '@taquito/local-forging'; +const crypto = require('crypto'); -CONFIGS().forEach(({ lib, setup, protocol, createAddress }) => { +CONFIGS().forEach(({ lib, setup, createAddress, knownTicketContract }) => { const Tezos = lib; - let contractAddress: string; + let pkh: string; + let code = `parameter unit; storage unit; code {CAR; NIL operation; PAIR};`; + let localForger = new LocalForger(); + let prepared: PreparedOperation + let method: any, args: any describe(`Test Preparation of operations using the PrepareProvider`, () => { beforeAll(async () => { - await setup(); - - try { - const op = await Tezos.contract.originate({ - code: `{ parameter (or (or (int %decrement) (int %increment)) (unit %reset)) ; - storage int ; - code { UNPAIR ; - IF_LEFT { IF_LEFT { SWAP ; SUB } { ADD } } { DROP 2 ; PUSH int 0 } ; - NIL operation ; - PAIR } }`, - storage: 1 - }); - await op.confirmation(); - - contractAddress = op.contractAddress!; - - } catch (e: any) { - console.log('Unable to originate contract: ', JSON.stringify(e)); - } - + await setup(true); + pkh = await Tezos.signer.publicKeyHash(); }) - beforeEach(async () => { + it('should prepare a reveal operation correctly', async () => { + prepared = await Tezos.prepare.reveal({}) + expect(prepared).toBeDefined(); + expect(prepared.counter).toBeDefined(); + expect(prepared.opOb).toBeDefined(); + expect(prepared.opOb.branch).toBeDefined(); + expect(prepared.opOb.contents).toBeDefined(); + expect(prepared.opOb.contents[0].kind).toEqual('reveal'); }); - it('should be able to prepare a transaction operation', async () => { - const prepared = await Tezos.prepare.transaction({ - to: 'tz1QZ6KY7d3BuZDT1d19dUxoQrtFPN2QJ3hn', - amount: 5 - }); + it('should toForge a prepared reveal operation accepted by both forgers', async () => { + const toForge = await Tezos.prepare.toForge(prepared); + const localForged = await localForger.forge(toForge); + const rpcForged = await Tezos.rpc.forgeOperations(toForge); + expect(localForged).toEqual(rpcForged); + }); + + it('should toPreapply a prepared a reveal operation accepted by rpc', async () => { + const toPreapply = await Tezos.rpc.preapplyOperations(await Tezos.prepare.toPreapply(prepared)); + expect(toPreapply).toBeInstanceOf(Array); + expect(toPreapply[0].contents).toBeInstanceOf(Array); + const content = toPreapply[0].contents[0] as OperationContentsAndResultReveal; + expect(content).toBeInstanceOf(Object); + expect(content.kind).toEqual('reveal'); + expect(content.metadata).toBeInstanceOf(Object); + expect(content.metadata.operation_result).toBeInstanceOf(Object); + expect(content.metadata.operation_result.status).toEqual('applied'); + + // injected so the rest of tests will run smoothly + const op = await Tezos.contract.reveal({}) + await op.confirmation(); + }); + it('should prepare an originate operation correctly', async () => { + prepared = await Tezos.prepare.originate({ code, storage: UnitValue }); expect(prepared).toBeDefined(); expect(prepared.counter).toBeDefined(); expect(prepared.opOb).toBeDefined(); expect(prepared.opOb.branch).toBeDefined(); expect(prepared.opOb.contents).toBeDefined(); + expect(prepared.opOb.contents[0].kind).toEqual('origination'); + expect(prepared.opOb.protocol).toBeDefined(); + }) - const content = prepared.opOb.contents[0] as OperationContentsTransaction; + it('should toForge a prepared originate operation accepted by both forgers', async () => { + const toForge = await Tezos.prepare.toForge(prepared); + const localForged = await localForger.forge(toForge); + const rpcForged = await Tezos.rpc.forgeOperations(toForge); + expect(localForged).toEqual(rpcForged); + }); - expect(content.kind).toEqual('transaction'); - expect(content.destination).toEqual('tz1QZ6KY7d3BuZDT1d19dUxoQrtFPN2QJ3hn') - expect(content.amount).toEqual('5000000'); + it('should toPreapply a prepared originate operation accepted by rpc', async () => { + const toPreapply = await Tezos.rpc.preapplyOperations(await Tezos.prepare.toPreapply(prepared)); + expect(toPreapply).toBeInstanceOf(Array); + expect(toPreapply[0].contents).toBeInstanceOf(Array); + let content = toPreapply[0].contents[0] as OperationContentsAndResultOrigination; + expect(content).toBeInstanceOf(Object); + expect(content.kind).toEqual('origination'); + expect(content.metadata).toBeInstanceOf(Object); + expect(content.metadata.operation_result).toBeInstanceOf(Object); + expect(content.metadata.operation_result.status).toEqual('applied'); + }) + + it('should prepare a contract call operation correctly', async () => { + // send 3 tickets to the pkh + let contract = await Tezos.contract.at(knownTicketContract); + method = await contract.methodsObject.default({ 0: pkh, 1: '3' }); + + prepared = await Tezos.prepare.contractCall(method); + expect(prepared).toBeDefined(); + expect(prepared.counter).toBeDefined(); + expect(prepared.opOb).toBeDefined(); + expect(prepared.opOb.branch).toBeDefined(); + expect(prepared.opOb.contents).toBeDefined(); + expect(prepared.opOb.contents[0].kind).toEqual('transaction'); + expect(prepared.opOb.protocol).toBeDefined(); + }) + it('should toForge a prepared contract call operation accepted by both forgers', async () => { + const toForge = await Tezos.prepare.toForge(prepared); + const localForged = await localForger.forge(toForge); + const rpcForged = await Tezos.rpc.forgeOperations(toForge); + expect(localForged).toEqual(rpcForged); }); - it('should be able to prepare a batch operation', async () => { - const prepared = await Tezos.prepare.batch([ - { - kind: OpKind.TRANSACTION, - to: 'tz1QZ6KY7d3BuZDT1d19dUxoQrtFPN2QJ3hn', - amount: 2, - }, - { - kind: OpKind.TRANSACTION, - to: 'tz1QZ6KY7d3BuZDT1d19dUxoQrtFPN2QJ3hn', - amount: 2, - }, - ]); + it('should toPreapply a prepared contract call operation accepted by rpc', async () => { + const toPreapply = await Tezos.rpc.preapplyOperations(await Tezos.prepare.toPreapply(prepared)); + expect(toPreapply).toBeInstanceOf(Array); + expect(toPreapply[0].contents).toBeInstanceOf(Array); + let content = toPreapply[0].contents[0] as OperationContentsAndResultTransaction; + expect(content).toBeInstanceOf(Object); + expect(content.kind).toEqual('transaction'); + expect(content.metadata).toBeInstanceOf(Object); + expect(content.metadata.operation_result).toBeInstanceOf(Object); + expect(content.metadata.operation_result.status).toEqual('applied'); + + // injected so transferTicket test can run + const op = await method.send(); + await op.confirmation(); + }) + it('should prepare a transaction operation correctly', async () => { + prepared = await Tezos.prepare.transaction({ to: 'tz1QZ6KY7d3BuZDT1d19dUxoQrtFPN2QJ3hn', amount: 5 }); expect(prepared).toBeDefined(); expect(prepared.counter).toBeDefined(); expect(prepared.opOb).toBeDefined(); expect(prepared.opOb.branch).toBeDefined(); expect(prepared.opOb.contents).toBeDefined(); - expect(prepared.opOb.contents.length).toEqual(2); expect(prepared.opOb.contents[0].kind).toEqual('transaction'); - expect(prepared.opOb.contents[1].kind).toEqual('transaction'); + expect(prepared.opOb.protocol).toBeDefined(); + }) + it('should toForge a prepared transaction operation accepted by both forgers', async () => { + const toForge = await Tezos.prepare.toForge(prepared); + const localForged = await localForger.forge(toForge); + const rpcForged = await Tezos.rpc.forgeOperations(toForge); + expect(localForged).toEqual(rpcForged); }); - it('should be able to prepare a ballot operation', async () => { - const prepared = await Tezos.prepare.ballot({ - proposal: 'PtKathmankSpLLDALzWw7CGD2j2MtyveTwboEYokqUCP4a1LxMg', - ballot: 'yay' - }); + it('should toPreapply a prepared transaction operation accepted by rpc', async () => { + const toPreapply = await Tezos.rpc.preapplyOperations(await Tezos.prepare.toPreapply(prepared)); + expect(toPreapply).toBeInstanceOf(Array); + expect(toPreapply[0].contents).toBeInstanceOf(Array); + let content = toPreapply[0].contents[0] as OperationContentsAndResultTransaction; + expect(content).toBeInstanceOf(Object); + expect(content.kind).toEqual('transaction'); + expect(content.metadata).toBeInstanceOf(Object); + expect(content.metadata.operation_result).toBeInstanceOf(Object); + expect(content.metadata.operation_result.status).toEqual('applied'); + }) + it('should prepare a delegation operation correctly', async () => { + args = { source: pkh, delegate: pkh } + prepared = await Tezos.prepare.delegation(args); expect(prepared).toBeDefined(); expect(prepared.counter).toBeDefined(); expect(prepared.opOb).toBeDefined(); expect(prepared.opOb.branch).toBeDefined(); expect(prepared.opOb.contents).toBeDefined(); + expect(prepared.opOb.contents[0].kind).toEqual('delegation'); + expect(prepared.opOb.protocol).toBeDefined(); + }) - const content = prepared.opOb.contents[0] as OperationContentsBallot + it('should toForge a prepared delegation operation accepted by both forgers', async () => { + const toForge = await Tezos.prepare.toForge(prepared); + const localForged = await localForger.forge(toForge); + const rpcForged = await Tezos.rpc.forgeOperations(toForge); + expect(localForged).toEqual(rpcForged); + }); - expect(prepared.opOb.contents[0].kind).toEqual('ballot'); - expect(content.proposal).toEqual('PtKathmankSpLLDALzWw7CGD2j2MtyveTwboEYokqUCP4a1LxMg'); - expect(content.ballot).toEqual('yay'); - expect(prepared.opOb.protocol).toEqual(protocol); + it('should toPreapply a prepared delegation operation accepted by rpc', async () => { + const toPreapply = await Tezos.rpc.preapplyOperations(await Tezos.prepare.toPreapply(prepared)); + expect(toPreapply).toBeInstanceOf(Array); + expect(toPreapply[0].contents).toBeInstanceOf(Array); + let content = toPreapply[0].contents[0] as OperationContentsAndResultDelegation; + expect(content).toBeInstanceOf(Object); + expect(content.kind).toEqual('delegation'); + expect(content.metadata).toBeInstanceOf(Object); + expect(content.metadata.operation_result).toBeInstanceOf(Object); + expect(content.metadata.operation_result.status).toEqual('applied'); + + // injected so the updateConcensusKey test can run + const op = await Tezos.contract.setDelegate(args) + await op.confirmation(); + expect(op.includedInBlock).toBeDefined + }) + + it('should prepare a registerGlobalConstant operation correctly', async () => { + prepared = await Tezos.prepare.registerGlobalConstant({ value: { prim: 'list', args: [{ prim: 'nat' }], annots: [`%${crypto.randomBytes(3).toString('hex')}`] } }); + expect(prepared).toBeDefined(); + expect(prepared.counter).toBeDefined(); + expect(prepared.opOb).toBeDefined(); + expect(prepared.opOb.branch).toBeDefined(); + expect(prepared.opOb.contents).toBeDefined(); + expect(prepared.opOb.contents[0].kind).toEqual('register_global_constant'); + expect(prepared.opOb.protocol).toBeDefined(); + }) + + it('should toForge a prepared registerGlobalConstant operation accepted by both forgers', async () => { + const toForge = await Tezos.prepare.toForge(prepared); + const localForged = await localForger.forge(toForge); + const rpcForged = await Tezos.rpc.forgeOperations(toForge); + expect(localForged).toEqual(rpcForged); }); - it('should be able to prepare a contractCall', async () => { - const contractAbs = await Tezos.contract.at(contractAddress); - const method = await contractAbs.methods.increment(1); - const prepared = await Tezos.prepare.contractCall(method); + it('should toPreapply a prepared registerGlobalConstant operation accepted by rpc', async () => { + const toPreapply = await Tezos.rpc.preapplyOperations(await Tezos.prepare.toPreapply(prepared)); + expect(toPreapply).toBeInstanceOf(Array); + expect(toPreapply[0].contents).toBeInstanceOf(Array); + let content = toPreapply[0].contents[0] as OperationContentsAndResultRegisterGlobalConstant; + expect(content).toBeInstanceOf(Object); + expect(content.kind).toEqual('register_global_constant'); + expect(content.metadata).toBeInstanceOf(Object); + expect(content.metadata.operation_result).toBeInstanceOf(Object); + expect(content.metadata.operation_result.status).toEqual('applied'); + }) + it('should prepare a updateConcensusKey operation correctly', async () => { + let concensusAccount = await createAddress(); + // let fundOp = await Tezos.contract.transfer({ to: await concensusAccount.signer.publicKeyHash(), amount: 1 }); + // await fundOp.confirmation(); + + prepared = await Tezos.prepare.updateConsensusKey({ pk: await concensusAccount.signer.publicKey() }); expect(prepared).toBeDefined(); expect(prepared.counter).toBeDefined(); + expect(prepared.opOb).toBeDefined(); expect(prepared.opOb.branch).toBeDefined(); expect(prepared.opOb.contents).toBeDefined(); + expect(prepared.opOb.contents[0].kind).toEqual('update_consensus_key'); expect(prepared.opOb.protocol).toBeDefined(); + }) + it('should toForge a prepared updateConcensusKey operation accepted by both forgers', async () => { + const toForge = await Tezos.prepare.toForge(prepared); + const localForged = await localForger.forge(toForge); + const rpcForged = await Tezos.rpc.forgeOperations(toForge); + expect(localForged).toEqual(rpcForged); }); - }); - - describe('toPreapply conversion method', () => { - it('Verify toPreaplyParams returns executable params for preapplyOperations', async () => { - const receiver = await createAddress(); - - const pkh = await receiver.signer.publicKeyHash(); - const estimates = await Tezos.estimate.transfer({ to: pkh, amount: 1 }); - const preparedTransfer = await Tezos.prepare.transaction({ - amount: 1, - to: pkh, - fee: estimates.suggestedFeeMutez, - storageLimit: estimates.storageLimit, - gasLimit: estimates.gasLimit + + it('should toPreapply a prepared updateConcensusKey operation accepted by rpc', async () => { + const toPreapply = await Tezos.rpc.preapplyOperations(await Tezos.prepare.toPreapply(prepared)); + expect(toPreapply).toBeInstanceOf(Array); + expect(toPreapply[0].contents).toBeInstanceOf(Array); + let content = toPreapply[0].contents[0] as OperationContentsAndResultUpdateConsensusKey; + expect(content).toBeInstanceOf(Object); + expect(content.kind).toEqual('update_consensus_key'); + expect(content.metadata).toBeInstanceOf(Object); + expect(content.metadata.operation_result).toBeInstanceOf(Object); + expect(content.metadata.operation_result.status).toEqual('applied'); + }) + + it('should prepare a transferTicket operation correctly', async () => { + prepared = await Tezos.prepare.transferTicket({ + ticketContents: { string: "Ticket" }, + ticketTy: { prim: "string" }, + ticketTicketer: knownTicketContract, + ticketAmount: 1, + destination: pkh, + entrypoint: 'default', }); + expect(prepared).toBeDefined(); + expect(prepared.counter).toBeDefined(); + expect(prepared.opOb).toBeDefined(); + expect(prepared.opOb.branch).toBeDefined(); + expect(prepared.opOb.contents).toBeDefined(); + expect(prepared.opOb.contents[0].kind).toEqual('transfer_ticket'); + expect(prepared.opOb.protocol).toBeDefined(); + }) - const preapplyParams = await Tezos.prepare.toPreapply(preparedTransfer) - const preapply = await Tezos.rpc.preapplyOperations(preapplyParams); + it('should toForge a prepared transferTicket operation accepted by both forgers', async () => { + const toForge = await Tezos.prepare.toForge(prepared); + const localForged = await localForger.forge(toForge); + const rpcForged = await Tezos.rpc.forgeOperations(toForge); + expect(localForged).toEqual(rpcForged); + }); - expect(preapplyParams[0].contents).toEqual(preparedTransfer.opOb.contents) - expect(preapplyParams[0].branch).toEqual(preparedTransfer.opOb.branch) + it('should toPreapply a prepared transferTicket operation accepted by rpc', async () => { + const toPreapply = await Tezos.rpc.preapplyOperations(await Tezos.prepare.toPreapply(prepared)); + expect(toPreapply).toBeInstanceOf(Array); + expect(toPreapply[0].contents).toBeInstanceOf(Array); + let content = toPreapply[0].contents[0] as OperationContentsAndResultTransferTicket; + expect(content).toBeInstanceOf(Object); + expect(content.kind).toEqual('transfer_ticket'); + expect(content.metadata).toBeInstanceOf(Object); + expect(content.metadata.operation_result).toBeInstanceOf(Object); + expect(content.metadata.operation_result.status).toEqual('applied'); + }) - if (preapply[0].contents[0].kind === 'reveal') { - expect(preapply[0].contents[0].kind).toEqual('reveal'); - expect(preapply[0].contents[1].kind).toEqual('transaction'); - } else { - expect(preapply[0].contents[0].kind).toEqual('transaction'); + it('should prepare a increasePaidStorage operation correctly', async () => { + prepared = await Tezos.prepare.increasePaidStorage({ amount: 1, destination: knownTicketContract }); + expect(prepared).toBeDefined(); + expect(prepared.counter).toBeDefined(); + expect(prepared.opOb).toBeDefined(); + expect(prepared.opOb.branch).toBeDefined(); + expect(prepared.opOb.contents).toBeDefined(); + expect(prepared.opOb.contents[0].kind).toEqual('increase_paid_storage'); + expect(prepared.opOb.protocol).toBeDefined(); + }) + + it('should toForge a prepared increasePaidStorage operation accepted by both forgers', async () => { + const toForge = await Tezos.prepare.toForge(prepared); + const localForged = await localForger.forge(toForge); + const rpcForged = await Tezos.rpc.forgeOperations(toForge); + expect(localForged).toEqual(rpcForged); + }); + + it('should toPreapply a prepared increasePaidStorage operation accepted by rpc', async () => { + const toPreapply = await Tezos.rpc.preapplyOperations(await Tezos.prepare.toPreapply(prepared)); + expect(toPreapply).toBeInstanceOf(Array); + expect(toPreapply[0].contents).toBeInstanceOf(Array); + let content = toPreapply[0].contents[0] as OperationContentsAndResultIncreasePaidStorage; + expect(content).toBeInstanceOf(Object); + expect(content.kind).toEqual('increase_paid_storage'); + expect(content.metadata).toBeInstanceOf(Object); + expect(content.metadata.operation_result).toBeInstanceOf(Object); + expect(content.metadata.operation_result.status).toEqual('applied'); + }) + + it('should prepare a smartRollupOriginate operation correctly', async () => { + args = { + pvmKind: PvmKind.WASM2, + kernel: '23212f7573722f62696e2f656e762073680a6578706f7274204b45524e454c3d22303036313733366430313030303030303031323830373630303337663766376630313766363030323766376630313766363030353766376637663766376630313766363030313766303036303031376630313766363030323766376630303630303030303032363130333131373336643631373237343566373236663663366337353730356636333666373236353061373236353631363435663639366537303735373430303030313137333664363137323734356637323666366336633735373035663633366637323635306337373732363937343635356636663735373437303735373430303031313137333664363137323734356637323666366336633735373035663633366637323635306237333734366637323635356637373732363937343635303030323033303530343033303430353036303530333031303030313037313430323033366436353664303230303061366236353732366536353663356637323735366530303036306161343031303432613031303237663431666130303266303130303231303132303030326630313030323130323230303132303032343730343430343165343030343131323431303034316534303034313030313030323161306230623038303032303030343163343030366230623530303130353766343166653030326430303030323130333431666330303266303130303231303232303030326430303030323130343230303032663031303032313035323030313130303432313036323030343230303334363034343032303030343130313661323030313431303136623130303131613035323030353230303234363034343032303030343130373661323030363130303131613062306230623164303130313766343164633031343138343032343139303163313030303231303034313834303232303030313030353431383430323130303330623062333830353030343165343030306231323266366236353732366536353663326636353665373632663732363536323666366637343030343166383030306230323030303130303431666130303062303230303032303034316663303030623032303030303030343166653030306230313031220a', + parametersType: { prim: 'bytes' } } + prepared = await Tezos.prepare.smartRollupOriginate(args); + expect(prepared).toBeDefined(); + expect(prepared.counter).toBeDefined(); + expect(prepared.opOb).toBeDefined(); + expect(prepared.opOb.branch).toBeDefined(); + expect(prepared.opOb.contents).toBeDefined(); + expect(prepared.opOb.contents[0].kind).toEqual('smart_rollup_originate'); + expect(prepared.opOb.protocol).toBeDefined(); + }) + it('should toForge a prepared smartRollupOriginate operation accepted accepted by both forgers', async () => { + const toForge = await Tezos.prepare.toForge(prepared); + const localForged = await localForger.forge(toForge); + const rpcForged = await Tezos.rpc.forgeOperations(toForge); + expect(localForged).toEqual(rpcForged); }); - }); - describe('toForge conversion method', () => { + it('should toPreapply a prepared smartRollupOriginate operation accepted by rpc', async () => { + const toPreapply = await Tezos.rpc.preapplyOperations(await Tezos.prepare.toPreapply(prepared)); + expect(toPreapply).toBeInstanceOf(Array); + expect(toPreapply[0].contents).toBeInstanceOf(Array); + let content = toPreapply[0].contents[0] as OperationContentsAndResultSmartRollupOriginate; + expect(content).toBeInstanceOf(Object); + expect(content.kind).toEqual('smart_rollup_originate'); + expect(content.metadata).toBeInstanceOf(Object); + expect(content.metadata.operation_result).toBeInstanceOf(Object); + expect(content.metadata.operation_result.status).toEqual('applied'); + + // injected so smart-rollup-add-messages test can run + const op = await Tezos.contract.smartRollupOriginate(args) + await op.confirmation(); + }) + + it('should prepare a smartRollupAddMessages operation correctly', async () => { + prepared = await Tezos.prepare.smartRollupAddMessages({ message: ['0000000031010000000b48656c6c6f20776f726c6401bdb6f61e4f12c952f807ae7d3341af5367887dac000000000764656661756c74'] }); + expect(prepared).toBeDefined(); + expect(prepared.counter).toBeDefined(); + expect(prepared.opOb).toBeDefined(); + expect(prepared.opOb.branch).toBeDefined(); + expect(prepared.opOb.contents).toBeDefined(); + expect(prepared.opOb.contents[0].kind).toEqual('smart_rollup_add_messages'); + expect(prepared.opOb.protocol).toBeDefined(); + }) - it('Verify that toForge is executable for both local forger and rpc.forgeOperations', async () => { - const receiver = await createAddress(); - const pkh = await receiver.signer.publicKeyHash(); - const preparedTransfer = await Tezos.prepare.transaction({ amount: 1, to: pkh }); - const forger = new LocalForger(); + it('should toForge a prepared smartRollupAddMessages operation accepted by both forgers', async () => { + const toForge = await Tezos.prepare.toForge(prepared); + const localForged = await localForger.forge(toForge); + const rpcForged = await Tezos.rpc.forgeOperations(toForge); + expect(localForged).toEqual(rpcForged); + }); - const forged = await forger.forge(Tezos.prepare.toForge(preparedTransfer)); - const rpcForged = await Tezos.rpc.forgeOperations(Tezos.prepare.toForge(preparedTransfer)); + it('should toPreapply a prepared smartRollupAddMessages operation accepted by rpc', async () => { + const toPreapply = await Tezos.rpc.preapplyOperations(await Tezos.prepare.toPreapply(prepared)); + expect(toPreapply).toBeInstanceOf(Array); + expect(toPreapply[0].contents).toBeInstanceOf(Array); + let content = toPreapply[0].contents[0] as OperationContentsAndResultSmartRollupAddMessages; + expect(content).toBeInstanceOf(Object); + expect(content.kind).toEqual('smart_rollup_add_messages'); + expect(content.metadata).toBeInstanceOf(Object); + expect(content.metadata.operation_result).toBeInstanceOf(Object); + expect(content.metadata.operation_result.status).toEqual('applied'); + }) - expect(forged).toEqual(rpcForged); + it('should prepare a batch operation correctly', async () => { + prepared = await Tezos.prepare.batch([ + { + kind: OpKind.TRANSACTION, + to: 'tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb', + amount: 1, + }, + { + kind: OpKind.ORIGINATION, + code, + storage: UnitValue, + }, + ]); + expect(prepared).toBeDefined(); + expect(prepared.counter).toBeDefined(); + expect(prepared.opOb).toBeDefined(); + expect(prepared.opOb.branch).toBeDefined(); + expect(prepared.opOb.contents).toBeDefined(); + expect(prepared.opOb.contents[0].kind).toEqual('transaction'); + expect(prepared.opOb.contents[1].kind).toEqual('origination'); + expect(prepared.opOb.protocol).toBeDefined(); + }) + it('should toForge a prepared batch operation accepted by both forgers', async () => { + const toForge = await Tezos.prepare.toForge(prepared); + const localForged = await localForger.forge(toForge); + const rpcForged = await Tezos.rpc.forgeOperations(toForge); + expect(localForged).toEqual(rpcForged); }); - }); -}) + it('should toPreapply a prepared batch operation accepted by rpc', async () => { + const toPreapply = await Tezos.rpc.preapplyOperations(await Tezos.prepare.toPreapply(prepared)); + expect(toPreapply).toBeInstanceOf(Array); + expect(toPreapply[0].contents).toBeInstanceOf(Array); + + let content0 = toPreapply[0].contents[0] as OperationContentsAndResultTransaction; + expect(content0).toBeInstanceOf(Object); + expect(content0.kind).toEqual('transaction'); + expect(content0.metadata).toBeInstanceOf(Object); + expect(content0.metadata.operation_result).toBeInstanceOf(Object); + expect(content0.metadata.operation_result.status).toEqual('applied'); + + let content1 = toPreapply[0].contents[1] as OperationContentsAndResultOrigination; + expect(content1).toBeInstanceOf(Object); + expect(content1.kind).toEqual('origination'); + expect(content1.metadata).toBeInstanceOf(Object); + expect(content1.metadata.operation_result).toBeInstanceOf(Object); + expect(content1.metadata.operation_result.status).toEqual('applied'); + }) + }) +}) \ No newline at end of file diff --git a/packages/taquito-core/src/errors.ts b/packages/taquito-core/src/errors.ts index 192147c35a..cbc4b1e0bd 100644 --- a/packages/taquito-core/src/errors.ts +++ b/packages/taquito-core/src/errors.ts @@ -105,10 +105,14 @@ export class InvalidBlockHashError extends ParameterValidationError { * @description Error that indicates an invalid amount of tez being passed as a parameter */ export class InvalidAmountError extends ParameterValidationError { - constructor(public readonly amount: string) { + constructor( + public readonly amount: string, + public readonly errorDetail?: string + ) { super(); this.name = 'InvalidAmountError'; this.message = `Invalid amount "${amount}"`; + this.message += errorDetail ? ` ${errorDetail}.` : '.'; } } diff --git a/packages/taquito/src/contract/rpc-contract-provider.ts b/packages/taquito/src/contract/rpc-contract-provider.ts index d4d490981d..705e4cb056 100644 --- a/packages/taquito/src/contract/rpc-contract-provider.ts +++ b/packages/taquito/src/contract/rpc-contract-provider.ts @@ -626,8 +626,8 @@ export class RpcContractProvider extends Provider implements ContractProvider, S * @param params increasePaidStorage operation parameter */ async increasePaidStorage(params: IncreasePaidStorageParams) { - if (params.amount < 0) { - throw new InvalidAmountError(params.amount.toString()); + if (params.amount <= 0) { + throw new InvalidAmountError(params.amount.toString(), 'amount must be greater than 0'); } const publicKeyHash = await this.signer.publicKeyHash(); const estimate = await this.estimate( diff --git a/packages/taquito/src/prepare/prepare-provider.ts b/packages/taquito/src/prepare/prepare-provider.ts index ffa59b6de5..f9b11f09cd 100644 --- a/packages/taquito/src/prepare/prepare-provider.ts +++ b/packages/taquito/src/prepare/prepare-provider.ts @@ -35,7 +35,12 @@ import { import { PreparationProvider, PreparedOperation } from './interface'; import { REVEAL_STORAGE_LIMIT, Protocols, getRevealFee, getRevealGasLimit } from '../constants'; import { RPCResponseError } from '../errors'; -import { PublicKeyNotFoundError, InvalidOperationKindError, DeprecationError } from '@taquito/core'; +import { + PublicKeyNotFoundError, + InvalidOperationKindError, + DeprecationError, + InvalidAmountError, +} from '@taquito/core'; import { Context } from '../context'; import { ContractMethod } from '../contract/contract-methods/contract-method-flat-param'; import { ContractMethodObject } from '../contract/contract-methods/contract-method-object-param'; @@ -276,7 +281,7 @@ export class PrepareProvider extends Provider implements PreparationProvider { return { ...op, ...this.getSource(op, pkh, source), - period: currentVotingPeriod?.voting_period.index, + period: currentVotingPeriod.voting_period.index, }; default: throw new InvalidOperationKindError((op as RPCOperation).kind); @@ -779,6 +784,9 @@ export class PrepareProvider extends Provider implements PreparationProvider { gasLimit, ...rest }: IncreasePaidStorageParams): Promise { + if (rest.amount <= 0) { + throw new InvalidAmountError(rest.amount.toString(), 'amount must be greater than 0'); + } const { pkh } = await this.getKeys(); const protocolConstants = await this.context.readProvider.getProtocolConstants('head'); @@ -843,7 +851,7 @@ export class PrepareProvider extends Provider implements PreparationProvider { ops, headCounter, pkh, - undefined, + params.source, currentVotingPeriod ); @@ -890,7 +898,7 @@ export class PrepareProvider extends Provider implements PreparationProvider { ops, headCounter, pkh, - undefined, + params.source, currentVotingPeriod ); From 9e741a3ddfcaf34191ec68c295271173bef45d17 Mon Sep 17 00:00:00 2001 From: huianyang Date: Tue, 17 Dec 2024 10:43:13 -0800 Subject: [PATCH 07/10] test: revamp sandbox-proposal-and-ballot-operation.spec.ts --- .../__tests__/prepare-operation.spec.ts | 2 +- ...dbox-proposal-and-ballot-operation.spec.ts | 119 ++++++++++++------ package-lock.json | 36 +++--- website/package-lock.json | 40 +++--- 4 files changed, 122 insertions(+), 75 deletions(-) diff --git a/integration-tests/__tests__/prepare-operation.spec.ts b/integration-tests/__tests__/prepare-operation.spec.ts index fb47e2c9ca..8181e91638 100644 --- a/integration-tests/__tests__/prepare-operation.spec.ts +++ b/integration-tests/__tests__/prepare-operation.spec.ts @@ -12,7 +12,7 @@ CONFIGS().forEach(({ lib, setup, createAddress, knownTicketContract }) => { let prepared: PreparedOperation let method: any, args: any - describe(`Test Preparation of operations using the PrepareProvider`, () => { + describe(`Test Preparation of operations using PrepareProvider`, () => { beforeAll(async () => { await setup(true); pkh = await Tezos.signer.publicKeyHash(); diff --git a/integration-tests/__tests__/tezbox/sandbox-proposal-and-ballot-operation.spec.ts b/integration-tests/__tests__/tezbox/sandbox-proposal-and-ballot-operation.spec.ts index f1376734ac..6253a38a9a 100644 --- a/integration-tests/__tests__/tezbox/sandbox-proposal-and-ballot-operation.spec.ts +++ b/integration-tests/__tests__/tezbox/sandbox-proposal-and-ballot-operation.spec.ts @@ -1,6 +1,7 @@ import { CONFIGS, isSandbox, sleep } from '../../config'; import { TezosToolkit } from '@taquito/taquito'; import { InMemorySigner } from '@taquito/signer'; +import { LocalForger } from '@taquito/local-forging'; import { OperationContentsAndResultBallot, OperationContentsAndResultProposals, VotingPeriodBlockResult, OperationContentsProposals } from '@taquito/rpc'; CONFIGS().forEach(async ({ rpc, protocol }) => { @@ -8,12 +9,22 @@ CONFIGS().forEach(async ({ rpc, protocol }) => { const baker1 = new TezosToolkit(rpc); const baker2 = new TezosToolkit(rpc); const baker3 = new TezosToolkit(rpc); + let localForger = new LocalForger(); const proposal = 'ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK'; const ballot = 'yay'; + let prepared: any; let blockTime: number let currentPeriod: VotingPeriodBlockResult; - describe(`Test Proposal and Ballot operation in ${protocol.substring(0, 8)} with tezbox`, () => { + async function sleepUntil(period: string): Promise { + currentPeriod = await baker1.rpc.getCurrentPeriod(); + while (currentPeriod.voting_period.kind !== period) { + await sleep(((currentPeriod.remaining + 1) * blockTime) * 1000) + currentPeriod = await baker1.rpc.getCurrentPeriod() + } + } + + describe(`Test Preparation of proposals and ballot ops using PrepareProvider in ${protocol.substring(0, 8)} with tezbox`, () => { beforeAll(async () => { // tezbox provision of 3 bakers, ref https://github.com/tez-capital/tezbox/blob/main/configuration/bakers.hjson baker1.setSignerProvider(new InMemorySigner('edsk4ArLQgBTLWG5FJmnGnT689VKoqhXwmDPBuGx3z4cvwU9MmrPZZ')); @@ -25,27 +36,44 @@ CONFIGS().forEach(async ({ rpc, protocol }) => { blockTime = constants.minimal_block_delay!.toNumber(); }); - tezboxnet('Should be able to prepare proposal accepted by preapply endpoint', async () => { - // check if it's in proposal period to start proposal test - currentPeriod = await baker1.rpc.getCurrentPeriod(); - while (currentPeriod.voting_period.kind !== 'proposal') { - await sleep(((currentPeriod.remaining + 1) * blockTime) * 1000) - currentPeriod = await baker1.rpc.getCurrentPeriod() - } - - const proposalPrepared = await baker1.prepare.proposals({ proposals: [proposal] }); - const proposalPreapplied = await baker1.rpc.preapplyOperations(await baker1.prepare.toPreapply(proposalPrepared)); - - expect(proposalPreapplied).toBeInstanceOf(Array); - expect(proposalPreapplied[0].contents).toBeInstanceOf(Array); - expect(proposalPreapplied[0].contents[0].kind).toBe('proposals'); - expect((proposalPreapplied[0].contents[0] as OperationContentsAndResultProposals).source).toBe(await baker1.signer.publicKeyHash()); - expect((proposalPreapplied[0].contents[0] as OperationContentsAndResultProposals).period).toBe((proposalPrepared.opOb.contents[0] as OperationContentsProposals).period); - expect((proposalPreapplied[0].contents[0] as OperationContentsAndResultProposals).proposals).toBeInstanceOf(Array); - expect((proposalPreapplied[0].contents[0] as OperationContentsAndResultProposals).proposals[0]).toEqual(proposal); + tezboxnet('should prepare a proposals operation correctly in proposal period', async () => { + await sleepUntil('proposal') + + prepared = await baker1.prepare.proposals({ proposals: [proposal] }); + expect(prepared).toBeDefined(); + expect(prepared.counter).toBeDefined(); + expect(prepared.opOb).toBeDefined(); + expect(prepared.opOb.branch).toBeDefined(); + expect(prepared.opOb.contents).toBeDefined(); + expect(prepared.opOb.contents[0].kind).toEqual('proposals'); }); - tezboxnet('Should be able to inject proposal operation in proposal period', async () => { + tezboxnet('should toForge a prepared proposals operation accepted by both forgers', async () => { + const toForge = await baker1.prepare.toForge(prepared); + const localForged = await localForger.forge(toForge); + const rpcForged = await baker1.rpc.forgeOperations(toForge); + expect(localForged).toEqual(rpcForged); + }) + + tezboxnet('should toPreapply a prepared a proposals operation accepted by rpc in proposal period', async () => { + await sleepUntil('proposal') + + const toPreapply = await baker1.rpc.preapplyOperations(await baker1.prepare.toPreapply(prepared)); + expect(toPreapply).toBeInstanceOf(Array); + expect(toPreapply[0].contents).toBeInstanceOf(Array); + const content = toPreapply[0].contents[0] as OperationContentsAndResultProposals; + expect(content).toBeInstanceOf(Object); + expect(content.kind).toEqual('proposals'); + expect((toPreapply[0].contents[0] as OperationContentsAndResultProposals).source).toBe(await baker1.signer.publicKeyHash()); + expect((toPreapply[0].contents[0] as OperationContentsAndResultProposals).period).toBe((prepared.opOb.contents[0] as OperationContentsProposals).period); + expect((toPreapply[0].contents[0] as OperationContentsAndResultProposals).proposals).toBeInstanceOf(Array); + expect((toPreapply[0].contents[0] as OperationContentsAndResultProposals).proposals[0]).toEqual(proposal); + + }) + + tezboxnet('Should be able to inject proposals operation in proposal period', async () => { + await sleepUntil('proposal') + const proposalsOp = await baker1.contract.proposals({ proposals: [proposal] }); @@ -67,25 +95,44 @@ CONFIGS().forEach(async ({ rpc, protocol }) => { expect(baker3Op.includedInBlock).toBeDefined(); }); - tezboxnet('Should be able to prepare ballot operations accepted by preapply endpoint', async () => { - // if it's still proposal period make the test sleep to get into exploration period to inject ballot operation - while (currentPeriod.voting_period.kind !== 'exploration') { - await sleep(((currentPeriod.remaining + 1) * blockTime) * 1000) - currentPeriod = await baker1.rpc.getCurrentPeriod() - } - - const ballotPrepared = await baker1.prepare.ballot({ proposal, ballot }); - const preappliedBallot = await baker1.rpc.preapplyOperations(await baker1.prepare.toPreapply(ballotPrepared)); - - expect(preappliedBallot).toBeInstanceOf(Array); - expect(preappliedBallot[0].contents).toBeInstanceOf(Array); - expect(preappliedBallot[0].contents[0].kind).toEqual('ballot'); - expect((preappliedBallot[0].contents[0] as OperationContentsAndResultBallot).source).toEqual(await baker1.signer.publicKeyHash()); - expect((preappliedBallot[0].contents[0] as OperationContentsAndResultBallot).proposal).toEqual(proposal); - expect((preappliedBallot[0].contents[0] as OperationContentsAndResultBallot).ballot).toEqual(ballot); + tezboxnet('should prepare a ballot operation correctly in exploration period', async () => { + // if it's still proposal period make the test sleep to get into exploration period to prepare ballot operation + await sleepUntil('exploration') + + prepared = await baker1.prepare.ballot({ proposal, ballot }); + expect(prepared).toBeDefined(); + expect(prepared.counter).toBeDefined(); + expect(prepared.opOb).toBeDefined(); + expect(prepared.opOb.branch).toBeDefined(); + expect(prepared.opOb.contents).toBeDefined(); + expect(prepared.opOb.contents[0].kind).toEqual('ballot'); }); + tezboxnet('Should be able to forge ballot operations accepted by both forgers', async () => { + const toForge = await baker1.prepare.toForge(prepared); + const localForged = await localForger.forge(toForge); + const rpcForged = await baker1.rpc.forgeOperations(toForge); + expect(localForged).toEqual(rpcForged); + }) + + it('should toPreapply a prepared a ballot operation accepted by rpc in proposal period in exploration period', async () => { + // if it's still proposal period make the test sleep to get into exploration period to preapply ballot operation + await sleepUntil('exploration') + + const toPreapply = await baker1.rpc.preapplyOperations(await baker1.prepare.toPreapply(prepared)); + expect(toPreapply).toBeInstanceOf(Array); + expect(toPreapply[0].contents).toBeInstanceOf(Array); + const content = toPreapply[0].contents[0] as OperationContentsAndResultBallot; + expect(content).toBeInstanceOf(Object); + expect(content.kind).toEqual('ballot'); + expect((toPreapply[0].contents[0] as OperationContentsAndResultBallot).source).toEqual(await baker1.signer.publicKeyHash()); + expect((toPreapply[0].contents[0] as OperationContentsAndResultBallot).proposal).toEqual(proposal); + expect((toPreapply[0].contents[0] as OperationContentsAndResultBallot).ballot).toEqual(ballot); + }) tezboxnet('Should be able to inject ballot operation in exploration period', async () => { + // if it's still proposal period make the test sleep to get into exploration period to inject ballot operation + await sleepUntil('exploration') + const explorationBallotOp = await baker1.contract.ballot({ proposal, ballot diff --git a/package-lock.json b/package-lock.json index ac7ddb6e18..5a60bb6adb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28157,7 +28157,7 @@ "webpack-subresource-integrity": "^5.1.0" }, "engines": { - "node": ">=20" + "node": ">=18" } }, "packages/taquito-beacon-wallet": { @@ -28202,7 +28202,7 @@ "webpack-cli": "^5.1.4" }, "engines": { - "node": ">=20" + "node": ">=18" } }, "packages/taquito-beacon-wallet/node_modules/@types/chrome": { @@ -28256,7 +28256,7 @@ "typescript": "~5.5.4" }, "engines": { - "node": ">=20" + "node": ">=18" } }, "packages/taquito-core": { @@ -28272,7 +28272,7 @@ "rollup-plugin-typescript2": "^0.36.0" }, "engines": { - "node": ">=20" + "node": ">=18" } }, "packages/taquito-http-utils": { @@ -28313,7 +28313,7 @@ "typescript": "~5.5.4" }, "engines": { - "node": ">=20" + "node": ">=18" } }, "packages/taquito-http-utils/node_modules/node-fetch": { @@ -28377,7 +28377,7 @@ "typescript": "~5.5.4" }, "engines": { - "node": ">=20" + "node": ">=18" } }, "packages/taquito-ledger-signer/node_modules/buffer": { @@ -28447,7 +28447,7 @@ "webpack-cli": "^5.1.4" }, "engines": { - "node": ">=20" + "node": ">=18" } }, "packages/taquito-michel-codec": { @@ -28480,7 +28480,7 @@ "typescript": "~5.5.4" }, "engines": { - "node": ">=20" + "node": ">=18" } }, "packages/taquito-michel-codec/pack-test-tool": { @@ -28530,7 +28530,7 @@ "typescript": "~5.5.4" }, "engines": { - "node": ">=20" + "node": ">=18" } }, "packages/taquito-remote-signer": { @@ -28575,7 +28575,7 @@ "typescript": "~5.5.4" }, "engines": { - "node": ">=20" + "node": ">=18" } }, "packages/taquito-rpc": { @@ -28616,7 +28616,7 @@ "typescript": "~5.5.4" }, "engines": { - "node": ">=20" + "node": ">=18" } }, "packages/taquito-sapling": { @@ -28667,7 +28667,7 @@ "typescript": "~5.5.4" }, "engines": { - "node": ">=20" + "node": ">=18" } }, "packages/taquito-sapling/node_modules/node-fetch": { @@ -28741,7 +28741,7 @@ "typescript": "~5.5.4" }, "engines": { - "node": ">=20" + "node": ">=18" } }, "packages/taquito-timelock": { @@ -28782,7 +28782,7 @@ "typescript": "^5.5.4" }, "engines": { - "node": ">=20" + "node": ">=18" } }, "packages/taquito-tzip12": { @@ -28824,7 +28824,7 @@ "typescript": "~5.5.4" }, "engines": { - "node": ">=20" + "node": ">=18" } }, "packages/taquito-tzip16": { @@ -28871,7 +28871,7 @@ "typescript": "~5.5.4" }, "engines": { - "node": ">=20" + "node": ">=18" } }, "packages/taquito-utils": { @@ -28919,7 +28919,7 @@ "typescript": "~5.5.4" }, "engines": { - "node": ">=20" + "node": ">=18" } }, "packages/taquito-utils/node_modules/buffer": { @@ -28988,7 +28988,7 @@ "typescript": "~5.5.4" }, "engines": { - "node": ">=20" + "node": ">=18" } }, "packages/taquito-wallet-connect-2": { diff --git a/website/package-lock.json b/website/package-lock.json index 398e55cf7e..e45de2bd18 100644 --- a/website/package-lock.json +++ b/website/package-lock.json @@ -123,7 +123,7 @@ "webpack-subresource-integrity": "^5.1.0" }, "engines": { - "node": ">=20" + "node": ">=18" } }, "../packages/taquito-beacon-wallet": { @@ -168,7 +168,7 @@ "webpack-cli": "^5.1.4" }, "engines": { - "node": ">=20" + "node": ">=18" } }, "../packages/taquito-core": { @@ -184,7 +184,7 @@ "rollup-plugin-typescript2": "^0.36.0" }, "engines": { - "node": ">=20" + "node": ">=18" } }, "../packages/taquito-http-utils": { @@ -225,7 +225,7 @@ "typescript": "~5.5.4" }, "engines": { - "node": ">=20" + "node": ">=18" } }, "../packages/taquito-ledger-signer": { @@ -269,7 +269,7 @@ "typescript": "~5.5.4" }, "engines": { - "node": ">=20" + "node": ">=18" } }, "../packages/taquito-michel-codec": { @@ -302,7 +302,7 @@ "typescript": "~5.5.4" }, "engines": { - "node": ">=20" + "node": ">=18" } }, "../packages/taquito-michelson-encoder": { @@ -344,7 +344,7 @@ "typescript": "~5.5.4" }, "engines": { - "node": ">=20" + "node": ">=18" } }, "../packages/taquito-remote-signer": { @@ -389,7 +389,7 @@ "typescript": "~5.5.4" }, "engines": { - "node": ">=20" + "node": ">=18" } }, "../packages/taquito-rpc": { @@ -430,7 +430,7 @@ "typescript": "~5.5.4" }, "engines": { - "node": ">=20" + "node": ">=18" } }, "../packages/taquito-signer": { @@ -484,7 +484,7 @@ "typescript": "~5.5.4" }, "engines": { - "node": ">=20" + "node": ">=18" } }, "../packages/taquito-tzip12": { @@ -526,7 +526,7 @@ "typescript": "~5.5.4" }, "engines": { - "node": ">=20" + "node": ">=18" } }, "../packages/taquito-tzip16": { @@ -573,7 +573,7 @@ "typescript": "~5.5.4" }, "engines": { - "node": ">=20" + "node": ">=18" } }, "../packages/taquito-utils": { @@ -621,7 +621,7 @@ "typescript": "~5.5.4" }, "engines": { - "node": ">=20" + "node": ">=18" } }, "../packages/taquito-wallet-connect": { @@ -666,7 +666,7 @@ "typescript": "~5.5.4" }, "engines": { - "node": ">=20" + "node": ">=18" } }, "../packages/taquito-wallet-connect-2": { @@ -10766,9 +10766,9 @@ } }, "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", "license": "MIT", "dependencies": { "path-key": "^3.1.0", @@ -17649,9 +17649,9 @@ "license": "ISC" }, "node_modules/nanoid": { - "version": "3.3.7", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", - "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.8.tgz", + "integrity": "sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==", "funding": [ { "type": "github", From 599ee0317b9c6a12f98139a72d1ae90ff3a3efcc Mon Sep 17 00:00:00 2001 From: huianyang Date: Tue, 17 Dec 2024 14:34:58 -0800 Subject: [PATCH 08/10] test: re-orgonised sandbox doc and sandbox tests --- .github/workflows/main.yml | 7 +-- docs/metadata-tzip16.md | 2 +- integration-tests/README.md | 24 +++++++--- ...dbox-proposal-and-ballot-operation.spec.ts | 2 +- integration-tests/package.json | 1 - integration-tests/sandbox-env.sh | 8 ++-- sandbox-bakers.sh | 48 ------------------- 7 files changed, 25 insertions(+), 67 deletions(-) delete mode 100755 sandbox-bakers.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 66c7c7f5fa..09d6f3321b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -81,9 +81,6 @@ jobs: run: npm -w integration-tests run sandbox:${{ matrix.testnet }} - run: npm ci - run: npm run build - - run: npm -w integration-tests run test __tests__/tezbox/sandbox-proposal-and-ballot-operation.spec.ts + - run: npm -w integration-tests run test __tests__/tezbox/ env: - TEZOS_RPC_${{ matrix.testnet_uppercase }}: http://0.0.0.0:8732 - - run: npm -w integration-tests run test __tests__/tezbox/sandbox-drain-delegate-operation.spec - env: - TEZOS_RPC_${{ matrix.testnet_uppercase }}: http://0.0.0.0:8732 + TEZOS_RPC_${{ matrix.testnet_uppercase }}: http://0.0.0.0:8732 \ No newline at end of file diff --git a/docs/metadata-tzip16.md b/docs/metadata-tzip16.md index 2268343d3e..346c2281aa 100644 --- a/docs/metadata-tzip16.md +++ b/docs/metadata-tzip16.md @@ -44,7 +44,7 @@ const Tezos = new TezosToolkit('rpcUrl'); // The constructor of the `MetadataProvider` class takes a `Map` as a parameter. const customHandler = new Map([ - ['ipfs', new IpfsHttpHandler('gateway.ipfs.io')], // Constructor of IpfsHttpHandler takes an optional gateway + ['ipfs', new IpfsHttpHandler('ipfs.io')], // Constructor of IpfsHttpHandler takes an optional gateway ['http', 'customHttpHandler'], // Custom HTTP(S) handler ['https', 'customHttpHandler'], ['tezos-storage', new TezosStorageHandler()], diff --git a/integration-tests/README.md b/integration-tests/README.md index d76fc14dc9..ceb43afaf7 100644 --- a/integration-tests/README.md +++ b/integration-tests/README.md @@ -3,7 +3,7 @@ The `taquito/integration-tests` directory contains the integration test suite for Taquito. These tests are executed against live Tezos testnets, ensuring a comprehensive evaluation of various Taquito use cases. -The tests may also be run using Flextesa. This is useful for testing new features not in current test nets and for testing features around governance that benefit from shortened block processing times. As well Flextesa tests offer a secondary confirmation of the test net results. +The tests may also be run using tezbox. This is useful for testing new features not in current testnets and for testing features around governance that benefit from shortened block processing times. As well tezbox tests offer a secondary confirmation of the testnet results. Internally Taquito is tested with tests running in parallel. This is achieved using an application that generates new keys and funds them as needed per test. The application is not publicly available. External users, therefore, must run the Taquito Integration Tests in sequence, one test at a time. @@ -100,13 +100,23 @@ If running the test with a configured secret key, ensure that the account balanc To review the graphical report of the test run, open the index.html file in ~/taquito/integration-tests/jest-stare after each test run. -## Taquito Integration Tests with Flextesa +## Taquito Integration Tests with Tezbox -:::warning -Due to the discontinuation of Flextesa support from Protocol Oxford onwards, we unfortunately will not be testing against sandboxes anymore. - -The only sandbox tests we're running points to the latest Nairobibox to specifically test for the `ballot` and `drain_delegate` operation. -::: +First, run this command to spin up the sandbox provided by [tezbox](https://github.com/tez-capital/tezbox) +This command will override the protocol parameters to 10 `blocks_per_cycle` and 1 second `minimal_block_delay` +``` +npm run sandbox:parisnet +``` +Then you can run the tests under tezbox subfolder that requires to wait cycles like proposals, ballot and drain_delegate +``` +TEZOS_RPC_PARISNET=http://localhost:8732 npm run test __tests__/tezbox/ +``` +Or if you'd like to run the entire `__tests__` folder run these commands +``` +source sandbox-env.sh +npm run originate-known-contracts +npm run test:parisnet-secret-key +``` ## The Keygen API diff --git a/integration-tests/__tests__/tezbox/sandbox-proposal-and-ballot-operation.spec.ts b/integration-tests/__tests__/tezbox/sandbox-proposal-and-ballot-operation.spec.ts index 6253a38a9a..e9144fb1d0 100644 --- a/integration-tests/__tests__/tezbox/sandbox-proposal-and-ballot-operation.spec.ts +++ b/integration-tests/__tests__/tezbox/sandbox-proposal-and-ballot-operation.spec.ts @@ -115,7 +115,7 @@ CONFIGS().forEach(async ({ rpc, protocol }) => { expect(localForged).toEqual(rpcForged); }) - it('should toPreapply a prepared a ballot operation accepted by rpc in proposal period in exploration period', async () => { + tezboxnet('should toPreapply a prepared a ballot operation accepted by rpc in proposal period in exploration period', async () => { // if it's still proposal period make the test sleep to get into exploration period to preapply ballot operation await sleepUntil('exploration') diff --git a/integration-tests/package.json b/integration-tests/package.json index 8029b31a0a..705a0b3a45 100644 --- a/integration-tests/package.json +++ b/integration-tests/package.json @@ -5,7 +5,6 @@ "test:secret-key": "RUN_WITH_SECRET_KEY=true jest --runInBand", "test:parisnet": "PARISNET=true jest", "test:parisnet-secret-key": "RUN_PARISNET_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 f450dc2f28..9990e054d3 100755 --- a/integration-tests/sandbox-env.sh +++ b/integration-tests/sandbox-env.sh @@ -1,7 +1,7 @@ #!/bin/sh -export RUN_NAIROBINET_WITH_SECRET_KEY=true -export SECRET_KEY=edsk3RFgDiCt7tWB2oe96w1eRw72iYiiqZPLu9nnEY23MYRp2d8Kkx -export TEZOS_RPC_NAIROBINET=http://localhost:20000 +export RUN_PARISNET_WITH_SECRET_KEY=true +export SECRET_KEY=edsk3QoqBuvdamxouPhin7swCvkQNgq4jP5KZPbwWNnwdZpSpJiEbq +export TEZOS_RPC_PARISNET=http://localhost:8732 export POLLING_INTERVAL_MILLISECONDS=100 export RPC_CACHE_MILLISECONDS=0 -export TEZOS_BAKER=tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb \ No newline at end of file +export TEZOS_BAKER=tz1faswCTDciRzE4oJ9jn2Vm2dvjeyA9fUzU \ No newline at end of file diff --git a/sandbox-bakers.sh b/sandbox-bakers.sh deleted file mode 100755 index b09552e979..0000000000 --- a/sandbox-bakers.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash - -# Generate Flextesa bootstrap accounts -flextesa_docker_image="${1}" - -# Set environment variables -export RUN_"${testnet_uppercase}"_WITH_SECRET_KEY=true -export SECRET_KEY="${secret_key}" -export TEZOS_RPC_"${testnet_uppercase}"="http://localhost:20000" -export POLLING_INTERVAL_MILLISECONDS=100 -export RPC_CACHE_MILLISECONDS=0 -export TEZOS_BAKER=tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb - -alice=$(docker run --rm "${flextesa_docker_image}" flextesa key alice) -bob=$(docker run --rm "${flextesa_docker_image}" flextesa key bob) -charlie=$(docker run --rm "${flextesa_docker_image}" flextesa key charlie) -dave=$(docker run --rm "${flextesa_docker_image}" flextesa key dave) - -export "alice=${alice}" -export "bob=${bob}" -export "charlie=${charlie}" -export "dave=${dave}" - -# Provision Flextesa container -protocol="${2}" -testnet="${3}" -testnet_uppercase="${4}" -secret_key="edsk3S8mG2sSBmSRbikAcZVLCz4SrCq4DjmsQRic6MGktqNFijfrS2" - -docker run \ - --rm \ - --name baking-sandbox \ - --detach \ - -p 20000:20000 \ - "${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="${dave}@2_000_000_000_000" \ - --no-daemons-for=dave \ - --until-level 200_000_000 \ - --protocol-kind "${protocol}" \ No newline at end of file From ef7f0f67324219050d53d5ad48c945bd03013264 Mon Sep 17 00:00:00 2001 From: huianyang Date: Tue, 17 Dec 2024 15:02:11 -0800 Subject: [PATCH 09/10] test: improved failing-noop tests --- .../__tests__/contract/operations/failing-noop.spec.ts | 4 ++-- integration-tests/__tests__/wallet/failing-noop.spec.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/integration-tests/__tests__/contract/operations/failing-noop.spec.ts b/integration-tests/__tests__/contract/operations/failing-noop.spec.ts index 93fdcef958..0ab1a833b6 100644 --- a/integration-tests/__tests__/contract/operations/failing-noop.spec.ts +++ b/integration-tests/__tests__/contract/operations/failing-noop.spec.ts @@ -3,11 +3,11 @@ import { OpKind, TezosToolkit } from "@taquito/taquito"; import { InMemorySigner } from "@taquito/signer"; import { verifySignature } from "@taquito/utils"; -CONFIGS().forEach(({ setup, rpc }) => { +CONFIGS().forEach(({ lib, setup, rpc }) => { let signerAlice = new InMemorySigner('edsk3QoqBuvdamxouPhin7swCvkQNgq4jP5KZPbwWNnwdZpSpJiEbq') describe(`Test failing_noop through wallet api using: ${rpc}`, () => { - let Tezos: TezosToolkit; + let Tezos = lib; beforeAll(async () => { setup(true) if (rpc.includes('paris')) { diff --git a/integration-tests/__tests__/wallet/failing-noop.spec.ts b/integration-tests/__tests__/wallet/failing-noop.spec.ts index fff84b0f99..b17f45e12b 100644 --- a/integration-tests/__tests__/wallet/failing-noop.spec.ts +++ b/integration-tests/__tests__/wallet/failing-noop.spec.ts @@ -3,11 +3,11 @@ import { OpKind, TezosToolkit } from "@taquito/taquito"; import { InMemorySigner } from "@taquito/signer"; import { verifySignature } from "@taquito/utils"; -CONFIGS().forEach(({ setup, rpc }) => { +CONFIGS().forEach(({ lib, setup, rpc }) => { let signerAlice = new InMemorySigner('edsk3QoqBuvdamxouPhin7swCvkQNgq4jP5KZPbwWNnwdZpSpJiEbq') describe(`Test failing_noop through wallet api using: ${rpc}`, () => { - let Tezos: TezosToolkit; + let Tezos = lib; beforeAll(async () => { setup(true) if (rpc.includes('paris')) { From f4111ebbb9c307f1f7b3363e8009493100a32f14 Mon Sep 17 00:00:00 2001 From: huianyang Date: Wed, 18 Dec 2024 13:59:07 -0800 Subject: [PATCH 10/10] test: addressed comments fixing typos --- cspell.json | 1 + integration-tests/__tests__/prepare-operation.spec.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cspell.json b/cspell.json index f50522dcec..78d3ebadb8 100644 --- a/cspell.json +++ b/cspell.json @@ -17,6 +17,7 @@ "BLPK", "Boissonneault", "camelcase", + "concensus", "crios", "cssanimista", "dailynet", diff --git a/integration-tests/__tests__/prepare-operation.spec.ts b/integration-tests/__tests__/prepare-operation.spec.ts index 8181e91638..3a11b7b4b7 100644 --- a/integration-tests/__tests__/prepare-operation.spec.ts +++ b/integration-tests/__tests__/prepare-operation.spec.ts @@ -35,7 +35,7 @@ CONFIGS().forEach(({ lib, setup, createAddress, knownTicketContract }) => { expect(localForged).toEqual(rpcForged); }); - it('should toPreapply a prepared a reveal operation accepted by rpc', async () => { + it('should toPreapply a prepared reveal operation accepted by rpc', async () => { const toPreapply = await Tezos.rpc.preapplyOperations(await Tezos.prepare.toPreapply(prepared)); expect(toPreapply).toBeInstanceOf(Array); expect(toPreapply[0].contents).toBeInstanceOf(Array); @@ -332,7 +332,7 @@ CONFIGS().forEach(({ lib, setup, createAddress, knownTicketContract }) => { expect(prepared.opOb.protocol).toBeDefined(); }) - it('should toForge a prepared smartRollupOriginate operation accepted accepted by both forgers', async () => { + it('should toForge a prepared smartRollupOriginate operation accepted by both forgers', async () => { const toForge = await Tezos.prepare.toForge(prepared); const localForged = await localForger.forge(toForge); const rpcForged = await Tezos.rpc.forgeOperations(toForge);