-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed fork consensus spec test (#7143)
- Loading branch information
1 parent
4a1c61a
commit 97e1767
Showing
4 changed files
with
57 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package consensustests | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/ledgerwatch/erigon/cl/clparams" | ||
) | ||
|
||
func forkTest(context testContext) error { | ||
prevContext := context | ||
prevContext.version-- | ||
preState, err := decodeStateFromFile(prevContext, "pre.ssz_snappy") | ||
if err != nil { | ||
return err | ||
} | ||
postState, err := decodeStateFromFile(context, "post.ssz_snappy") | ||
expectedError := os.IsNotExist(err) | ||
if err != nil && !expectedError { | ||
return err | ||
} | ||
|
||
if preState.Version() == clparams.Phase0Version { | ||
if err := preState.UpgradeToAltair(); err != nil { | ||
return err | ||
} | ||
} else if preState.Version() == clparams.AltairVersion { | ||
if err := preState.UpgradeToBellatrix(); err != nil { | ||
return err | ||
} | ||
} else if preState.Version() == clparams.BellatrixVersion { | ||
if err := preState.UpgradeToCapella(); err != nil { | ||
return err | ||
} | ||
} | ||
if expectedError { | ||
return fmt.Errorf("expected error") | ||
} | ||
root, err := preState.HashSSZ() | ||
if err != nil { | ||
return err | ||
} | ||
expectedRoot, err := postState.HashSSZ() | ||
if err != nil { | ||
return err | ||
} | ||
if root != expectedRoot { | ||
return fmt.Errorf("mismatching state roots") | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters