Skip to content

[CLD-1781]: tests(operations-gen): add EVM golden tests#920

Open
graham-chainlink wants to merge 1 commit intomainfrom
ggoh/cld-1777/golden-test-evm
Open

[CLD-1781]: tests(operations-gen): add EVM golden tests#920
graham-chainlink wants to merge 1 commit intomainfrom
ggoh/cld-1777/golden-test-evm

Conversation

@graham-chainlink
Copy link
Copy Markdown
Collaborator

@graham-chainlink graham-chainlink commented Apr 8, 2026

Add golden tests for EVM to test generation of DeployLinkToken and MCMS

JIRA: https://smartcontract-it.atlassian.net/browse/CLD-1781

@graham-chainlink graham-chainlink requested a review from Copilot April 8, 2026 08:07
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 8, 2026

⚠️ No Changeset found

Latest commit: 60803b6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an end-to-end golden test fixture for the EVM operations-gen tool to validate generation output for the LinkToken contract using real ABI/bytecode inputs.

Changes:

  • Add EVM fixtures (ABI + bytecode) for LinkToken v1.0.0.
  • Add a generated golden Go file to compare against generator output.
  • Add an E2E golden test that runs the EVM generator and diffs output vs the golden file.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.

File Description
tools/operations-gen/evm_golden_test.go New E2E test that runs generation into a temp dir and compares to a golden file (with -update support).
tools/operations-gen/testdata/evm/link_token.golden.go Golden generated output for LinkToken operations (used for diff-based verification).
tools/operations-gen/testdata/evm/abi/v1_0_0/link_token.json LinkToken ABI fixture consumed by the generator during the golden test.
tools/operations-gen/testdata/evm/bytecode/v1_0_0/link_token.bin LinkToken bytecode fixture consumed by the generator during the golden test.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@graham-chainlink graham-chainlink force-pushed the ggoh/cld-1777/golden-test-evm branch from d4adf18 to 5c618c8 Compare April 8, 2026 14:43
@graham-chainlink graham-chainlink force-pushed the ggoh/cld-1777/evm-support-operations-gen branch from e63b65b to e6bcc9a Compare April 8, 2026 14:43
@graham-chainlink graham-chainlink force-pushed the ggoh/cld-1777/golden-test-evm branch from 5c618c8 to 8379c2e Compare April 8, 2026 15:02
@graham-chainlink graham-chainlink force-pushed the ggoh/cld-1777/evm-support-operations-gen branch from e6bcc9a to e94ae22 Compare April 8, 2026 15:02
@graham-chainlink graham-chainlink force-pushed the ggoh/cld-1777/golden-test-evm branch from 8379c2e to 7158e62 Compare April 9, 2026 06:19
@graham-chainlink graham-chainlink force-pushed the ggoh/cld-1777/evm-support-operations-gen branch from e94ae22 to 3e98b36 Compare April 13, 2026 03:31
@graham-chainlink graham-chainlink force-pushed the ggoh/cld-1777/golden-test-evm branch from 7158e62 to fdcf1e1 Compare April 13, 2026 03:32
@graham-chainlink graham-chainlink force-pushed the ggoh/cld-1777/evm-support-operations-gen branch from 3e98b36 to 8b7d364 Compare April 13, 2026 03:48
@graham-chainlink graham-chainlink force-pushed the ggoh/cld-1777/golden-test-evm branch from fdcf1e1 to 96ba700 Compare April 13, 2026 03:48
@graham-chainlink graham-chainlink force-pushed the ggoh/cld-1777/evm-support-operations-gen branch from 8b7d364 to 1c9fe4c Compare April 13, 2026 04:18
@graham-chainlink graham-chainlink force-pushed the ggoh/cld-1777/golden-test-evm branch from 96ba700 to a595456 Compare April 13, 2026 04:18
@graham-chainlink graham-chainlink changed the title tests(operations-gen): add EVM golden test [CLD-1777]: tests(operations-gen): add EVM golden test Apr 13, 2026
@graham-chainlink graham-chainlink force-pushed the ggoh/cld-1777/evm-support-operations-gen branch from 1c9fe4c to c142d01 Compare April 13, 2026 04:32
@graham-chainlink graham-chainlink force-pushed the ggoh/cld-1777/golden-test-evm branch from a595456 to 4d3274e Compare April 13, 2026 04:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@graham-chainlink graham-chainlink force-pushed the ggoh/cld-1777/golden-test-evm branch from 4d3274e to c0982b5 Compare April 13, 2026 04:58
@graham-chainlink graham-chainlink force-pushed the ggoh/cld-1777/evm-support-operations-gen branch from c142d01 to 7ec42ee Compare April 13, 2026 05:02
@graham-chainlink graham-chainlink force-pushed the ggoh/cld-1777/golden-test-evm branch from c0982b5 to 63ab634 Compare April 13, 2026 05:02
@graham-chainlink graham-chainlink force-pushed the ggoh/cld-1777/evm-support-operations-gen branch from 7ec42ee to 663feeb Compare April 13, 2026 05:18
@graham-chainlink graham-chainlink force-pushed the ggoh/cld-1777/golden-test-evm branch from 63ab634 to c355def Compare April 13, 2026 05:18
github-merge-queue bot pushed a commit that referenced this pull request Apr 13, 2026
Add evm support for the operations-gen cli, ported the code from
https://github.com/smartcontractkit/chainlink-ccip/blob/main/chains/evm/cmd/operations-gen/main.go,
improved and adapted it to the new design

I have follow up PR adding some golden tests -
#920


JIRA: https://smartcontract-it.atlassian.net/browse/CLD-1777
Base automatically changed from ggoh/cld-1777/evm-support-operations-gen to main April 13, 2026 08:02
Add test for EVM to test generation of deploy link token and MCMS

JIRA: https://smartcontract-it.atlassian.net/browse/CLD-1777
@graham-chainlink graham-chainlink force-pushed the ggoh/cld-1777/golden-test-evm branch from c355def to 60803b6 Compare April 13, 2026 08:03
@graham-chainlink graham-chainlink changed the title [CLD-1777]: tests(operations-gen): add EVM golden test [CLD-1781]: tests(operations-gen): add EVM golden test Apr 13, 2026
@graham-chainlink graham-chainlink marked this pull request as ready for review April 13, 2026 08:05
@graham-chainlink graham-chainlink requested a review from a team as a code owner April 13, 2026 08:05
Copilot AI review requested due to automatic review settings April 13, 2026 08:05
@@ -0,0 +1 @@
0x60006000
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a placeholder as the byte value is irrelevant for tests

@graham-chainlink graham-chainlink changed the title [CLD-1781]: tests(operations-gen): add EVM golden test [CLD-1781]: tests(operations-gen): add EVM golden tests Apr 13, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +56 to +64
func (c *LinkTokenContract) Owner(opts *bind.CallOpts) (common.Address, error) {
var out []any
err := c.contract.Call(opts, &out, "owner")
if err != nil {
return common.Address{}, err
}
return *abi.ConvertType(out[0], new(common.Address)).(*common.Address), nil
}

Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generated LinkToken wrapper includes an Owner() method that unconditionally calls the owner function, but the LinkToken ABI fixture does not define an owner() function (it only has _owner parameters / event fields). This means the generated method will always fail at runtime if called, and it’s also confusing to ship in the golden output.

Suggested fix: make the generator/template emit Owner() only when (a) the ABI actually contains an owner() view function, or (b) at least one configured operation uses access: owner (and validate that owner() exists in the ABI in that case). Update the golden accordingly.

Suggested change
func (c *LinkTokenContract) Owner(opts *bind.CallOpts) (common.Address, error) {
var out []any
err := c.contract.Call(opts, &out, "owner")
if err != nil {
return common.Address{}, err
}
return *abi.ConvertType(out[0], new(common.Address)).(*common.Address), nil
}

Copilot uses AI. Check for mistakes.
Comment on lines +65 to +79
func (c *ManyChainMultiSigContract) SetConfig(opts *bind.TransactOpts, signerAddresses []common.Address, signerGroups []uint8, groupQuorums any, groupParents any, clearRoot bool) (*types.Transaction, error) {
return c.contract.Transact(opts, "setConfig", signerAddresses, signerGroups, groupQuorums, groupParents, clearRoot)
}

func (c *ManyChainMultiSigContract) SetRoot(opts *bind.TransactOpts, root [32]byte, validUntil uint32, metadata RootMetadata, metadataProof [][32]byte, signatures []Signature) (*types.Transaction, error) {
return c.contract.Transact(opts, "setRoot", root, validUntil, metadata, metadataProof, signatures)
}

type RootMetadata struct {
ChainId *big.Int `json:"chainId"`
MultiSig common.Address `json:"multiSig"`
PreOpCount any `json:"preOpCount"`
PostOpCount any `json:"postOpCount"`
OverridePreviousRoot bool `json:"overridePreviousRoot"`
}
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several parameters/fields that have concrete Solidity types in the ABI are generated as any (e.g., groupQuorums/groupParents are uint8[32], and preOpCount/postOpCount are uint40). This loses type-safety and makes it easy for callers to pass a value that the ABI packer can’t encode.

Suggested fix: extend the EVM type mapping to cover fixed-size arrays (e.g., map uint8[32][32]uint8) and missing integer widths like uint40 (could be uint64), then regenerate the golden output.

Copilot uses AI. Check for mistakes.
@cl-sonarqube-production
Copy link
Copy Markdown

Quality Gate failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants