Skip to content

Commit

Permalink
2064 lima integration remove jakarta (#2084)
Browse files Browse the repository at this point in the history
* 1630 ballot operation support in contract API (#2050)

* added estimate and contract ballot operation support

* added rpc contract provider for ballot op

* updated implementation and added docs

* added property in OperationContentsAndResultBallot and added unit test

* remove metadata property from ballot

* addressed PR comments

* updated yarn and package-lock

* cleaned up comments and switched out async for promise in op emitter

* removed unnecessary line break

* 660 support customize parser options (#2061)

* feat: exposed setParserProvider configuration through TezosToolkit

re #660

* test: added integration tests using setParserProvider with TezosToolkit

re #660

* docs: updated starting production server commands with taquito-test-dapp readme.md

* test: removed unnecessory console.log

re #660

* chore: update vite to latest version

* docs: fixed some typos in doc to address comments

re #660

* initial changes, check chainids

adjust config, run originate contracts

 add untracked

fix improper config data

switch jakarta tests, switch rpc endpoint

fix missed jakartanet

adjust constants lima, estimate test values

fix broken value

* change test protocol runs

Co-authored-by: Davis Sawali <[email protected]>
Co-authored-by: hui-an-yang <[email protected]>
Co-authored-by: Zainen Suzuki <[email protected]>
  • Loading branch information
4 people authored Nov 8, 2022
1 parent 6c23351 commit 2bf3ae4
Show file tree
Hide file tree
Showing 16 changed files with 1,030 additions and 1,059 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node:
node:
- '16.13.1'
- '17.3.x'
steps:
Expand Down Expand Up @@ -44,6 +44,7 @@ jobs:
matrix:
protocol:
- kathmandunet
- limanet
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
Expand Down Expand Up @@ -78,4 +79,4 @@ jobs:
POLLING_INTERVAL_MILLISECONDS: 100
RPC_CACHE_MILLISECONDS: 0
TEZOS_BAKER: tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb
- run: docker kill my-sandbox
- run: docker kill my-sandbox
67 changes: 34 additions & 33 deletions integration-tests/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { importKey, InMemorySigner } from '@taquito/signer';
import { RpcClient, RpcClientCache } from '@taquito/rpc';
import { knownBigMapContractProtoALph, knownContractProtoALph, knownOnChainViewContractAddressProtoALph, knownSaplingContractProtoALph, knownTzip12BigMapOffChainContractProtoALph, txRollupAddressProtoALph } from './known-contracts-ProtoALph';
import { knownContractPtKathman, knownBigMapContractPtKathman, knownTzip12BigMapOffChainContractPtKathman, knownSaplingContractPtKathman, knownOnChainViewContractAddressPtKathman, txRollupAddressPtKathman } from './known-contracts-PtKathman';
import { knownContractPtJakart2, knownBigMapContractPtJakart2, knownTzip12BigMapOffChainContractPtJakart2, knownSaplingContractPtJakart2, knownOnChainViewContractAddressPtJakart2, txRollupAddressPtJakart2 } from './known-contracts-PtJakart2';
import { knownContractPtLimaPtL, knownBigMapContractPtLimaPtL, knownTzip12BigMapOffChainContractPtLimaPtL, knownSaplingContractPtLimaPtL, knownOnChainViewContractAddressPtLimaPtL, txRollupAddressPtLimaPtL } from './known-contracts-PtLimaPtL';

const nodeCrypto = require('crypto');

Expand Down Expand Up @@ -91,32 +91,33 @@ const kathmandunetEphemeral = {
protocol: Protocols.PtKathman,
signerConfig: {
type: SignerType.EPHEMERAL_KEY as SignerType.EPHEMERAL_KEY,
keyUrl: 'https://api.tez.ie/keys/kathmandunet',
keyUrl: 'http://key-gen-1.i.tez.ie:3000/kathmandunet',
requestHeaders: { Authorization: 'Bearer taquito-example' },
}
};

const jakartanetEphemeral = {
rpc: process.env['TEZOS_RPC_JAKARTANET'] || 'https://jakartanet-archive.ecadinfra.com',
const limanetEphemeral = {
rpc: process.env['TEZOS_RPC_LIMANET'] || 'https://limanet.ecadinfra.com',
pollingIntervalMilliseconds: process.env['POLLING_INTERVAL_MILLISECONDS'] || undefined,
rpcCacheMilliseconds: process.env['RPC_CACHE_MILLISECONDS'] || '1000',
knownBaker: process.env['TEZOS_BAKER'] || 'tz1cjyja1TU6fiyiFav3mFAdnDsCReJ12hPD',
knownContract: process.env['TEZOS_JAKARTANET_CONTRACT_ADDRESS'] || knownContractPtJakart2,
knownBigMapContract: process.env['TEZOS_JAKARTANET_BIGMAPCONTRACT_ADDRESS'] || knownBigMapContractPtJakart2,
knownTzip1216Contract: process.env['TEZOS_JAKARTANET_TZIP1216CONTRACT_ADDRESS'] || knownTzip12BigMapOffChainContractPtJakart2,
knownSaplingContract: process.env['TEZOS_JAKARTANET_SAPLINGCONTRACT_ADDRESS'] || knownSaplingContractPtJakart2,
txRollupWithdrawContract: process.env['TEZOS_JAKARTANET_TX_ROLLUP_WITHDRAW_CONTRACT'] || '',
txRollupDepositContract: process.env['TEZOS_JAKARTANET_TX_ROLLUP_DEPOSIT_CONTRACT'] || '',
knownViewContract: process.env['TEZOS_JAKARTANET_ON_CHAIN_VIEW_CONTRACT'] || knownOnChainViewContractAddressPtJakart2,
txRollupAddress: process.env['TEZOS_JAKARTANET_TXROLLUP_ADDRESS'] || txRollupAddressPtJakart2,
protocol: Protocols.PtJakart2,
knownContract: process.env['TEZOS_LIMANET_CONTRACT_ADDRESS'] || knownContractPtLimaPtL,
knownBigMapContract: process.env['TEZOS_LIMANET_BIGMAPCONTRACT_ADDRESS'] || knownBigMapContractPtLimaPtL,
knownTzip1216Contract: process.env['TEZOS_LIMANET_TZIP1216CONTRACT_ADDRESS'] || knownTzip12BigMapOffChainContractPtLimaPtL,
knownSaplingContract: process.env['TEZOS_LIMANET_SAPLINGCONTRACT_ADDRESS'] || knownSaplingContractPtLimaPtL,
txRollupWithdrawContract: process.env['TEZOS_LIMANET_TX_ROLLUP_WITHDRAW_CONTRACT'] || '',
txRollupDepositContract: process.env['TEZOS_LIMANET_TX_ROLLUP_DEPOSIT_CONTRACT'] || '',
knownViewContract: process.env['TEZOS_LIMANET_ON_CHAIN_VIEW_CONTRACT'] || knownOnChainViewContractAddressPtLimaPtL,
txRollupAddress: process.env['TEZOS_LIMANET_TXROLLUP_ADDRESS'] || txRollupAddressPtLimaPtL,
protocol: Protocols.PtLimaPtL,
signerConfig: {
type: SignerType.EPHEMERAL_KEY as SignerType.EPHEMERAL_KEY,
keyUrl: 'https://api.tez.ie/keys/jakartanet',
keyUrl: 'http://key-gen-1.i.tez.ie:3000/limanet',
requestHeaders: { Authorization: 'Bearer taquito-example' },
},
};


const mondaynetEphemeral = {
rpc: process.env['TEZOS_RPC_MONDAYNET'] || 'http://mondaynet.ecadinfra.com:8732',
pollingIntervalMilliseconds: process.env['POLLING_INTERVAL_MILLISECONDS'] || undefined,
Expand Down Expand Up @@ -155,20 +156,20 @@ const kathmandunetSecretKey = {
signerConfig: defaultSecretKey,
};

const jakartanetSecretKey = {
rpc: process.env['TEZOS_RPC_JAKARTANET'] || 'https://jakartanet-archive.ecadinfra.com',
const limanetSecretKey = {
rpc: process.env['TEZOS_RPC_LIMANET'] || 'https://limanet-archive.ecadinfra.com',
pollingIntervalMilliseconds: process.env['POLLING_INTERVAL_MILLISECONDS'] || undefined,
rpcCacheMilliseconds: process.env['RPC_CACHE_MILLISECONDS'] || '1000',
knownBaker: process.env['TEZOS_BAKER'] || 'tz1cjyja1TU6fiyiFav3mFAdnDsCReJ12hPD',
knownContract: process.env['TEZOS_JAKARTANET_CONTRACT_ADDRESS'] || knownContractPtJakart2,
knownBigMapContract: process.env['TEZOS_JAKARTANET_BIGMAPCONTRACT_ADDRESS'] || knownBigMapContractPtJakart2,
knownTzip1216Contract: process.env['TEZOS_JAKARTANET_TZIP1216CONTRACT_ADDRESS'] || knownTzip12BigMapOffChainContractPtJakart2,
knownSaplingContract: process.env['TEZOS_JAKARTANET_SAPLINGCONTRACT_ADDRESS'] || knownSaplingContractPtJakart2,
txRollupWithdrawContract: process.env['TEZOS_JAKARTANET_TX_ROLLUP_WITHDRAW_CONTRACT'] || '',
txRollupDepositContract: process.env['TEZOS_JAKARTANET_TX_ROLLUP_DEPOSIT_CONTRACT'] || '',
knownViewContract: process.env['TEZOS_JAKARTANET_ON_CHAIN_VIEW_CONTRACT'] || knownOnChainViewContractAddressPtJakart2,
txRollupAddress: process.env['TEZOS_JAKARTANET_TXROLLUP_ADDRESS'] || txRollupAddressPtJakart2,
protocol: Protocols.PtJakart2,
knownContract: process.env['TEZOS_LIMANET_CONTRACT_ADDRESS'] || knownContractPtLimaPtL,
knownBigMapContract: process.env['TEZOS_LIMANET_BIGMAPCONTRACT_ADDRESS'] || knownBigMapContractPtLimaPtL,
knownTzip1216Contract: process.env['TEZOS_LIMANET_TZIP1216CONTRACT_ADDRESS'] || knownTzip12BigMapOffChainContractPtLimaPtL,
knownSaplingContract: process.env['TEZOS_LIMANET_SAPLINGCONTRACT_ADDRESS'] || knownSaplingContractPtLimaPtL,
txRollupWithdrawContract: process.env['TEZOS_LIMANET_TX_ROLLUP_WITHDRAW_CONTRACT'] || '',
txRollupDepositContract: process.env['TEZOS_LIMANET_TX_ROLLUP_DEPOSIT_CONTRACT'] || '',
knownViewContract: process.env['TEZOS_LIMANET_ON_CHAIN_VIEW_CONTRACT'] || knownOnChainViewContractAddressPtLimaPtL,
txRollupAddress: process.env['TEZOS_LIMANET_TXROLLUP_ADDRESS'] || txRollupAddressPtLimaPtL,
protocol: Protocols.PtLimaPtL,
signerConfig: defaultSecretKey
};

Expand All @@ -192,21 +193,21 @@ const mondaynetSecretKey = {
const providers: Config[] = [];

if (process.env['RUN_WITH_SECRET_KEY']) {
providers.push(jakartanetSecretKey, kathmandunetSecretKey);
} else if (process.env['RUN_JAKARTANET_WITH_SECRET_KEY']) {
providers.push(jakartanetSecretKey);
providers.push(limanetSecretKey, kathmandunetSecretKey);
} else if (process.env['RUN_LIMANET_WITH_SECRET_KEY']) {
providers.push(limanetSecretKey);
} else if (process.env['RUN_KATHMANDUNET_WITH_SECRET_KEY']) {
providers.push(kathmandunetSecretKey);
} else if (process.env['RUN_MONDAYNET_WITH_SECRET_KEY']) {
providers.push(mondaynetSecretKey);
} else if (process.env['JAKARTANET']) {
providers.push(jakartanetEphemeral);
} else if (process.env['KATHMANDUNET']) {
providers.push(kathmandunetEphemeral);
} else if (process.env['LIMANET']) {
providers.push(limanetEphemeral);
} else if (process.env['MONDAYNET']) {
providers.push(mondaynetEphemeral);
} else {
providers.push(jakartanetEphemeral, kathmandunetEphemeral);
providers.push(limanetEphemeral, kathmandunetEphemeral);
}

const setupForger = (Tezos: TezosToolkit, forger: ForgerType): void => {
Expand Down Expand Up @@ -250,7 +251,7 @@ const setupSignerWithEphemeralKey = async (
const httpClient = new HttpBackend();

try {
const { id, pkh } = await httpClient.createRequest({
const { id, pkh } = await httpClient.createRequest<{ id: string; pkh: string }>({
url: ephemeralUrl,
method: 'POST',
headers: requestHeaders,
Expand Down Expand Up @@ -352,4 +353,4 @@ export const CONFIGS = () => {
);
return [...prev, ...configs];
}, [] as ConfigWithSetup[]);
};
};
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { Protocols } from "@taquito/taquito";
import { CONFIGS } from "./config";

CONFIGS().forEach(({ lib, rpc, protocol, setup, createAddress }) => {
CONFIGS().forEach(({ lib, rpc, setup, createAddress }) => {

const Tezos = lib;
const jakartanet = (protocol === Protocols.PtJakart2) ? test : test.skip;
const kathmandunetAndAlpha = (protocol === Protocols.PtKathman || protocol === Protocols.ProtoALpha) ? test : test.skip;

describe(`Test emptying a revealed implicit account into a new implicit account through contract api using: ${rpc}`, () => {

Expand All @@ -14,58 +12,7 @@ CONFIGS().forEach(({ lib, rpc, protocol, setup, createAddress }) => {
done()
})

jakartanet('Verify that a new unrevealed implicit account can be created with the createAddress function and the sender account can be emptied into the created one', async (done) => {

const receiver = await createAddress();
const receiver_pkh = await receiver.signer.publicKeyHash();

// create and fund the account we want to empty
const sender = await createAddress();
const sender_pkh = await sender.signer.publicKeyHash();
const op = await Tezos.contract.transfer({ to: sender_pkh, amount: 1 });
await op.confirmation();

// Sending 1 token from the account we want to empty
// This will do the reveal operation automatically
const op2 = await sender.contract.transfer({ to: await Tezos.signer.publicKeyHash(), amount: 0.1 });
await op2.confirmation();

const balance = await Tezos.tz.getBalance(sender_pkh);

const estimate = await sender.estimate.transfer({
to: receiver_pkh,
amount: 0.5,
});

// // Emptying the account
const totalFees = estimate.suggestedFeeMutez + estimate.burnFeeMutez;
const maxAmount = balance.minus(totalFees).toNumber();
// // Temporary fix, see https://gitlab.com/tezos/tezos/-/issues/1754
// // we need to increase the gasLimit and fee returned by the estimation
const gasBuffer = 500;
const MINIMAL_FEE_PER_GAS_MUTEZ = 0.1;
const increasedFee = (gasBuffer: number, opSize: number) => {
return (gasBuffer) * MINIMAL_FEE_PER_GAS_MUTEZ + opSize
}

const opTransfer = await sender.contract.transfer({
to: receiver_pkh,
mutez: true,
amount: maxAmount - increasedFee(gasBuffer, Number(estimate.opSize)),
fee: estimate.suggestedFeeMutez + increasedFee(gasBuffer, Number(estimate.opSize)), // baker fees
gasLimit: estimate.gasLimit + gasBuffer,
storageLimit: estimate.storageLimit
});

await opTransfer.confirmation();
const finalBalance = await Tezos.tz.getBalance(sender_pkh);

expect(finalBalance.toString()).toEqual("0")

done();
});

kathmandunetAndAlpha('Verify that a new unrevealed implicit account can be created from the sender account and the sender account can be emptied into the created one.', async (done) => {
it('Verify that a new unrevealed implicit account can be created from the sender account and the sender account can be emptied into the created one.', async (done) => {
const receiver = await createAddress();
const receiver_pkh = await receiver.signer.publicKeyHash();

Expand All @@ -74,7 +21,7 @@ CONFIGS().forEach(({ lib, rpc, protocol, setup, createAddress }) => {
const sender_pkh = await sender.signer.publicKeyHash();
const op = await Tezos.contract.transfer({ to: sender_pkh, amount: 1 });
await op.confirmation();

// Sending 1 token from the account we want to empty
// This will do the reveal operation automatically
const op2 = await sender.contract.transfer({ to: await Tezos.signer.publicKeyHash(), amount: 0.1 });
Expand All @@ -90,14 +37,14 @@ CONFIGS().forEach(({ lib, rpc, protocol, setup, createAddress }) => {
// // Emptying the account
const totalFees = estimate.suggestedFeeMutez + estimate.burnFeeMutez;
const maxAmount = balance.minus(totalFees).toNumber();

const opTransfer = await sender.contract.transfer({
to: receiver_pkh,
mutez: true,
amount: maxAmount,
fee: estimate.suggestedFeeMutez,
gasLimit: estimate.gasLimit,
storageLimit: estimate.storageLimit
amount: maxAmount,
fee: estimate.suggestedFeeMutez,
gasLimit: estimate.gasLimit,
storageLimit: estimate.storageLimit
});

await opTransfer.confirmation();
Expand All @@ -108,4 +55,4 @@ CONFIGS().forEach(({ lib, rpc, protocol, setup, createAddress }) => {
done();
});
});
})
})
Loading

0 comments on commit 2bf3ae4

Please sign in to comment.