|
| 1 | +package state |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + "github.com/ethereum/go-ethereum/common" |
| 7 | + "github.com/ethereum/go-ethereum/common/hexutil" |
| 8 | + "github.com/stretchr/testify/require" |
| 9 | +) |
| 10 | + |
| 11 | +func TestCombineDeployConfig(t *testing.T) { |
| 12 | + intent := Intent{ |
| 13 | + L1ChainID: 1, |
| 14 | + } |
| 15 | + chainState := ChainState{ |
| 16 | + ID: common.HexToHash("0x123"), |
| 17 | + } |
| 18 | + chainIntent := ChainIntent{ |
| 19 | + Eip1559Denominator: 1, |
| 20 | + Eip1559Elasticity: 2, |
| 21 | + BaseFeeVaultRecipient: common.HexToAddress("0x123"), |
| 22 | + L1FeeVaultRecipient: common.HexToAddress("0x456"), |
| 23 | + SequencerFeeVaultRecipient: common.HexToAddress("0x789"), |
| 24 | + Roles: ChainRoles{ |
| 25 | + SystemConfigOwner: common.HexToAddress("0x123"), |
| 26 | + L1ProxyAdminOwner: common.HexToAddress("0x456"), |
| 27 | + L2ProxyAdminOwner: common.HexToAddress("0x789"), |
| 28 | + UnsafeBlockSigner: common.HexToAddress("0xabc"), |
| 29 | + Batcher: common.HexToAddress("0xdef"), |
| 30 | + }, |
| 31 | + } |
| 32 | + state := State{ |
| 33 | + SuperchainDeployment: &SuperchainDeployment{ProtocolVersionsProxyAddress: common.HexToAddress("0x123")}, |
| 34 | + } |
| 35 | + |
| 36 | + // apply hard fork overrides |
| 37 | + chainIntent.DeployOverrides = map[string]any{ |
| 38 | + "l2GenesisGraniteTimeOffset": "0x8", |
| 39 | + "l2GenesisHoloceneTimeOffset": "0x10", |
| 40 | + } |
| 41 | + |
| 42 | + out, err := CombineDeployConfig(&intent, &chainIntent, &state, &chainState) |
| 43 | + require.NoError(t, err) |
| 44 | + require.Equal(t, *out.L2InitializationConfig.UpgradeScheduleDeployConfig.L2GenesisFjordTimeOffset, hexutil.Uint64(0)) |
| 45 | + require.Equal(t, *out.L2InitializationConfig.UpgradeScheduleDeployConfig.L2GenesisGraniteTimeOffset, hexutil.Uint64(8)) |
| 46 | + require.Equal(t, *out.L2InitializationConfig.UpgradeScheduleDeployConfig.L2GenesisHoloceneTimeOffset, hexutil.Uint64(16)) |
| 47 | +} |
0 commit comments