|
| 1 | +import { expect } from 'chai'; |
| 2 | + |
| 3 | +import { type ChainAddresses } from '@hyperlane-xyz/registry'; |
| 4 | +import { |
| 5 | + type CoreConfig, |
| 6 | + type DerivedCoreConfig, |
| 7 | + HookType, |
| 8 | + IsmType, |
| 9 | +} from '@hyperlane-xyz/sdk'; |
| 10 | +import { |
| 11 | + ProtocolType, |
| 12 | + assert, |
| 13 | + isValidAddressSealevel, |
| 14 | +} from '@hyperlane-xyz/utils'; |
| 15 | +import { SealevelIgpHookReader, createRpc } from '@hyperlane-xyz/sealevel-sdk'; |
| 16 | + |
| 17 | +import { readYamlOrJson, writeYamlOrJson } from '../../../utils/files.js'; |
| 18 | +import { HyperlaneE2ECoreTestCommands } from '../../commands/core.js'; |
| 19 | +import { |
| 20 | + CORE_ADDRESSES_PATH_BY_PROTOCOL, |
| 21 | + CORE_CONFIG_PATH_BY_PROTOCOL, |
| 22 | + CORE_READ_CONFIG_PATH_BY_PROTOCOL, |
| 23 | + HYP_DEPLOYER_ADDRESS_BY_PROTOCOL, |
| 24 | + HYP_KEY_BY_PROTOCOL, |
| 25 | + REGISTRY_PATH, |
| 26 | + TEST_CHAIN_METADATA_BY_PROTOCOL, |
| 27 | +} from '../../constants.js'; |
| 28 | + |
| 29 | +// SVM deploys programs from bytes (~90+ write-chunk transactions per program), |
| 30 | +// so the suite needs a generous timeout. |
| 31 | +const SVM_DEPLOY_TIMEOUT = 600_000; |
| 32 | + |
| 33 | +describe('hyperlane core deploy (Sealevel E2E tests)', async function () { |
| 34 | + this.timeout(SVM_DEPLOY_TIMEOUT); |
| 35 | + |
| 36 | + const hyperlaneCore = new HyperlaneE2ECoreTestCommands( |
| 37 | + ProtocolType.Sealevel, |
| 38 | + 'svmlocal1', |
| 39 | + REGISTRY_PATH, |
| 40 | + CORE_CONFIG_PATH_BY_PROTOCOL.sealevel, |
| 41 | + CORE_READ_CONFIG_PATH_BY_PROTOCOL.sealevel.CHAIN_NAME_1, |
| 42 | + ); |
| 43 | + |
| 44 | + it('should create a core deployment with the signer as the mailbox owner', async () => { |
| 45 | + const coreConfig: CoreConfig = await readYamlOrJson( |
| 46 | + CORE_CONFIG_PATH_BY_PROTOCOL.sealevel, |
| 47 | + ); |
| 48 | + |
| 49 | + writeYamlOrJson( |
| 50 | + CORE_READ_CONFIG_PATH_BY_PROTOCOL.sealevel.CHAIN_NAME_1, |
| 51 | + coreConfig, |
| 52 | + ); |
| 53 | + hyperlaneCore.setCoreInputPath( |
| 54 | + CORE_READ_CONFIG_PATH_BY_PROTOCOL.sealevel.CHAIN_NAME_1, |
| 55 | + ); |
| 56 | + |
| 57 | + await hyperlaneCore.deploy(HYP_KEY_BY_PROTOCOL.sealevel); |
| 58 | + |
| 59 | + // Validate core read (mailbox-level assertions) |
| 60 | + const derivedCoreConfig: DerivedCoreConfig = |
| 61 | + await hyperlaneCore.readConfig(); |
| 62 | + |
| 63 | + expect(derivedCoreConfig.owner).to.equal( |
| 64 | + HYP_DEPLOYER_ADDRESS_BY_PROTOCOL.sealevel, |
| 65 | + ); |
| 66 | + expect(derivedCoreConfig.proxyAdmin?.owner).to.be.undefined; |
| 67 | + |
| 68 | + const deployedDefaultIsm = derivedCoreConfig.defaultIsm; |
| 69 | + assert( |
| 70 | + deployedDefaultIsm.type === IsmType.TEST_ISM, |
| 71 | + `Expected deployed defaultIsm to be of type ${IsmType.TEST_ISM}`, |
| 72 | + ); |
| 73 | + |
| 74 | + // Validate the registry has the deployed addresses |
| 75 | + const addresses: ChainAddresses = await readYamlOrJson( |
| 76 | + CORE_ADDRESSES_PATH_BY_PROTOCOL.sealevel.CHAIN_NAME_1, |
| 77 | + ); |
| 78 | + expect(isValidAddressSealevel(addresses.interchainGasPaymaster)).to.be.true; |
| 79 | + expect(isValidAddressSealevel(addresses.mailbox)).to.be.true; |
| 80 | + expect(isValidAddressSealevel(addresses.validatorAnnounce)).to.be.true; |
| 81 | + |
| 82 | + // Validate the IGP hook was properly deployed via direct hook read |
| 83 | + const rpc = createRpc( |
| 84 | + TEST_CHAIN_METADATA_BY_PROTOCOL.sealevel.CHAIN_NAME_1.rpcUrl, |
| 85 | + ); |
| 86 | + // Zero salt matches DEFAULT_IGP_SALT used by the CLI core deploy flow. |
| 87 | + const igpReader = new SealevelIgpHookReader(rpc, new Uint8Array(32)); |
| 88 | + assert( |
| 89 | + addresses.interchainGasPaymaster, |
| 90 | + 'Expected interchainGasPaymaster address to be defined', |
| 91 | + ); |
| 92 | + const igpArtifact = await igpReader.read(addresses.interchainGasPaymaster); |
| 93 | + assert( |
| 94 | + igpArtifact.config.type === HookType.INTERCHAIN_GAS_PAYMASTER, |
| 95 | + `Expected hook to be of type ${HookType.INTERCHAIN_GAS_PAYMASTER}, got ${igpArtifact.config.type}`, |
| 96 | + ); |
| 97 | + }); |
| 98 | +}); |
0 commit comments