2024-04-15 11:23:23 +08:00
|
|
|
package systemcontracts
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/sha256"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestAllCodesHash(t *testing.T) {
|
|
|
|
upgradesList := [13]map[string]*Upgrade{
|
|
|
|
ramanujanUpgrade,
|
|
|
|
nielsUpgrade,
|
|
|
|
mirrorUpgrade,
|
|
|
|
brunoUpgrade,
|
|
|
|
eulerUpgrade,
|
|
|
|
gibbsUpgrade,
|
|
|
|
moranUpgrade,
|
|
|
|
planckUpgrade,
|
|
|
|
lubanUpgrade,
|
|
|
|
platoUpgrade,
|
|
|
|
keplerUpgrade,
|
|
|
|
feynmanUpgrade,
|
|
|
|
feynmanFixUpgrade}
|
|
|
|
|
|
|
|
allCodes := make([]byte, 0, 10_000_000)
|
|
|
|
for _, hardfork := range upgradesList {
|
2024-05-14 16:37:17 +08:00
|
|
|
for _, network := range []string{mainNet, chapelNet} {
|
2024-04-15 11:23:23 +08:00
|
|
|
allCodes = append(allCodes, []byte(network)...)
|
|
|
|
if hardfork[network] != nil {
|
|
|
|
for _, addressConfig := range hardfork[network].Configs {
|
|
|
|
allCodes = append(allCodes, addressConfig.ContractAddr[:]...)
|
|
|
|
allCodes = append(allCodes, addressConfig.Code[:]...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
allCodeHash := sha256.Sum256(allCodes)
|
2024-05-14 16:37:17 +08:00
|
|
|
require.Equal(t, allCodeHash[:], common.Hex2Bytes("833cc0fc87c46ad8a223e44ccfdc16a51a7e7383525136441bd0c730f06023df"))
|
2024-04-15 11:23:23 +08:00
|
|
|
}
|