forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathdeployer_test.go
More file actions
96 lines (71 loc) · 2.95 KB
/
Copy pathdeployer_test.go
File metadata and controls
96 lines (71 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package sysgo
import (
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/require"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/artifacts"
"github.com/ethereum-optimism/optimism/op-devstack/devtest"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/intentbuilder"
"github.com/ethereum-optimism/optimism/op-service/eth"
)
func TestLocalContractSourcesLocator(t *testing.T) {
t.Parallel()
t.Run("valid dir", func(t *testing.T) {
t.Parallel()
artifactsDir := filepath.Join(t.TempDir(), "forge-artifacts")
require.NoError(t, os.Mkdir(artifactsDir, 0o755))
loc, err := localContractSourcesLocator(artifactsDir)
require.NoError(t, err)
require.True(t, artifacts.MustNewFileLocator(artifactsDir).Equal(loc))
})
t.Run("missing dir", func(t *testing.T) {
t.Parallel()
_, err := localContractSourcesLocator(filepath.Join(t.TempDir(), "missing"))
require.Error(t, err)
})
}
func TestLocalContractSourcesLocatorAcceptsContractsBedrockRoot(t *testing.T) {
t.Parallel()
contractsDir := filepath.Join(t.TempDir(), "packages", "contracts-bedrock")
require.NoError(t, os.MkdirAll(filepath.Join(contractsDir, "forge-artifacts"), 0o755))
loc, err := localContractSourcesLocator(contractsDir)
require.NoError(t, err)
require.True(t, artifacts.MustNewFileLocator(contractsDir).Equal(loc))
}
func TestWithLocalContractSourcesAt(t *testing.T) {
t.Parallel()
artifactsDir := filepath.Join(t.TempDir(), "forge-artifacts")
require.NoError(t, os.Mkdir(artifactsDir, 0o755))
builder := newValidIntentBuilder()
dt := devtest.SerialT(t)
WithLocalContractSourcesAt(artifactsDir)(dt, nil, builder)
intent, err := builder.Build()
require.NoError(t, err)
expected := artifacts.MustNewFileLocator(artifactsDir)
require.True(t, expected.Equal(intent.L1ContractsLocator))
require.True(t, expected.Equal(intent.L2ContractsLocator))
}
func newValidIntentBuilder() intentbuilder.Builder {
builder := intentbuilder.New()
_, superchain := builder.WithSuperchain()
superchain.WithProxyAdminOwner(common.HexToAddress("0x1"))
superchain.WithGuardian(common.HexToAddress("0x2"))
superchain.WithProtocolVersionsOwner(common.HexToAddress("0x3"))
superchain.WithChallenger(common.HexToAddress("0x4"))
builder, _ = builder.WithL1(eth.ChainIDFromUInt64(1))
_, l2 := builder.WithL2(eth.ChainIDFromUInt64(10))
l2.WithBaseFeeVaultRecipient(common.HexToAddress("0x5"))
l2.WithSequencerFeeVaultRecipient(common.HexToAddress("0x6"))
l2.WithL1FeeVaultRecipient(common.HexToAddress("0x7"))
l2.WithOperatorFeeVaultRecipient(common.HexToAddress("0x8"))
l2.WithL1ProxyAdminOwner(common.HexToAddress("0x9"))
l2.WithL2ProxyAdminOwner(common.HexToAddress("0xa"))
l2.WithSystemConfigOwner(common.HexToAddress("0xb"))
l2.WithUnsafeBlockSigner(common.HexToAddress("0xc"))
l2.WithBatcher(common.HexToAddress("0xd"))
l2.WithProposer(common.HexToAddress("0xe"))
l2.WithChallenger(common.HexToAddress("0xf"))
return builder
}