[CLD-1781]: tests(operations-gen): add EVM golden tests#920
[CLD-1781]: tests(operations-gen): add EVM golden tests#920graham-chainlink wants to merge 1 commit intomainfrom
Conversation
|
There was a problem hiding this comment.
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.
d4adf18 to
5c618c8
Compare
e63b65b to
e6bcc9a
Compare
5c618c8 to
8379c2e
Compare
e6bcc9a to
e94ae22
Compare
8379c2e to
7158e62
Compare
e94ae22 to
3e98b36
Compare
7158e62 to
fdcf1e1
Compare
3e98b36 to
8b7d364
Compare
fdcf1e1 to
96ba700
Compare
8b7d364 to
1c9fe4c
Compare
96ba700 to
a595456
Compare
1c9fe4c to
c142d01
Compare
a595456 to
4d3274e
Compare
There was a problem hiding this comment.
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.
4d3274e to
c0982b5
Compare
c142d01 to
7ec42ee
Compare
c0982b5 to
63ab634
Compare
7ec42ee to
663feeb
Compare
63ab634 to
c355def
Compare
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
Add test for EVM to test generation of deploy link token and MCMS JIRA: https://smartcontract-it.atlassian.net/browse/CLD-1777
c355def to
60803b6
Compare
| @@ -0,0 +1 @@ | |||
| 0x60006000 | |||
There was a problem hiding this comment.
just a placeholder as the byte value is irrelevant for tests
There was a problem hiding this comment.
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.
| 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 | ||
| } | ||
|
|
There was a problem hiding this comment.
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.
| 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 | |
| } |
| 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"` | ||
| } |
There was a problem hiding this comment.
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.
|


Add golden tests for EVM to test generation of DeployLinkToken and MCMS
JIRA: https://smartcontract-it.atlassian.net/browse/CLD-1781