Skip to content

Commit

Permalink
refactor: removed set_deposit_limit in local-forger.forge() for oxford
Browse files Browse the repository at this point in the history
  • Loading branch information
hui-an-yang committed Sep 14, 2023
1 parent b0f584b commit d4cd4bc
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 35 deletions.
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
15 changes: 13 additions & 2 deletions integration-tests/local-forging.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
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 }) => {
nairobinet(`Verify that .forge for local forge will return same result as for network forge for rpc: ${name} (${rpc})`, async done => {
const localForger = new LocalForger(protocol as unknown as ProtocolsHash);
const result = await localForger.forge(operation);
const rpcResult = await Tezos.rpc.forgeOperations(operation);
expect(result).toEqual(rpcResult);

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
4 changes: 0 additions & 4 deletions packages/taquito-local-forging/src/codec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,10 +501,6 @@ export const burnLimitDecoder = (value: Uint8ArrayConsumer) => {
}
};

export const depositsLimitEncoder = (val: string) => {
return !val ? '00' : `ff${zarithEncoder(val)}`;
};

export const depositsLimitDecoder = (value: Uint8ArrayConsumer) => {
const prefix = value.consume(1);
if (Buffer.from(prefix).toString('hex') !== '00') {
Expand Down
5 changes: 0 additions & 5 deletions packages/taquito-local-forging/src/encoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
proposalEncoder,
proposalsEncoder,
publicKeyEncoder,
depositsLimitEncoder,
pvmKindEncoder,
smartContractAddressEncoder,
smartRollupAddressEncoder,
Expand Down Expand Up @@ -49,7 +48,6 @@ import {
TransferTicketSchema,
TxRollupOriginationSchema,
TxRollupSubmitBatchSchema,
SetDepositsLimitSchema,
SmartRollupOriginateSchema,
SmartRollupExecuteOutboxMessageSchema,
SmartRollupAddMessagesSchema,
Expand Down Expand Up @@ -85,7 +83,6 @@ export const encoders: { [key: string]: Encoder<any> } = {
[CODEC.TX_ROLLUP_ID]: txRollupIdEncoder,
[CODEC.TX_ROLLUP_BATCH_CONTENT]: txRollupBatchContentEncoder,
[CODEC.BURN_LIMIT]: burnLimitEncoder,
[CODEC.DEPOSITS_LIMIT]: depositsLimitEncoder,
[CODEC.PVM_KIND]: pvmKindEncoder,
[CODEC.PADDED_BYTES]: paddedBytesEncoder,
[CODEC.SMART_ROLLUP_MESSAGE]: smartRollupMessageEncoder,
Expand Down Expand Up @@ -122,6 +119,4 @@ encoders[CODEC.OP_SMART_ROLLUP_ADD_MESSAGES] = (val: any) =>
encoders[CODEC.OP_SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE] = (val: any) =>
schemaEncoder(encoders)(SmartRollupExecuteOutboxMessageSchema)(val);
encoders[CODEC.MANAGER] = schemaEncoder(encoders)(ManagerOperationSchema);
encoders[CODEC.OP_SET_DEPOSITS_LIMIT] = (val) =>
schemaEncoder(encoders)(SetDepositsLimitSchema)(val);
encoders[CODEC.OP_FAILING_NOOP] = (val: any) => schemaEncoder(encoders)(FailingNoopSchema)(val);
2 changes: 0 additions & 2 deletions packages/taquito-local-forging/src/taquito-local-forging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ export class LocalForger implements Forger {
continue;
} else if (content.kind === 'transaction' && diff[0] === 'parameters') {
continue;
} else if (content.kind === 'set_deposits_limit' && diff[0] === 'limit') {
continue;
} else if (
content.kind === ('tx_rollup_submit_batch' as unknown) &&
diff[0] === 'burn_limit'
Expand Down

0 comments on commit d4cd4bc

Please sign in to comment.