@@ -8,23 +8,63 @@ import (
8
8
"github.com/stretchr/testify/require"
9
9
)
10
10
11
+ func TestValidatorPriceListStoreKey (t * testing.T ) {
12
+ // Prefix: 0x10
13
+ expect , _ := hex .DecodeString ("100a31303030303030303031" )
14
+ require .Equal (t , expect , ValidatorPriceListStoreKey (sdk .ValAddress ("1000000001" )))
15
+
16
+ // Test with empty validator address
17
+ emptyVal := sdk.ValAddress {}
18
+ expectEmpty , _ := hex .DecodeString ("10" )
19
+ require .Equal (t , expectEmpty , ValidatorPriceListStoreKey (emptyVal ))
20
+ }
21
+
22
+ func TestPriceStoreKey (t * testing.T ) {
23
+ // Prefix: 0x11
24
+ expect , _ := hex .DecodeString ("1142414e44" )
25
+ require .Equal (t , expect , PriceStoreKey ("BAND" ))
26
+
27
+ // Test with empty string
28
+ expectEmpty , _ := hex .DecodeString ("11" )
29
+ require .Equal (t , expectEmpty , PriceStoreKey ("" ))
30
+ }
31
+
11
32
func TestDelegatorSignalsStoreKey (t * testing.T ) {
33
+ // Prefix: 0x12
12
34
acc , _ := sdk .AccAddressFromHexUnsafe ("b80f2a5df7d5710b15622d1a9f1e3830ded5bda8" )
13
- expect , _ := hex .DecodeString ("0314b80f2a5df7d5710b15622d1a9f1e3830ded5bda8 " )
35
+ expect , _ := hex .DecodeString ("1214b80f2a5df7d5710b15622d1a9f1e3830ded5bda8 " )
14
36
require .Equal (t , expect , DelegatorSignalsStoreKey (acc ))
37
+
38
+ // Test with empty address
39
+ emptyAcc := sdk.AccAddress {}
40
+ expectEmpty , _ := hex .DecodeString ("12" )
41
+ require .Equal (t , expectEmpty , DelegatorSignalsStoreKey (emptyAcc ))
15
42
}
16
43
17
44
func TestSignalTotalPowerStoreKey (t * testing.T ) {
18
- expect , _ := hex .DecodeString ("0442414e44" )
45
+ // Prefix: 0x13
46
+ expect , _ := hex .DecodeString ("1342414e44" )
19
47
require .Equal (t , expect , SignalTotalPowerStoreKey ("BAND" ))
20
- }
21
48
22
- func TestValidatorPriceListStoreKey ( t * testing. T ) {
23
- expect , _ := hex .DecodeString ("010a31303030303030303031 " )
24
- require .Equal (t , expect , ValidatorPriceListStoreKey ( sdk . ValAddress ( "1000000001" ) ))
49
+ // Test with empty string
50
+ expectEmpty , _ := hex .DecodeString ("13 " )
51
+ require .Equal (t , expectEmpty , SignalTotalPowerStoreKey ( "" ))
25
52
}
26
53
27
- func TestPriceStoreKey (t * testing.T ) {
28
- expect , _ := hex .DecodeString ("0242414e44" )
29
- require .Equal (t , expect , PriceStoreKey ("BAND" ))
54
+ func TestSignalTotalPowerByPowerIndexKey (t * testing.T ) {
55
+ // Prefix: 0x80
56
+ // Test with signal ID "BAND" and power 100
57
+ expect , _ := hex .DecodeString (
58
+ "80000000000000006404bdbeb1bb" ,
59
+ ) // Signal ID "BAND" with power 100, Signal ID bytes negated
60
+ require .Equal (t , expect , SignalTotalPowerByPowerIndexKey ("BAND" , 100 ))
61
+
62
+ // Test with empty signal ID and zero power
63
+ expectEmpty , _ := hex .DecodeString ("80000000000000000000" )
64
+ require .Equal (t , expectEmpty , SignalTotalPowerByPowerIndexKey ("" , 0 ))
65
+
66
+ // Test with empty signal ID and large power
67
+ largePower := int64 (9223372036854775807 ) // Max int64
68
+ expectLargePower , _ := hex .DecodeString ("807fffffffffffffff00" )
69
+ require .Equal (t , expectLargePower , SignalTotalPowerByPowerIndexKey ("" , largePower ))
30
70
}
0 commit comments