Skip to content

Commit

Permalink
Mondaynet 2023 09 12 (#2654)
Browse files Browse the repository at this point in the history
* test: mondaynet update 0912 & revert contract-estimate assertations

* chore: update dependnecies

* test: fix flextesa nairobinet with unregister delegate bug

* ci: updated nairobinet flextesa image
  • Loading branch information
hui-an-yang authored Sep 13, 2023
1 parent 0829121 commit e1b1d69
Show file tree
Hide file tree
Showing 6 changed files with 3,603 additions and 2,421 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
- protocol: Nairobi
testnet: nairobinet
testnet_uppercase: NAIROBINET
flextesa_docker_image: oxheadalpha/flextesa:20230502
flextesa_docker_image: oxheadalpha/flextesa:20230607
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const defaultConfig = ({
rpc: process.env[`TEZOS_RPC_${networkName}`] || defaultRpc,
pollingIntervalMilliseconds: process.env[`POLLING_INTERVAL_MILLISECONDS`] || undefined,
rpcCacheMilliseconds: process.env[`RPC_CACHE_MILLISECONDS`] || '1000',
knownBaker: process.env[`TEZOS_BAKER`] || networkName === 'MONDAYNET' ? 'tz1ck3EJwzFpbLVmXVuEn5Ptwzc6Aj14mHSH' : 'tz1cjyja1TU6fiyiFav3mFAdnDsCReJ12hPD',
knownBaker: process.env[`TEZOS_BAKER`] || (networkName === 'MONDAYNET' ? 'tz1ck3EJwzFpbLVmXVuEn5Ptwzc6Aj14mHSH' : 'tz1cjyja1TU6fiyiFav3mFAdnDsCReJ12hPD'),
knownContract: process.env[`TEZOS_${networkName}_CONTRACT_ADDRESS`] || knownContracts.contract,
knownBigMapContract: process.env[`TEZOS_${networkName}_BIGMAPCONTRACT_ADDRESS`] || knownContracts.bigMapContract,
knownTzip1216Contract: process.env[`TEZOS_${networkName}_TZIP1216CONTRACT_ADDRESS`] || knownContracts.tzip12BigMapOffChainContract,
Expand Down
123 changes: 51 additions & 72 deletions integration-tests/contract-estimation-tests.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { DEFAULT_FEE, MANAGER_LAMBDA, TezosToolkit, Protocols } from '@taquito/taquito';
import { DEFAULT_FEE, MANAGER_LAMBDA, TezosToolkit } from '@taquito/taquito';
import { Contract } from '@taquito/taquito';
import { CONFIGS } from './config';
import { originate, originate2, transferImplicit2 } from './data/lambda';
import { ligoSample } from './data/ligo-simple-contract';
import { managerCode } from './data/manager_code';
import { InvalidAmountError } from '@taquito/core';

CONFIGS().forEach(({ lib, setup, knownBaker, createAddress, rpc, protocol }) => {
CONFIGS().forEach(({ lib, setup, knownBaker, createAddress, rpc }) => {
const Tezos = lib;
const nairobinet = protocol === Protocols.PtNairobi ? it : it.skip;
const mondaynet = protocol === Protocols.ProtoALpha ? it : it.skip;

describe(`Test estimate scenarios using: ${rpc}`, () => {
let LowAmountTez: TezosToolkit;
Expand Down Expand Up @@ -43,11 +41,11 @@ CONFIGS().forEach(({ lib, setup, knownBaker, createAddress, rpc, protocol }) =>
const estimate = await LowAmountTez.estimate.transfer({ to: await Tezos.signer.publicKeyHash(), amount: 0.019 });
expect(estimate.gasLimit).toEqual(201);
expect(estimate.storageLimit).toEqual(0);
expect(estimate.suggestedFeeMutez).toEqual(372);
expect(estimate.suggestedFeeMutez).toEqual(374);
expect(estimate.burnFeeMutez).toEqual(0);
expect(estimate.minimalFeeMutez).toEqual(272);
expect(estimate.totalCost).toEqual(272);
expect(estimate.usingBaseFeeMutez).toEqual(272);
expect(estimate.minimalFeeMutez).toEqual(274);
expect(estimate.totalCost).toEqual(274);
expect(estimate.usingBaseFeeMutez).toEqual(274);
expect(estimate.consumedMilligas).toEqual(100040);
done();
});
Expand All @@ -56,11 +54,11 @@ CONFIGS().forEach(({ lib, setup, knownBaker, createAddress, rpc, protocol }) =>
const estimate = await LowAmountTez.estimate.transfer({ to: await (await createAddress()).signer.publicKeyHash(), amount: 0.017 });
expect(estimate.gasLimit).toEqual(201);
expect(estimate.storageLimit).toEqual(257);
expect(estimate.suggestedFeeMutez).toEqual(372);
expect(estimate.suggestedFeeMutez).toEqual(374);
expect(estimate.burnFeeMutez).toEqual(64250);
expect(estimate.minimalFeeMutez).toEqual(272);
expect(estimate.totalCost).toEqual(64522);
expect(estimate.usingBaseFeeMutez).toEqual(272);
expect(estimate.minimalFeeMutez).toEqual(274);
expect(estimate.totalCost).toEqual(64524);
expect(estimate.usingBaseFeeMutez).toEqual(274);
expect(estimate.consumedMilligas).toEqual(100040);
done();
});
Expand All @@ -73,12 +71,12 @@ CONFIGS().forEach(({ lib, setup, knownBaker, createAddress, rpc, protocol }) =>
});
expect(estimate.gasLimit).toEqual(677);
expect(estimate.storageLimit).toEqual(571);
expect(estimate.suggestedFeeMutez).toEqual(711);
expect(estimate.suggestedFeeMutez).toEqual(713);
expect(estimate.burnFeeMutez).toEqual(142750);
expect(estimate.minimalFeeMutez).toEqual(611);
expect(estimate.totalCost).toEqual(143361);
expect(estimate.usingBaseFeeMutez).toEqual(611);
expect(estimate.consumedMilligas).toEqual(576230);
expect(estimate.minimalFeeMutez).toEqual(613);
expect(estimate.totalCost).toEqual(143363);
expect(estimate.usingBaseFeeMutez).toEqual(613);
expect(estimate.consumedMilligas).toEqual(576347);
done();
});

Expand All @@ -89,26 +87,26 @@ CONFIGS().forEach(({ lib, setup, knownBaker, createAddress, rpc, protocol }) =>
});
expect(estimate.gasLimit).toEqual(200);
expect(estimate.storageLimit).toEqual(0);
expect(estimate.suggestedFeeMutez).toEqual(367);
expect(estimate.suggestedFeeMutez).toEqual(369);
expect(estimate.burnFeeMutez).toEqual(0);
expect(estimate.minimalFeeMutez).toEqual(267);
expect(estimate.totalCost).toEqual(267);
expect(estimate.usingBaseFeeMutez).toEqual(267);
expect(estimate.minimalFeeMutez).toEqual(269);
expect(estimate.totalCost).toEqual(269);
expect(estimate.usingBaseFeeMutez).toEqual(269);
expect(estimate.consumedMilligas).toEqual(100000);
done();
});

it('Verify .estimate.transfer for internal transfer to allocated implicit', async (done) => {
const tx = contract.methods.do(MANAGER_LAMBDA.transferImplicit(knownBaker, 5)).toTransferParams();
const estimate = await LowAmountTez.estimate.transfer(tx);
expect(estimate.gasLimit).toEqual(1456);
expect(estimate.gasLimit).toEqual(1457);
expect(estimate.storageLimit).toEqual(0);
expect(estimate.suggestedFeeMutez).toEqual(570);
expect(estimate.suggestedFeeMutez).toEqual(572);
expect(estimate.burnFeeMutez).toEqual(0);
expect(estimate.minimalFeeMutez).toEqual(470);
expect(estimate.totalCost).toEqual(470);
expect(estimate.usingBaseFeeMutez).toEqual(470);
expect(estimate.consumedMilligas).toEqual(1355917);
expect(estimate.minimalFeeMutez).toEqual(472);
expect(estimate.totalCost).toEqual(472);
expect(estimate.usingBaseFeeMutez).toEqual(472);
expect(estimate.consumedMilligas).toEqual(1356735);
done();
});

Expand All @@ -119,42 +117,42 @@ CONFIGS().forEach(({ lib, setup, knownBaker, createAddress, rpc, protocol }) =>
50)
).toTransferParams();
const estimate = await LowAmountTez.estimate.transfer(tx);
expect(estimate.gasLimit).toEqual(1571);
expect(estimate.gasLimit).toEqual(1572);
expect(estimate.storageLimit).toEqual(514);
expect(estimate.suggestedFeeMutez).toEqual(641);
expect(estimate.suggestedFeeMutez).toEqual(643);
expect(estimate.burnFeeMutez).toEqual(128500);
expect(estimate.minimalFeeMutez).toEqual(541);
expect(estimate.totalCost).toEqual(129041);
expect(estimate.usingBaseFeeMutez).toEqual(541);
expect(estimate.consumedMilligas).toEqual(1470446);
expect(estimate.minimalFeeMutez).toEqual(543);
expect(estimate.totalCost).toEqual(129043);
expect(estimate.usingBaseFeeMutez).toEqual(543);
expect(estimate.consumedMilligas).toEqual(1471270);
done();
});

it('Verify .estimate.transfer for internal origination', async (done) => {
const tx = contract.methods.do(originate()).toTransferParams();
const estimate = await LowAmountTez.estimate.transfer(tx);
expect(estimate.gasLimit).toEqual(1867);
expect(estimate.gasLimit).toEqual(1868);
expect(estimate.storageLimit).toEqual(317);
expect(estimate.suggestedFeeMutez).toEqual(617);
expect(estimate.suggestedFeeMutez).toEqual(619);
expect(estimate.burnFeeMutez).toEqual(79250);
expect(estimate.minimalFeeMutez).toEqual(517);
expect(estimate.totalCost).toEqual(79767);
expect(estimate.usingBaseFeeMutez).toEqual(517);
expect(estimate.consumedMilligas).toEqual(1766527);
expect(estimate.minimalFeeMutez).toEqual(519);
expect(estimate.totalCost).toEqual(79769);
expect(estimate.usingBaseFeeMutez).toEqual(519);
expect(estimate.consumedMilligas).toEqual(1767848);
done();
});

it('Verify .estimate.transfer for multiple internal originations', async (done) => {
const tx = contract.methods.do(originate2()).toTransferParams();
const estimate = await LowAmountTez.estimate.transfer(tx);
expect(estimate.gasLimit).toEqual(2392);
expect(estimate.gasLimit).toEqual(2394);
expect(estimate.storageLimit).toEqual(634);
expect(estimate.suggestedFeeMutez).toEqual(735);
expect(estimate.suggestedFeeMutez).toEqual(737);
expect(estimate.burnFeeMutez).toEqual(158500);
expect(estimate.minimalFeeMutez).toEqual(635);
expect(estimate.totalCost).toEqual(159135);
expect(estimate.usingBaseFeeMutez).toEqual(635);
expect(estimate.consumedMilligas).toEqual(2291666);
expect(estimate.minimalFeeMutez).toEqual(637);
expect(estimate.totalCost).toEqual(159137);
expect(estimate.usingBaseFeeMutez).toEqual(637);
expect(estimate.consumedMilligas).toEqual(2293496);
// Do the actual operation
const op2 = await contract.methods.do(originate2()).send();
await op2.confirmation();
Expand Down Expand Up @@ -187,49 +185,30 @@ CONFIGS().forEach(({ lib, setup, knownBaker, createAddress, rpc, protocol }) =>
let estimate = await LowAmountTez.estimate.transfer({ to: await Tezos.signer.publicKeyHash(), mutez: true, amount: amt - (1382 + DEFAULT_FEE.REVEAL) });
expect(estimate.gasLimit).toEqual(201);
expect(estimate.storageLimit).toEqual(0);
expect(estimate.suggestedFeeMutez).toEqual(370);
expect(estimate.suggestedFeeMutez).toEqual(372);
expect(estimate.burnFeeMutez).toEqual(0);
expect(estimate.minimalFeeMutez).toEqual(270);
expect(estimate.totalCost).toEqual(270);
expect(estimate.usingBaseFeeMutez).toEqual(270);
expect(estimate.minimalFeeMutez).toEqual(272);
expect(estimate.totalCost).toEqual(272);
expect(estimate.usingBaseFeeMutez).toEqual(272);
expect(estimate.consumedMilligas).toEqual(100040);
done();
});

nairobinet('Estimate transfer to regular address with a fixed fee', async (done) => {

const params = { fee: 2000, to: await Tezos.signer.publicKeyHash(), mutez: true, amount: amt - (1382 + DEFAULT_FEE.REVEAL) };

await expect(LowAmountTez.estimate.transfer(params)).rejects.toMatchObject({
id: 'proto.017-PtNairob.implicit.empty_implicit_contract',
});
done();
});

mondaynet('Estimate transfer to regular address with a fixed fee', async (done) => {
it('Estimate transfer to regular address with a fixed fee', async (done) => {

const params = { fee: 2000, to: await Tezos.signer.publicKeyHash(), mutez: true, amount: amt - (1382 + DEFAULT_FEE.REVEAL) };

await expect(LowAmountTez.estimate.transfer(params)).rejects.toMatchObject({
id: 'proto.alpha.implicit.empty_implicit_contract',
});
done();
});

nairobinet('Estimate transfer to regular address with insufficient balance', async (done) => {
await expect(
LowAmountTez.estimate.transfer({ to: await Tezos.signer.publicKeyHash(), mutez: true, amount: amt })
).rejects.toMatchObject({
id: 'proto.017-PtNairob.tez.subtraction_underflow',
id: expect.stringContaining('empty_implicit_contract'),
});
done();
});

mondaynet('Estimate transfer to regular address with insufficient balance', async (done) => {
it('Estimate transfer to regular address with insufficient balance', async (done) => {
await expect(
LowAmountTez.estimate.transfer({ to: await Tezos.signer.publicKeyHash(), mutez: true, amount: amt })
).rejects.toMatchObject({
id: 'proto.alpha.tez.subtraction_underflow',
id: expect.stringContaining('subtraction_underflow'),
});
done();
});
Expand Down
10 changes: 5 additions & 5 deletions integration-tests/known-contracts-ProtoALph.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { KnownContracts } from './known-contracts';
export const knownContractsProtoALph: KnownContracts = {
contract: "KT1JWuKFJWDYvBWWiH6GDrMn7KbgbSXnYPZS",
bigMapContract: "KT1FiKJtmUd3AU5Ey3bNGahehudqtFkatprA",
tzip12BigMapOffChainContract: "KT1Mq4TszoSWeXvsqPWSz45W6aVVSDrxizNW",
saplingContract: "KT1ENuhqgJLa7EHvgf2LDvRp8Z9wZ9LNkg5J",
onChainViewContractAddress: "KT1XBxr9fbJV4XFRwLx3EB9kpazGouFFYhP6",
contract: "KT1XXrWDuK77kQWX55zjD347Wh6bwgmJDfJ8",
bigMapContract: "KT1NSDEhMTWoX2Vie98NCtQV4fVYoPfqfAN3",
tzip12BigMapOffChainContract: "KT1X4c8BCVSDE7dtf5jPRtpYtYcaSFknwzN5",
saplingContract: "KT1JKC49zUSCXJGKT2p1bHVWmg47rAgF53ff",
onChainViewContractAddress: "KT1FVjUZeH5KM8tMwYvrVCMC3QFyDRUBFNLk",
};
Loading

0 comments on commit e1b1d69

Please sign in to comment.