Skip to content

Commit

Permalink
Merge branch 'oxford' of github.com:ecadlabs/taquito into oxford
Browse files Browse the repository at this point in the history
  • Loading branch information
hui-an-yang committed Sep 20, 2023
2 parents b0f584b + 59def8f commit fc2a6e1
Show file tree
Hide file tree
Showing 19 changed files with 202 additions and 384 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
- protocol: Nairobi
testnet: nairobinet
testnet_uppercase: NAIROBINET
flextesa_docker_image: oxheadalpha/flextesa:20230502
flextesa_docker_image: oxheadalpha/flextesa:20230607
- protocol: Oxford
testnet: oxfordnet
testnet_uppercase: OXFORDNET
Expand Down
2 changes: 2 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@
"nairobibox",
"nairobinet",
"octez",
"oxfordnet",
"oxheadalpha",
"precommit",
"println",
"Protofire",
"Proxford",
"PtNairobi",
"rollups",
"Roxane",
Expand Down
16 changes: 8 additions & 8 deletions integration-tests/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { KnownContracts } from './known-contracts';
import { knownContractsProtoALph } from './known-contracts-ProtoALph';
import { knownContractsPtGhostnet } from './known-contracts-PtGhostnet';
import { knownContractsPtNairobi } from './known-contracts-PtNairobi';
import { knownContractsProxford } from './known-contracts-Proxford';
import { knownContractsProxfordS } from './known-contracts-ProxfordS';

const nodeCrypto = require('crypto');

Expand All @@ -24,7 +24,7 @@ enum ForgerType {
COMPOSITE = 'composite',
}

export const isSandbox = (config: {rpc: string}) => {
export const isSandbox = (config: { rpc: string }) => {
return config.rpc.includes('localhost') || config.rpc.includes('0.0.0.0') || config.rpc.includes('127.0.0.1');
}

Expand Down Expand Up @@ -144,14 +144,14 @@ const nairobinetEphemeral: Config =
});

const nairobinetSecretKey: Config =
{ ...nairobinetEphemeral, ...{ signerConfig: defaultSecretKey }, ...{ defaultRpc: 'http://ecad-nairobinet-full:8732' } };
{ ...nairobinetEphemeral, ...{ signerConfig: defaultSecretKey }, ...{ defaultRpc: 'http://ecad-nairobinet-full:8732' } };

const oxfordnetEphemeral: Config =
defaultConfig({
networkName: 'OXFORDNET',
protocol: Protocols.Proxford,
defaultRpc: 'http://ecad-oxfordnet-full.i.tez.ie:8732',
knownContracts: knownContractsProxford,
knownContracts: knownContractsProxfordS,
signerConfig: defaultEphemeralConfig('https://keygen.ecadinfra.com/oxfordnet')
});

Expand All @@ -161,8 +161,8 @@ const oxfordnetSecretKey: Config =
const ghostnetEphemeral: Config =
defaultConfig({
networkName: 'GHOSTNET',
protocol: Protocols.PtMumbai2,
defaultRpc: 'ecad-ghostnet-rolling:8732',
protocol: Protocols.PtNairobi,
defaultRpc: 'http://ecad-ghostnet-rolling:8732',
knownContracts: knownContractsPtGhostnet,
signerConfig: defaultEphemeralConfig('https://keygen.ecadinfra.com/ghostnet')
});
Expand Down Expand Up @@ -265,13 +265,13 @@ const setupWithSecretKey = async (Tezos: TezosToolkit, signerConfig: SecretKeyCo
};

const configurePollingInterval = (Tezos: TezosToolkit, pollingIntervalMilliseconds: string | undefined) => {
if(pollingIntervalMilliseconds) {
if (pollingIntervalMilliseconds) {
Tezos.setStreamProvider(Tezos.getFactory(PollingSubscribeProvider)({ pollingIntervalMilliseconds: Number(pollingIntervalMilliseconds) }));
}
}

const configureRpcCache = (rpc: string, rpcCacheMilliseconds: string) => {
if(rpcCacheMilliseconds === '0') {
if (rpcCacheMilliseconds === '0') {
return new TezosToolkit(rpc);
} else {
return new TezosToolkit(new RpcClientCache(new RpcClient(rpc), Number(rpcCacheMilliseconds)));
Expand Down
14 changes: 7 additions & 7 deletions integration-tests/contract-estimation-tests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ CONFIGS().forEach(({ lib, setup, knownBaker, createAddress, rpc }) => {
expect(estimate.minimalFeeMutez).toEqual(472);
expect(estimate.totalCost).toEqual(472);
expect(estimate.usingBaseFeeMutez).toEqual(472);
expect(estimate.consumedMilligas).toEqual(1356735);
expect(estimate.consumedMilligas).toEqual(1356379);
done();
});

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

Expand All @@ -138,7 +138,7 @@ CONFIGS().forEach(({ lib, setup, knownBaker, createAddress, rpc }) => {
expect(estimate.minimalFeeMutez).toEqual(519);
expect(estimate.totalCost).toEqual(79769);
expect(estimate.usingBaseFeeMutez).toEqual(519);
expect(estimate.consumedMilligas).toEqual(1767848);
expect(estimate.consumedMilligas).toEqual(1767492);
done();
});

Expand All @@ -152,7 +152,7 @@ CONFIGS().forEach(({ lib, setup, knownBaker, createAddress, rpc }) => {
expect(estimate.minimalFeeMutez).toEqual(637);
expect(estimate.totalCost).toEqual(159137);
expect(estimate.usingBaseFeeMutez).toEqual(637);
expect(estimate.consumedMilligas).toEqual(2293496);
expect(estimate.consumedMilligas).toEqual(2293140);
// Do the actual operation
const op2 = await contract.methods.do(originate2()).send();
await op2.confirmation();
Expand Down Expand Up @@ -199,7 +199,7 @@ CONFIGS().forEach(({ lib, setup, knownBaker, createAddress, rpc }) => {
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',
id: expect.stringContaining('implicit_contract'),
});
done();
});
Expand All @@ -208,7 +208,7 @@ CONFIGS().forEach(({ lib, setup, knownBaker, createAddress, rpc }) => {
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('subtraction_underflow'),
});
done();
});
Expand Down
48 changes: 26 additions & 22 deletions integration-tests/data/allTestsCases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,85 +48,89 @@ interface TestCase {
expected?: object;
}

export const commonCases: TestCase[] = [
export const nairobiCases: TestCase[] = [

{
name: 'Delegation',
name: 'Set deposits limit 1000000',
operation: {
branch: 'BLzyjjHKEKMULtvkpSHxuZxx6ei6fpntH2BTkYZiLgs8zLVstvX',
contents: [
{
kind: OpKind.DELEGATION,
delegate: 'tz1QZ6KY7d3BuZDT1d19dUxoQrtFPN2QJ3hn',
kind: OpKind.SET_DEPOSITS_LIMIT,
counter: '1',
source: 'tz1QZ6KY7d3BuZDT1d19dUxoQrtFPN2QJ3hn',
fee: '10000',
gas_limit: '10',
storage_limit: '10',
limit: '1000000',
},
],
},
},
{
name: 'Reveal',
name: 'Unset deposits limit',
operation: {
branch: 'BLzyjjHKEKMULtvkpSHxuZxx6ei6fpntH2BTkYZiLgs8zLVstvX',
contents: [
{
kind: OpKind.REVEAL,
kind: OpKind.SET_DEPOSITS_LIMIT,
counter: '1',
source: 'tz1QZ6KY7d3BuZDT1d19dUxoQrtFPN2QJ3hn',
public_key: 'edpkvS5QFv7KRGfa3b87gg9DBpxSm3NpSwnjhUjNBQrRUUR66F7C9g',
fee: '10000',
gas_limit: '10',
storage_limit: '10',
storage_limit: '10'
},
],
},
},
]

export const commonCases: TestCase[] = [
{
name: 'Ballot',
name: 'Delegation',
operation: {
branch: 'BLzyjjHKEKMULtvkpSHxuZxx6ei6fpntH2BTkYZiLgs8zLVstvX',
contents: [
{
kind: OpKind.BALLOT,
kind: OpKind.DELEGATION,
delegate: 'tz1QZ6KY7d3BuZDT1d19dUxoQrtFPN2QJ3hn',
counter: '1',
source: 'tz1QZ6KY7d3BuZDT1d19dUxoQrtFPN2QJ3hn',
period: -300,
ballot: 'yay',
proposal: 'PsCARTHAGazKbHtnKfLzQg3kms52kSRpgnDY982a9oYsSXRLQEb',
fee: '10000',
gas_limit: '10',
storage_limit: '10',
},
],
},
},
{
name: 'Set deposits limit 1000000',
name: 'Reveal',
operation: {
branch: 'BLzyjjHKEKMULtvkpSHxuZxx6ei6fpntH2BTkYZiLgs8zLVstvX',
contents: [
{
kind: OpKind.SET_DEPOSITS_LIMIT,
kind: OpKind.REVEAL,
counter: '1',
source: 'tz1QZ6KY7d3BuZDT1d19dUxoQrtFPN2QJ3hn',
public_key: 'edpkvS5QFv7KRGfa3b87gg9DBpxSm3NpSwnjhUjNBQrRUUR66F7C9g',
fee: '10000',
gas_limit: '10',
storage_limit: '10',
limit: '1000000',
},
],
},
},
{
name: 'Unset deposits limit',
name: 'Ballot',
operation: {
branch: 'BLzyjjHKEKMULtvkpSHxuZxx6ei6fpntH2BTkYZiLgs8zLVstvX',
contents: [
{
kind: OpKind.SET_DEPOSITS_LIMIT,
counter: '1',
kind: OpKind.BALLOT,
source: 'tz1QZ6KY7d3BuZDT1d19dUxoQrtFPN2QJ3hn',
fee: '10000',
gas_limit: '10',
storage_limit: '10'
period: -300,
ballot: 'yay',
proposal: 'PsCARTHAGazKbHtnKfLzQg3kms52kSRpgnDY982a9oYsSXRLQEb',
},
],
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { KnownContracts } from './known-contracts';
export const knownContractsProxford: KnownContracts = {
export const knownContractsProxfordS: KnownContracts = {
contract: "KT1TU9LydXWri8CBTQmzwnwjCm3dK8jt1LQA",
bigMapContract: "KT1MYLamQavaVMYqgn9f4gMgHzEZfQD73qYs",
tzip12BigMapOffChainContract: "KT1XX1JK4C7aPL2joE7nfeWRwPdrJYwroAUa",
Expand Down
8 changes: 0 additions & 8 deletions integration-tests/known-contracts-PtMumbai2.ts

This file was deleted.

16 changes: 14 additions & 2 deletions integration-tests/local-forging.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
import { CONFIGS } from "./config";
import { commonCases } from './data/allTestsCases';
import { commonCases, nairobiCases } from './data/allTestsCases';
import { LocalForger, ProtocolsHash } from '@taquito/local-forging'
import { TezosToolkit } from "@taquito/taquito";
import { Protocols, TezosToolkit } from "@taquito/taquito";

CONFIGS().forEach(({ rpc, protocol }) => {
const Tezos = new TezosToolkit(rpc);
const nairobinet = protocol === Protocols.PtNairobi ? it : it.skip;

describe(`Test local forger: ${rpc}`, () => {
nairobiCases.forEach(({ name, operation, expected }) => {
// Oxford has removed to forge set and unset deposit limit ops in rpcForger.
// We removed them in localForger .forge, but keep the .parse logic for now.
nairobinet(`Verify that .parse for local forge will return same operation that rpc forge for rpc: ${name} (${rpc})`, async done => {
const localForger = new LocalForger(protocol as unknown as ProtocolsHash);
const rpcResult = await Tezos.rpc.forgeOperations(operation);
expect(await localForger.parse(rpcResult)).toEqual(expected || operation);

done();
});
});
// all protocols
commonCases.forEach(({ name, operation, expected }) => {
it(`Verify that .forge for local forge will return same result as for network forge for rpc: ${name} (${rpc})`, async done => {
Expand Down
34 changes: 23 additions & 11 deletions integration-tests/rpc-nodes.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CONFIGS } from './config';
import { DefaultContractType } from "@taquito/taquito";
import { RpcClientCache, RpcClient, RPCRunViewParam, RPCRunScriptViewParam, PendingOperations, PvmKind } from '@taquito/rpc';
import { CONFIGS, NetworkType } from './config';
import { DefaultContractType, Protocols } from "@taquito/taquito";
import { RpcClientCache, RpcClient, RPCRunViewParam, RPCRunScriptViewParam, PendingOperationsV1, PendingOperationsV2, PvmKind } from '@taquito/rpc';
import { encodeExpr } from '@taquito/utils';
import { Schema } from '@taquito/michelson-encoder';
import { tokenBigmapCode, tokenBigmapStorage } from './data/token_bigmap';
Expand All @@ -20,6 +20,7 @@ CONFIGS().forEach(
}) => {
const Tezos = lib;
const unrestrictedRPCNode = rpc.endsWith("ecadinfra.com") ? test.skip : test;
const oxfordnetAndAlpha = protocol === Protocols.Proxford || protocol === Protocols.ProtoALpha ? test : test.skip;

let ticketContract: DefaultContractType;

Expand Down Expand Up @@ -488,17 +489,28 @@ CONFIGS().forEach(
done();
});

it('Verify that rpcClient.getPendingOperations will retrieve the pending operations in mempool', async (done) => {
const pendingOperations: PendingOperations = await rpcClient.getPendingOperations();
expect(pendingOperations).toBeDefined();
expect(pendingOperations.applied).toBeInstanceOf(Array);
expect(pendingOperations.refused).toBeInstanceOf(Array);
expect(pendingOperations.outdated).toBeInstanceOf(Array);
expect(pendingOperations.branch_delayed).toBeInstanceOf(Array);
expect(pendingOperations.branch_refused).toBeInstanceOf(Array);
it('Verify that rpcClient.getPendingOperations version1 will retrieve the pending operations in mempool with property applied', async (done) => {
const pendingOperations1 = await rpcClient.getPendingOperations() as PendingOperationsV1;
expect(pendingOperations1).toBeDefined();
expect(pendingOperations1.applied).toBeInstanceOf(Array);
expect(pendingOperations1.refused).toBeInstanceOf(Array);
expect(pendingOperations1.outdated).toBeInstanceOf(Array);
expect(pendingOperations1.branch_delayed).toBeInstanceOf(Array);
expect(pendingOperations1.branch_refused).toBeInstanceOf(Array);
done();
});

oxfordnetAndAlpha('Verify that rpcClient.getPendingOperations version2 will retrieve the pending operations in mempool with property validated', async (done) => {
const pendingOperations2 = await rpcClient.getPendingOperations({ version: '2' }) as PendingOperationsV2;
expect(pendingOperations2).toBeDefined();
expect(pendingOperations2.validated).toBeInstanceOf(Array);
expect(pendingOperations2.refused).toBeInstanceOf(Array);
expect(pendingOperations2.outdated).toBeInstanceOf(Array);
expect(pendingOperations2.branch_delayed).toBeInstanceOf(Array);
expect(pendingOperations2.branch_refused).toBeInstanceOf(Array);
done();
})

it('Verify that rpcClient.getOriginationProof will retrieve the proof needed for smart rollup originate', async (done) => {
const proof = await rpcClient.getOriginationProof({
kernel: '23212f7573722f62696e2f656e762073680a6578706f7274204b45524e454c3d22303036313733366430313030303030303031323830373630303337663766376630313766363030323766376630313766363030353766376637663766376630313766363030313766303036303031376630313766363030323766376630303630303030303032363130333131373336643631373237343566373236663663366337353730356636333666373236353061373236353631363435663639366537303735373430303030313137333664363137323734356637323666366336633735373035663633366637323635306337373732363937343635356636663735373437303735373430303031313137333664363137323734356637323666366336633735373035663633366637323635306237333734366637323635356637373732363937343635303030323033303530343033303430353036303530333031303030313037313430323033366436353664303230303061366236353732366536353663356637323735366530303036306161343031303432613031303237663431666130303266303130303231303132303030326630313030323130323230303132303032343730343430343165343030343131323431303034316534303034313030313030323161306230623038303032303030343163343030366230623530303130353766343166653030326430303030323130333431666330303266303130303231303232303030326430303030323130343230303032663031303032313035323030313130303432313036323030343230303334363034343032303030343130313661323030313431303136623130303131613035323030353230303234363034343032303030343130373661323030363130303131613062306230623164303130313766343164633031343138343032343139303163313030303231303034313834303232303030313030353431383430323130303330623062333830353030343165343030306231323266366236353732366536353663326636353665373632663732363536323666366637343030343166383030306230323030303130303431666130303062303230303032303034316663303030623032303030303030343166653030306230313031220a',
Expand Down
Loading

0 comments on commit fc2a6e1

Please sign in to comment.