@@ -14,27 +14,30 @@ import (
14
14
// Register clears any registered [params.Extras] and then registers `extras`
15
15
// for the lifetime of the current test, clearing them via tb's
16
16
// [testing.TB.Cleanup].
17
- func Register [C params.ChainConfigHooks , R params.RulesHooks ](tb testing.TB , extras params.Extras [C , R ]) {
17
+ func Register [C params.ChainConfigHooks , R params.RulesHooks ](tb testing.TB , extras params.Extras [C , R ]) params. ExtraPayloads [ C , R ] {
18
18
tb .Helper ()
19
19
params .TestOnlyClearRegisteredExtras ()
20
20
tb .Cleanup (params .TestOnlyClearRegisteredExtras )
21
- params .RegisterExtras (extras )
21
+ return params .RegisterExtras (extras )
22
22
}
23
23
24
24
// A Stub is a test double for [params.ChainConfigHooks] and
25
25
// [params.RulesHooks]. Each of the fields, if non-nil, back their respective
26
26
// hook methods, which otherwise fall back to the default behaviour.
27
27
type Stub struct {
28
+ CheckConfigForkOrderFn func () error
29
+ CheckConfigCompatibleFn func (* params.ChainConfig , * big.Int , uint64 ) * params.ConfigCompatError
30
+ DescriptionSuffix string
28
31
PrecompileOverrides map [common.Address ]libevm.PrecompiledContract
29
32
CanExecuteTransactionFn func (common.Address , * common.Address , libevm.StateReader ) error
30
33
CanCreateContractFn func (* libevm.AddressContext , uint64 , libevm.StateReader ) (uint64 , error )
31
34
}
32
35
33
36
// Register is a convenience wrapper for registering s as both the
34
37
// [params.ChainConfigHooks] and [params.RulesHooks] via [Register].
35
- func (s * Stub ) Register (tb testing.TB ) {
38
+ func (s * Stub ) Register (tb testing.TB ) params. ExtraPayloads [ * Stub , * Stub ] {
36
39
tb .Helper ()
37
- Register (tb , params.Extras [* Stub , * Stub ]{
40
+ return Register (tb , params.Extras [* Stub , * Stub ]{
38
41
NewRules : func (_ * params.ChainConfig , _ * params.Rules , _ * Stub , blockNum * big.Int , isMerge bool , timestamp uint64 ) * Stub {
39
42
return s
40
43
},
@@ -52,6 +55,29 @@ func (s Stub) PrecompileOverride(a common.Address) (libevm.PrecompiledContract,
52
55
return p , ok
53
56
}
54
57
58
+ // CheckConfigForkOrder proxies arguments to the s.CheckConfigForkOrderFn
59
+ // function if non-nil, otherwise it acts as a noop.
60
+ func (s Stub ) CheckConfigForkOrder () error {
61
+ if f := s .CheckConfigForkOrderFn ; f != nil {
62
+ return f ()
63
+ }
64
+ return nil
65
+ }
66
+
67
+ // CheckConfigCompatible proxies arguments to the s.CheckConfigCompatibleFn
68
+ // function if non-nil, otherwise it acts as a noop.
69
+ func (s Stub ) CheckConfigCompatible (newcfg * params.ChainConfig , headNumber * big.Int , headTimestamp uint64 ) * params.ConfigCompatError {
70
+ if f := s .CheckConfigCompatibleFn ; f != nil {
71
+ return f (newcfg , headNumber , headTimestamp )
72
+ }
73
+ return nil
74
+ }
75
+
76
+ // Description returns s.DescriptionSuffix.
77
+ func (s Stub ) Description () string {
78
+ return s .DescriptionSuffix
79
+ }
80
+
55
81
// CanExecuteTransaction proxies arguments to the s.CanExecuteTransactionFn
56
82
// function if non-nil, otherwise it acts as a noop.
57
83
func (s Stub ) CanExecuteTransaction (from common.Address , to * common.Address , sr libevm.StateReader ) error {
0 commit comments