@@ -22,6 +22,8 @@ import (
22
22
"testing"
23
23
"time"
24
24
25
+ "gotest.tools/assert"
26
+
25
27
"github.com/ethereum/go-ethereum/common/math"
26
28
)
27
29
@@ -134,3 +136,45 @@ func TestConfigRules(t *testing.T) {
134
136
t .Errorf ("expected %v to be shanghai" , 0 )
135
137
}
136
138
}
139
+
140
+ func TestBorKeyValueConfigHelper (t * testing.T ) {
141
+ t .Parallel ()
142
+
143
+ backupMultiplier := map [string ]uint64 {
144
+ "0" : 2 ,
145
+ "25275000" : 5 ,
146
+ "29638656" : 2 ,
147
+ }
148
+ assert .Equal (t , borKeyValueConfigHelper (backupMultiplier , 0 ), uint64 (2 ))
149
+ assert .Equal (t , borKeyValueConfigHelper (backupMultiplier , 1 ), uint64 (2 ))
150
+ assert .Equal (t , borKeyValueConfigHelper (backupMultiplier , 25275000 - 1 ), uint64 (2 ))
151
+ assert .Equal (t , borKeyValueConfigHelper (backupMultiplier , 25275000 ), uint64 (5 ))
152
+ assert .Equal (t , borKeyValueConfigHelper (backupMultiplier , 25275000 + 1 ), uint64 (5 ))
153
+ assert .Equal (t , borKeyValueConfigHelper (backupMultiplier , 29638656 - 1 ), uint64 (5 ))
154
+ assert .Equal (t , borKeyValueConfigHelper (backupMultiplier , 29638656 ), uint64 (2 ))
155
+ assert .Equal (t , borKeyValueConfigHelper (backupMultiplier , 29638656 + 1 ), uint64 (2 ))
156
+
157
+ config := map [string ]uint64 {
158
+ "0" : 1 ,
159
+ "90000000" : 2 ,
160
+ "100000000" : 3 ,
161
+ }
162
+ assert .Equal (t , borKeyValueConfigHelper (config , 0 ), uint64 (1 ))
163
+ assert .Equal (t , borKeyValueConfigHelper (config , 1 ), uint64 (1 ))
164
+ assert .Equal (t , borKeyValueConfigHelper (config , 90000000 - 1 ), uint64 (1 ))
165
+ assert .Equal (t , borKeyValueConfigHelper (config , 90000000 ), uint64 (2 ))
166
+ assert .Equal (t , borKeyValueConfigHelper (config , 90000000 + 1 ), uint64 (2 ))
167
+ assert .Equal (t , borKeyValueConfigHelper (config , 100000000 - 1 ), uint64 (2 ))
168
+ assert .Equal (t , borKeyValueConfigHelper (config , 100000000 ), uint64 (3 ))
169
+ assert .Equal (t , borKeyValueConfigHelper (config , 100000000 + 1 ), uint64 (3 ))
170
+
171
+ burntContract := map [string ]string {
172
+ "22640000" : "0x70bcA57F4579f58670aB2d18Ef16e02C17553C38" ,
173
+ "41824608" : "0x617b94CCCC2511808A3C9478ebb96f455CF167aA" ,
174
+ }
175
+ assert .Equal (t , borKeyValueConfigHelper (burntContract , 22640000 ), "0x70bcA57F4579f58670aB2d18Ef16e02C17553C38" )
176
+ assert .Equal (t , borKeyValueConfigHelper (burntContract , 22640000 + 1 ), "0x70bcA57F4579f58670aB2d18Ef16e02C17553C38" )
177
+ assert .Equal (t , borKeyValueConfigHelper (burntContract , 41824608 - 1 ), "0x70bcA57F4579f58670aB2d18Ef16e02C17553C38" )
178
+ assert .Equal (t , borKeyValueConfigHelper (burntContract , 41824608 ), "0x617b94CCCC2511808A3C9478ebb96f455CF167aA" )
179
+ assert .Equal (t , borKeyValueConfigHelper (burntContract , 41824608 + 1 ), "0x617b94CCCC2511808A3C9478ebb96f455CF167aA" )
180
+ }
0 commit comments