Skip to content

Commit

Permalink
updated protocol constants test (#2918)
Browse files Browse the repository at this point in the history
* updated protocol constants test

* updated constants response for proto20

* updated missing properties and estimation values

* removed duplicate property
  • Loading branch information
dsawali authored Apr 16, 2024
1 parent cf41c8b commit 6047339
Show file tree
Hide file tree
Showing 5 changed files with 455 additions and 222 deletions.
8 changes: 4 additions & 4 deletions integration-tests/__tests__/contract/estimation-tests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ CONFIGS().forEach(({ lib, setup, knownBaker, createAddress, rpc }) => {
expect(estimate.minimalFeeMutez).toEqual(374);
expect(estimate.totalCost).toEqual(374);
expect(estimate.usingBaseFeeMutez).toEqual(374);
expect(estimate.consumedMilligas).toEqual(1456056);
expect(estimate.consumedMilligas).toEqual(1456142);
});

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

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

it('Verify .estimate.transfer for multiple internal originations', async () => {
Expand All @@ -145,7 +145,7 @@ CONFIGS().forEach(({ lib, setup, knownBaker, createAddress, rpc }) => {
expect(estimate.minimalFeeMutez).toEqual(539);
expect(estimate.totalCost).toEqual(164039);
expect(estimate.usingBaseFeeMutez).toEqual(539);
expect(estimate.consumedMilligas).toEqual(2391833);
expect(estimate.consumedMilligas).toEqual(2391919);
// Do the actual operation
const op2 = await contract.methods.do(originate2()).send();
await op2.confirmation();
Expand Down
165 changes: 157 additions & 8 deletions integration-tests/__tests__/rpc/get-protocol-constants.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { Protocols } from "@taquito/taquito";
import { CONFIGS, NetworkType } from "../../config";
import BigNumber from 'bignumber.js';
import { ConstantsResponseProto019 } from '@taquito/rpc';
import { ConstantsResponseProto019, ConstantsResponseProto020 } from '@taquito/rpc';

CONFIGS().forEach(({ lib, protocol, rpc, networkType }) => {
const Tezos = lib;
const oxfordnet = (networkType == NetworkType.TESTNET && protocol === Protocols.ProxfordY) ? test : test.skip;
const parisnet = (networkType == NetworkType.TESTNET && protocol === Protocols.PtParisBQ) ? test : test.skip;
const weeklynet = (networkType == NetworkType.TESTNET && protocol === Protocols.ProtoALpha) ? test : test.skip;
describe('Test fetching constants for all protocols on Mainnet', () => {
const rpcUrl = 'https://mainnet.ecadinfra.com/';
Tezos.setRpcProvider(rpcUrl);
it(`successfully fetches Proto19(oxford2) constants at head`, async () => {
it(`should successfully fetch Proto19(oxford2) constants at head`, async () => {
const constants: ConstantsResponseProto019 = await Tezos.rpc.getConstants();
expect(constants).toEqual({
adaptive_issuance_activation_vote_enable: false,
Expand Down Expand Up @@ -140,7 +141,155 @@ CONFIGS().forEach(({ lib, protocol, rpc, networkType }) => {
});

describe(`Fetch constants for testnet`, () => {
oxfordnet(`successfully fetches all constants for oxfordnet using ${rpc}`, async () => {
parisnet(`should successfully fetch all constants for Parisnet using ${rpc}`, async () => {
Tezos.setRpcProvider(rpc);
const constants: ConstantsResponseProto020 = await Tezos.rpc.getConstants();
expect(constants).toEqual({
adaptive_issuance_activation_vote_enable: true,
adaptive_issuance_force_activation: false,
adaptive_issuance_launch_ema_threshold: 0,
adaptive_rewards_params: {
center_dz: {
denominator: "2",
numerator: "1",
},
growth_rate: {
denominator: "25",
numerator: "1",
},
issuance_ratio_final_max: {
denominator: "10",
numerator: "1",
},
issuance_ratio_final_min: {
denominator: "400",
numerator: "1",
},
issuance_ratio_initial_max: {
denominator: "200",
numerator: "11",
},
issuance_ratio_initial_min: {
denominator: "200",
numerator: "9"
},
max_bonus: "50000000000000",
radius_dz: {
denominator: "50",
numerator: "1",
},
initial_period: 10,
transition_period: 50
},
autostaking_enable: true,
proof_of_work_nonce_size: 8,
nonce_length: 32,
max_anon_ops_per_block: 132,
max_operation_data_length: 32768,
max_proposals_per_delegate: 20,
max_micheline_node_count: 50000,
max_micheline_bytes_limit: 50000,
max_allowed_global_constants_depth: 10000,
cache_layout_size: 3,
michelson_maximum_type_size: 2001,
smart_rollup_max_wrapped_proof_binary_size: 30000,
smart_rollup_max_number_of_messages_per_level: '1000000',
blocks_per_cycle: 12288,
blocks_per_commitment: 96,
blocks_preservation_cycles: 1,
nonce_revelation_threshold: 768,
ns_enable: true,
cycles_per_voting_period: 1,
hard_gas_limit_per_operation: new BigNumber(1040000),
hard_gas_limit_per_block: new BigNumber(1733333),
proof_of_work_threshold: new BigNumber(-1),
minimal_stake: new BigNumber(6000000000),
origination_size: 257,
cost_per_byte: new BigNumber(250),
hard_storage_limit_per_operation: new BigNumber(60000),
percentage_of_frozen_deposits_slashed_per_double_attestation: 5000,
percentage_of_frozen_deposits_slashed_per_double_baking: 500,
minimal_frozen_stake: '600000000',
limit_of_delegation_over_baking: 9,
liquidity_baking_subsidy: new BigNumber(5000000),
issuance_weights: {
attesting_reward_weight: 10240,
baking_reward_bonus_weight: 5120,
baking_reward_fixed_portion_weight: 5120,
base_total_issued_per_minute: "80007812",
seed_nonce_revelation_tip_weight: 1,
vdf_revelation_tip_weight: 1,
},
min_proposal_quorum: 500,
edge_of_staking_over_delegation: 2,
global_limit_of_staking_over_baking: 5,
liquidity_baking_toggle_ema_threshold: 1000000000,
max_operations_time_to_live: 360,
minimal_block_delay: new BigNumber(5),
delay_increment_per_round: new BigNumber(2),
delegate_parameters_activation_delay: 5,
direct_ticket_spending_enable: false,
consensus_committee_size: 7000,
consensus_threshold: 4667,
consensus_rights_delay: 2,
minimal_participation_ratio: {
numerator: 2,
denominator: 3
},
max_slashing_period: 2,
max_slashing_per_block: 10000,
max_slashing_threshold: 2334,
cache_script_size: 100000000,
cache_stake_distribution_cycles: 8,
cache_sampler_state_cycles: 8,
dal_parametric: {
attestation_lag: 8,
attestation_threshold: 66,
feature_enable: true,
incentives_enable: false,
number_of_shards: 512,
number_of_slots: 32,
page_size: 3967,
redundancy_factor: 8,
slot_size: 126944,
},
quorum_max: 7000,
quorum_min: 2000,
smart_rollup_arith_pvm_enable: false,
smart_rollup_challenge_window_in_blocks: 241920,
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_max_number_of_cemented_commitments: 5,
smart_rollup_max_number_of_parallel_games: 32,
smart_rollup_message_size_limit: 4096,
smart_rollup_number_of_sections_in_dissection: 32,
smart_rollup_origination_size: 6314,
smart_rollup_private_enable: true,
smart_rollup_reveal_activation_level: {
dal_attested_slots_validity_lag: 241920,
dal_page: 8193,
dal_parameters: 8193,
metadata: 0,
raw_data: {
Blake2B: 0,
},
},
smart_rollup_riscv_pvm_enable: false,
smart_rollup_stake_amount: '10000000000',
smart_rollup_timeout_period_in_blocks: 120960,
testnet_dictator: 'tz1Xf8zdT3DbAX9cHw3c3CXh79rc4nK4gCe8',
vdf_difficulty: new BigNumber(10000000000),
zk_rollup_enable: false,
zk_rollup_max_ticket_payload_size: 2048,
zk_rollup_min_pending_to_process: 10,
zk_rollup_origination_size: 4000,
});
});


oxfordnet(`should successfully fetch all constants for Oxfordnet using ${rpc}`, async () => {
Tezos.setRpcProvider(rpc);
const constants: ConstantsResponseProto019 = await Tezos.rpc.getConstants();
expect(constants).toEqual({
Expand Down Expand Up @@ -185,8 +334,8 @@ CONFIGS().forEach(({ lib, protocol, rpc, networkType }) => {
preserved_cycles: 3,
blocks_per_cycle: 8192,
blocks_per_commitment: 64,
nonce_revelation_threshold: 512,
blocks_per_stake_snapshot: 512,
nonce_revelation_threshold: 512,
cycles_per_voting_period: 1,
hard_gas_limit_per_operation: new BigNumber(1040000),
hard_gas_limit_per_block: new BigNumber(2600000),
Expand Down Expand Up @@ -227,14 +376,14 @@ CONFIGS().forEach(({ lib, protocol, rpc, networkType }) => {
cache_sampler_state_cycles: 8,
dal_parametric: {
feature_enable: false,
number_of_slots: 256,
blocks_per_epoch: 1,
attestation_lag: 4,
attestation_threshold: 50,
blocks_per_epoch: 1,
redundancy_factor: 16,
page_size: 4096,
slot_size: 1048576,
number_of_shards: 2048
number_of_shards: 2048,
number_of_slots: 256,
},
quorum_max: 7000,
quorum_min: 2000,
Expand Down Expand Up @@ -270,7 +419,7 @@ CONFIGS().forEach(({ lib, protocol, rpc, networkType }) => {
});
});

weeklynet(`successfully fetches all constants for weeklynet using ${rpc}`, async () => {
weeklynet(`should successfully fetch all constants for weeklynet using ${rpc}`, async () => {
Tezos.setRpcProvider(rpc);
const constants: ConstantsResponseProto019 = await Tezos.rpc.getConstants();

Expand Down
Loading

0 comments on commit 6047339

Please sign in to comment.