Skip to content

Commit

Permalink
feat: supports attesation along side endorsement
Browse files Browse the repository at this point in the history
  • Loading branch information
hui-an-yang committed Dec 21, 2023
1 parent ee1220a commit 77b6025
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 44 deletions.
81 changes: 41 additions & 40 deletions integration-tests/data/allTestsCases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,36 +48,18 @@ interface TestCase {
expected?: object;
}

export const nairobiCases: TestCase[] = [
export const oxfordCases: TestCase[] = [
{
name: 'Set deposits limit 1000000',
name: 'Attestation',
operation: {
branch: 'BLzyjjHKEKMULtvkpSHxuZxx6ei6fpntH2BTkYZiLgs8zLVstvX',
contents: [
{
kind: OpKind.SET_DEPOSITS_LIMIT,
counter: '1',
source: 'tz1QZ6KY7d3BuZDT1d19dUxoQrtFPN2QJ3hn',
fee: '10000',
gas_limit: '10',
storage_limit: '10',
limit: '1000000',
},
],
},
},
{
name: 'Unset deposits limit',
operation: {
branch: 'BLzyjjHKEKMULtvkpSHxuZxx6ei6fpntH2BTkYZiLgs8zLVstvX',
contents: [
{
kind: OpKind.SET_DEPOSITS_LIMIT,
counter: '1',
source: 'tz1QZ6KY7d3BuZDT1d19dUxoQrtFPN2QJ3hn',
fee: '10000',
gas_limit: '10',
storage_limit: '10'
kind: OpKind.ATTESTATION,
slot: 0,
level: 66299,
round: 5,
block_payload_hash: 'vh3FEkypvxUYLwjGYd2Sme7aWyfX8npDsqxcL6imVpBWnAZeNn2n',
},
],
},
Expand Down Expand Up @@ -134,6 +116,40 @@ export const commonCases: TestCase[] = [
],
},
},

{
name: 'Set deposits limit 1000000',
operation: {
branch: 'BLzyjjHKEKMULtvkpSHxuZxx6ei6fpntH2BTkYZiLgs8zLVstvX',
contents: [
{
kind: OpKind.SET_DEPOSITS_LIMIT,
counter: '1',
source: 'tz1QZ6KY7d3BuZDT1d19dUxoQrtFPN2QJ3hn',
fee: '10000',
gas_limit: '10',
storage_limit: '10',
limit: '1000000',
},
],
},
},
{
name: 'Unset deposits limit',
operation: {
branch: 'BLzyjjHKEKMULtvkpSHxuZxx6ei6fpntH2BTkYZiLgs8zLVstvX',
contents: [
{
kind: OpKind.SET_DEPOSITS_LIMIT,
counter: '1',
source: 'tz1QZ6KY7d3BuZDT1d19dUxoQrtFPN2QJ3hn',
fee: '10000',
gas_limit: '10',
storage_limit: '10'
},
],
},
},
{
name: 'Seed nonce revelation',
operation: {
Expand Down Expand Up @@ -1171,21 +1187,6 @@ export const commonCases: TestCase[] = [
],
},
},
{
name: 'Endorsement',
operation: {
branch: 'BLzyjjHKEKMULtvkpSHxuZxx6ei6fpntH2BTkYZiLgs8zLVstvX',
contents: [
{
kind: OpKind.ENDORSEMENT,
slot: 0,
level: 66299,
round: 5,
block_payload_hash: 'vh3FEkypvxUYLwjGYd2Sme7aWyfX8npDsqxcL6imVpBWnAZeNn2n',
},
],
},
},
{
name: `Origination of a contract that contains the instructions SUB_MUTEZ`,
operation: {
Expand Down
9 changes: 5 additions & 4 deletions integration-tests/local-forging.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { CONFIGS } from "./config";
import { commonCases, nairobiCases } from './data/allTestsCases';
import { commonCases, oxfordCases } from './data/allTestsCases';
import { LocalForger, ProtocolsHash } from '@taquito/local-forging'
import { Protocols, TezosToolkit } from "@taquito/taquito";
import { ProtoGreaterOrEqual } from '@taquito/michel-codec'

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

describe(`Test local forger: ${rpc}`, () => {
// all protocols
nairobiCases.forEach(({ name, operation, expected }) => {
nairobinet(`Verify that .forge for local forge will return same result as for network forge for rpc: ${name} (${rpc})`, async () => {
oxfordCases.forEach(({ name, operation, expected }) => {
oxfordAndAlpha(`Verify that .forge for local forge will return same result as for network forge for rpc: ${name} (${rpc})`, async () => {
const localForger = new LocalForger(protocol as unknown as ProtocolsHash);
const result = await localForger.forge(operation);
const rpcResult = await Tezos.rpc.forgeOperations(operation);
Expand Down
2 changes: 2 additions & 0 deletions packages/taquito/src/subscribe/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const opHashFilter = (op: OperationContent, filter: OpHashFilter) => op.hash ===

const sourceFilter = (x: OperationContent, filter: SourceFilter) => {
switch (x.kind) {
case 'attestation':
return 'metadata' in x && x.metadata.delegate === filter.source;
case 'endorsement':
return 'metadata' in x && x.metadata.delegate === filter.source;
case 'activate_account':
Expand Down

0 comments on commit 77b6025

Please sign in to comment.