bsc/core/systemcontracts/upgrade_test.go

42 lines
1.0 KiB
Go
Raw Permalink Normal View History

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 {
for _, network := range []string{mainNet, chapelNet} {
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)
require.Equal(t, allCodeHash[:], common.Hex2Bytes("833cc0fc87c46ad8a223e44ccfdc16a51a7e7383525136441bd0c730f06023df"))
}