The core protocol of WoopChain
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
woop/internal/params/config_test.go

45 lines
1.2 KiB

package params
import (
"math/big"
"reflect"
"testing"
)
func TestCheckCompatible(t *testing.T) {
type test struct {
stored, new *ChainConfig
head uint64
wantErr *ConfigCompatError
}
tests := []test{
{stored: AllProtocolChanges, new: AllProtocolChanges, head: 0, wantErr: nil},
{stored: AllProtocolChanges, new: AllProtocolChanges, head: 100, wantErr: nil},
{
stored: &ChainConfig{EIP155Epoch: big.NewInt(10)},
new: &ChainConfig{EIP155Epoch: big.NewInt(20)},
head: 9,
wantErr: nil,
},
{
stored: &ChainConfig{S3Epoch: big.NewInt(30), EIP155Epoch: big.NewInt(10)},
new: &ChainConfig{S3Epoch: big.NewInt(25), EIP155Epoch: big.NewInt(20)},
head: 25,
wantErr: &ConfigCompatError{
What: "EIP155 fork block",
StoredConfig: big.NewInt(10),
NewConfig: big.NewInt(20),
RewindTo: 9,
},
},
}
for _, test := range tests {
err := test.stored.CheckCompatible(test.new, test.head)
if !reflect.DeepEqual(err, test.wantErr) {
// TODO: re-enable this once CheckCompatible is updated.
//t.Errorf("error mismatch:\nstored: %v\nnew: %v\nhead: %v\nerr: %v\nwant: %v", test.stored, test.new, test.head, err, test.wantErr)
}
}
}