Skip to content

Commit

Permalink
2065 local forging support new operations for lima 2 (#2139)
Browse files Browse the repository at this point in the history
* feat: support new types for new operations UpdateConsensusKey and DrainDelegate in Lima

re #2066

* test: update_consensus_key unit test added for limanet

re #2066

* feat: support new operation UpdateConsensusKey for Lima

re #2065

* feat: support new operation updateConsensusKey in local-forger for Lima

re #2065

* revert: removed unnecesorry change of updateConsensusKey in rpc-batch-provider

re #2065

* revert: changes of update_consensus_key in RpcContractProvider and RPCEstimateProvider

re #2065

* feat: support new operation drainDelegate for Lima

re #2065

* feat: support new encoding for ticket & ticket depreacted in lima with tests

re #2072

* fix: added ASSERT_SOME in ticketCode and fixed 2 integration tests in lima

re #2072

* fix: fixs merge conflicts

* fix: replaced ASSERT_SOME with its expansion in ticketCode

re #2072

* test: added local-forgin integration tests for new operations

re #2065

* fix: address comments removed duplicate tests and move kathcases to commoncases

re #2065

* fix: address comments to remove kathcases integration tests

re #2065

* test: address comments add forge and parse operation test suite back with lima cases

re #2065

* test: addressing comments updated file name and added simicolons

re #2065

* test: address comments added semicolon

re #2065

* fix: configure localforger with lima protocol hash with lima cases

re #2065

* fix: removed update_consensus_key & drain_delegate from encodersProto14 and decoderProto14

re #2065
  • Loading branch information
hui-an-yang authored Nov 28, 2022
1 parent 5652389 commit fd18fcb
Show file tree
Hide file tree
Showing 23 changed files with 2,742 additions and 1,740 deletions.
110 changes: 110 additions & 0 deletions integration-tests/contract-deploy-having-ticket.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import { CONFIGS } from "./config";
import { ticketCode } from './data/code_with_ticket';
import { ticketCodeProto14 } from './data/code_with_ticket_proto14';
import { Protocols } from "@taquito/taquito";

CONFIGS().forEach(({ lib, rpc, setup, protocol }) => {
const Tezos = lib;
const kathmandunet = protocol === Protocols.PtKathman ? test: test.skip;
const limanetAndAlpha = protocol === Protocols.PtLimaPtL || protocol === Protocols.ProtoALpha ? test: test.skip;

describe(`Test origination of a token contract using: ${rpc}`, () => {

beforeEach(async (done) => {
await setup();
done();
});

kathmandunet('Originates a contract having ticket with init and the contract api', async (done) => {
const op = await Tezos.contract.originate({
code: ticketCodeProto14,
init: `(Pair None None)`
});

await op.confirmation();
expect(op.hash).toBeDefined();
expect(op.includedInBlock).toBeLessThan(Number.POSITIVE_INFINITY);

done();
});

kathmandunet('Originates a contract having ticket with init in JSON and the contract api', async (done) => {
const op = await Tezos.contract.originate({
code: ticketCodeProto14,
init: { prim: 'Pair', args: [ { prim: 'None' }, { prim: 'None' } ] }
});

await op.confirmation();
expect(op.hash).toBeDefined();
expect(op.includedInBlock).toBeLessThan(Number.POSITIVE_INFINITY);

done();
});

kathmandunet('Originates a contract having ticket with storage and the contract api', async (done) => {
const op = await Tezos.contract.originate({
code: ticketCodeProto14,
storage: {
'%x': null,
'%y': null
}
});

await op.confirmation();
expect(op.hash).toBeDefined();
expect(op.includedInBlock).toBeLessThan(Number.POSITIVE_INFINITY);

done();
});
});

describe(`Test origination of a token contract using: ${rpc}`, () => {

beforeEach(async (done) => {
await setup();
done();
});

limanetAndAlpha('Originates a contract having ticket with init and the contract api', async (done) => {
const op = await Tezos.contract.originate({
code: ticketCode,
init: `(Pair None None)`
});

await op.confirmation();
expect(op.hash).toBeDefined();
expect(op.includedInBlock).toBeLessThan(Number.POSITIVE_INFINITY);

done();
});

limanetAndAlpha('Originates a contract having ticket with init in JSON and the contract api', async (done) => {
const op = await Tezos.contract.originate({
code: ticketCode,
init: { prim: 'Pair', args: [ { prim: 'None' }, { prim: 'None' } ] }
});

await op.confirmation();
expect(op.hash).toBeDefined();
expect(op.includedInBlock).toBeLessThan(Number.POSITIVE_INFINITY);

done();
});

limanetAndAlpha('Originates a contract having ticket with storage and the contract api', async (done) => {
const op = await Tezos.contract.originate({
code: ticketCode,
storage: {
'%x': null,
'%y': null
}
});

await op.confirmation();
expect(op.hash).toBeDefined();
expect(op.includedInBlock).toBeLessThan(Number.POSITIVE_INFINITY);

done();
});
});
})
67 changes: 0 additions & 67 deletions integration-tests/contract-edo-deploy-having-ticket.spec.ts

This file was deleted.

115 changes: 85 additions & 30 deletions integration-tests/data/allTestsCases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ import {
example9,
example10,
} from './code_with_sapling';
import { ticketCode, ticketStorage } from './code_with_ticket';
import {
ticketCode,
ticketCode2,
ticketCode3,
ticketCode4,
ticketStorage,
ticketStorage2,
ticketStorage3,
ticketStorage4,
} from './code_with_ticket';
ticketCodeProto14,
ticketCode2Proto14,
ticketCode3Proto14,
ticketCode4Proto14,
ticketStorageProto14,
ticketStorage2Proto14,
ticketStorage3Proto14,
ticketStorage4Proto14,
} from './code_with_ticket_proto14';
import { genericCode, genericStorage } from './generic_contract';
import { tokenBigmapCode, tokenBigmapStorage } from './token_bigmap';
import { noAnnotCode, noAnnotInit } from './token_without_annotation';
Expand All @@ -30,6 +31,7 @@ import {
import { codeViewsTopLevel, storageViewsTopLevel } from './contract_views_top_level';
import { MichelsonV1Expression, OpKind } from '@taquito/rpc';
import { emitCode } from './code_with_emit';
import { opMappingProto14 } from '../../packages/taquito-local-forging/src/proto14-kathmandu/constants-proto14'

function extractOp(
startIndex: number,
Expand Down Expand Up @@ -804,7 +806,7 @@ export const commonCases: TestCase[] = [
],
},
},
...extractOp(0, 150, opMapping).map((op): TestCase => {
...extractOp(0, 151, opMappingProto14).map((op): TestCase => {
return {
name: `Origination operation (${op})`,
operation: {
Expand Down Expand Up @@ -941,8 +943,8 @@ export const commonCases: TestCase[] = [
storage_limit: '10',
balance: '0',
script: {
code: ticketCode,
storage: ticketStorage,
code: ticketCodeProto14,
storage: ticketStorageProto14,
},
},
],
Expand All @@ -962,8 +964,8 @@ export const commonCases: TestCase[] = [
storage_limit: '10',
balance: '0',
script: {
code: ticketCode2,
storage: ticketStorage2,
code: ticketCode2Proto14,
storage: ticketStorage2Proto14,
},
},
],
Expand All @@ -983,8 +985,8 @@ export const commonCases: TestCase[] = [
storage_limit: '10',
balance: '0',
script: {
code: ticketCode3,
storage: ticketStorage3,
code: ticketCode3Proto14,
storage: ticketStorage3Proto14,
},
},
],
Expand All @@ -1004,8 +1006,8 @@ export const commonCases: TestCase[] = [
storage_limit: '10',
balance: '0',
script: {
code: ticketCode4,
storage: ticketStorage4,
code: ticketCode4Proto14,
storage: ticketStorage4Proto14,
},
},
],
Expand Down Expand Up @@ -1342,10 +1344,52 @@ export const commonCases: TestCase[] = [
],
},
},
{
name: `Origination of a contract that contains the instructions EMIT`,
operation: {
branch: 'BMV9bffK5yjWCJgUJBsoTRifb4SsAYbkCVwVkKbJHffJYn7ePBL',
contents: [
{
kind: OpKind.ORIGINATION,
counter: '94141',
source: 'tz2WH1zahKo2KiS1gcHBhNFTURPfW1Vk7qpE',
fee: '603',
gas_limit: '1526',
storage_limit: '377',
balance: '0',
script: {
code: emitCode,
storage: {
prim: 'Unit',
},
},
},
],
},
},
{
name: `Increase Paid Storage operation`,
operation: {
branch: 'BMV9bffK5yjWCJgUJBsoTRifb4SsAYbkCVwVkKbJHffJYn7ePBL',
contents: [
{
kind: OpKind.INCREASE_PAID_STORAGE,
counter: '1',
source: 'tz2WH1zahKo2KiS1gcHBhNFTURPfW1Vk7qpE',
fee: '100',
gas_limit: '10000',
storage_limit: '10',
amount: '2',
destination: 'KT1JHqHQdHSgWBKo6H4UfG8dw3JnZSyjGkHA',
},
],
},
},
];

export const kathmanduCases: TestCase[] = [
...extractOp(150, 151, opMapping).map((op): TestCase => {
export const limaCases: TestCase[] = [
// In `opMapping` from the file `constants.ts`, the operations and types starting at `ticket` were added in the lima protocol
...extractOp(154, 154, opMapping).map((op): TestCase => {
return {
name: `Origination operation (${op})`,
operation: {
Expand All @@ -1369,7 +1413,7 @@ export const kathmanduCases: TestCase[] = [
};
}),
{
name: `Origination of a contract that contains the instructions EMIT`,
name: `Origination of a contract that contains the instructions TICKET`,
operation: {
branch: 'BMV9bffK5yjWCJgUJBsoTRifb4SsAYbkCVwVkKbJHffJYn7ePBL',
contents: [
Expand All @@ -1382,29 +1426,40 @@ export const kathmanduCases: TestCase[] = [
storage_limit: '377',
balance: '0',
script: {
code: emitCode,
storage: {
prim: 'Unit',
},
code: ticketCode,
storage: ticketStorage,
},
},
],
},
},
{
name: `Increase Paid Storage operation`,
name: `Update Consensus Key operation`,
operation: {
branch: 'BMV9bffK5yjWCJgUJBsoTRifb4SsAYbkCVwVkKbJHffJYn7ePBL',
contents: [
{
kind: OpKind.INCREASE_PAID_STORAGE,
kind: OpKind.UPDATE_CONSENSUS_KEY,
counter: '1',
source: 'tz2WH1zahKo2KiS1gcHBhNFTURPfW1Vk7qpE',
source: 'tz1KvJCU5cNdz5RAS3diEtdRvS9wfhRC7Cwj',
fee: '100',
gas_limit: '10000',
storage_limit: '10',
amount: '2',
destination: 'KT1JHqHQdHSgWBKo6H4UfG8dw3JnZSyjGkHA',
pk: 'edpkti5K5JbdLpp2dCqiTLoLQqs5wqzeVhfHVnNhsSCuoU8zdHYoY7'
},
],
},
},
{
name: `Drain Delegate operation`,
operation: {
branch: 'BMV9bffK5yjWCJgUJBsoTRifb4SsAYbkCVwVkKbJHffJYn7ePBL',
contents: [
{
kind: OpKind.DRAIN_DELEGATE,
consensus_key: 'tz1MY8g5UqVmQtpAp7qs1cUwEof1GjZCHgVv',
delegate: 'tz1MY8g5UqVmQtpAp7qs1cUwEof1GjZCHgVv',
destination: 'tz1KvJCU5cNdz5RAS3diEtdRvS9wfhRC7Cwj',
},
],
},
Expand Down
Loading

0 comments on commit fd18fcb

Please sign in to comment.