Skip to content

Commit 5ea6bf2

Browse files
committed
add missing switch cases and tests
1 parent 0225899 commit 5ea6bf2

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

encoding/da.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -768,8 +768,10 @@ func GetHardforkName(config *params.ChainConfig, blockHeight, blockTimestamp uin
768768
return "euclid"
769769
} else if !config.IsFeynman(blockTimestamp) {
770770
return "euclidV2"
771-
} else {
771+
} else if !config.IsGalileo(blockTimestamp) {
772772
return "feynman"
773+
} else {
774+
return "galileo"
773775
}
774776
}
775777

@@ -791,8 +793,10 @@ func GetCodecVersion(config *params.ChainConfig, blockHeight, blockTimestamp uin
791793
return CodecV6
792794
} else if !config.IsFeynman(blockTimestamp) {
793795
return CodecV7
794-
} else {
796+
} else if !config.IsGalileo(blockTimestamp) {
795797
return CodecV8
798+
} else {
799+
return CodecV9
796800
}
797801
}
798802

@@ -821,7 +825,7 @@ func GetChunkEnableCompression(codecVersion CodecVersion, chunk *Chunk) (bool, e
821825
return false, nil
822826
case CodecV2, CodecV3:
823827
return true, nil
824-
case CodecV4, CodecV5, CodecV6, CodecV7, CodecV8:
828+
case CodecV4, CodecV5, CodecV6, CodecV7, CodecV8, CodecV9:
825829
return CheckChunkCompressedDataCompatibility(chunk, codecVersion)
826830
default:
827831
return false, fmt.Errorf("unsupported codec version: %v", codecVersion)
@@ -835,7 +839,7 @@ func GetBatchEnableCompression(codecVersion CodecVersion, batch *Batch) (bool, e
835839
return false, nil
836840
case CodecV2, CodecV3:
837841
return true, nil
838-
case CodecV4, CodecV5, CodecV6, CodecV7, CodecV8:
842+
case CodecV4, CodecV5, CodecV6, CodecV7, CodecV8, CodecV9:
839843
return CheckBatchCompressedDataCompatibility(batch, codecVersion)
840844
default:
841845
return false, fmt.Errorf("unsupported codec version: %v", codecVersion)

encoding/interfaces_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ func TestCodecFromVersion(t *testing.T) {
2525
{"CodecV6", CodecV6, &DACodecV6{}, false},
2626
{"CodecV7", CodecV7, &DACodecV7{}, false},
2727
{"CodecV8", CodecV8, &DACodecV8{}, false},
28+
{"CodecV9", CodecV9, &DACodecV9{}, false},
29+
{"CodecV10", CodecVersion(10), nil, true}, // not defined yet
2830
{"InvalidCodec", CodecVersion(99), nil, true},
2931
}
3032

@@ -49,6 +51,39 @@ func TestCodecFromConfig(t *testing.T) {
4951
timestamp uint64
5052
want Codec
5153
}{
54+
{
55+
name: "Galileo active",
56+
config: &params.ChainConfig{
57+
LondonBlock: big.NewInt(0),
58+
BernoulliBlock: big.NewInt(0),
59+
CurieBlock: big.NewInt(0),
60+
DarwinTime: new(uint64),
61+
DarwinV2Time: new(uint64),
62+
EuclidTime: new(uint64),
63+
EuclidV2Time: new(uint64),
64+
FeynmanTime: new(uint64),
65+
GalileoTime: new(uint64),
66+
},
67+
blockNum: big.NewInt(0),
68+
timestamp: 0,
69+
want: &DACodecV9{},
70+
},
71+
{
72+
name: "Feynman active",
73+
config: &params.ChainConfig{
74+
LondonBlock: big.NewInt(0),
75+
BernoulliBlock: big.NewInt(0),
76+
CurieBlock: big.NewInt(0),
77+
DarwinTime: new(uint64),
78+
DarwinV2Time: new(uint64),
79+
EuclidTime: new(uint64),
80+
EuclidV2Time: new(uint64),
81+
FeynmanTime: new(uint64),
82+
},
83+
blockNum: big.NewInt(0),
84+
timestamp: 0,
85+
want: &DACodecV8{},
86+
},
5287
{
5388
name: "EuclidV2 active",
5489
config: &params.ChainConfig{

0 commit comments

Comments
 (0)