Skip to content

Commit

Permalink
chore: Remove snapshots from protocol-contracts (#5342)
Browse files Browse the repository at this point in the history
They have been a very annoying source of conflicts, and are not
providing any valuable data. Let's remove them.
  • Loading branch information
spalladino authored Mar 20, 2024
1 parent 1868e25 commit 31ca344
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 151 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { setupCustomSnapshotSerializers } from '@aztec/foundation/testing';

import omit from 'lodash.omit';
import { computeContractAddressFromInstance, getContractClassFromArtifact } from '@aztec/circuits.js';

import { ClassRegistererAddress, getCanonicalClassRegisterer } from './index.js';

describe('ClassRegisterer', () => {
setupCustomSnapshotSerializers(expect);
it('returns canonical protocol contract', () => {
const contract = getCanonicalClassRegisterer();
expect(omit(contract, 'artifact')).toMatchSnapshot();
expect(computeContractAddressFromInstance(contract.instance)).toEqual(contract.address);
expect(getContractClassFromArtifact(contract.artifact).id).toEqual(contract.contractClass.id);
expect(contract.address.toString()).toEqual(ClassRegistererAddress.toString());
});
});

This file was deleted.

19 changes: 3 additions & 16 deletions yarn-project/protocol-contracts/src/gas-token/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
import { EthAddress } from '@aztec/circuits.js';
import { setupCustomSnapshotSerializers } from '@aztec/foundation/testing';

import omit from 'lodash.omit';
import { EthAddress, computeContractAddressFromInstance, getContractClassFromArtifact } from '@aztec/circuits.js';

import { getCanonicalGasToken } from './index.js';

describe('GasToken', () => {
setupCustomSnapshotSerializers(expect);
it('returns canonical protocol contract', () => {
// if you're updating the snapshots here then you'll also have to update CANONICAL_GAS_TOKEN_ADDRESS in
// - noir-projects/noir-contracts/contracts/fpc_contract/src/main.nr
// - noir-projects/noir-contracts/contracts/app_subscription_contract/src/main.nr
const contract = getCanonicalGasToken(EthAddress.ZERO);
expect(omit(contract, ['artifact', 'contractClass'])).toMatchSnapshot();

// bytecode is very large
expect(omit(contract.contractClass, ['packedBytecode', 'publicFunctions'])).toMatchSnapshot();

// this contract has public bytecode
expect(contract.contractClass.publicFunctions.map(x => omit(x, 'bytecode'))).toMatchSnapshot();
expect(contract.contractClass.packedBytecode.length).toBeGreaterThan(0);
expect(computeContractAddressFromInstance(contract.instance)).toEqual(contract.address);
expect(getContractClassFromArtifact(contract.artifact).id).toEqual(contract.contractClass.id);
});
});

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { computeContractAddressFromInstance, getContractClassFromArtifact } from '@aztec/circuits.js';
import { setupCustomSnapshotSerializers } from '@aztec/foundation/testing';

import omit from 'lodash.omit';

import { InstanceDeployerAddress, getCanonicalInstanceDeployer } from './index.js';

describe('InstanceDeployer', () => {
setupCustomSnapshotSerializers(expect);
it('returns canonical protocol contract', () => {
// TODO(@spalladino): Consider sorting functions by selector when constructing the contract
// class, or even better, when calling loadContractArtifact from the Noir output.
const contract = getCanonicalInstanceDeployer();
expect(omit(contract, 'artifact')).toMatchSnapshot();
expect(computeContractAddressFromInstance(contract.instance)).toEqual(contract.address);
expect(getContractClassFromArtifact(contract.artifact).id).toEqual(contract.contractClass.id);
expect(contract.address.toString()).toEqual(InstanceDeployerAddress.toString());
});
});

0 comments on commit 31ca344

Please sign in to comment.