MCPcopy Create free account
hub / github.com/akash-network/node / TestCalculateBlocksDiff_DefaultParams

Function TestCalculateBlocksDiff_DefaultParams

x/bme/keeper/keeper_test.go:52–88  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

50}
51
52func TestCalculateBlocksDiff_DefaultParams(t *testing.T) {
53 // EpochBlocksBackoffPercent=10 (10%), base = 1.1
54 // result = 10 * 1.1^steps, truncated
55 params := defaultTestParams()
56
57 tests := []struct {
58 name string
59 cr int64
60 expected int64
61 }{
62 // 0.950 → steps=0 → 10
63 {"cr_9500_steps_0", 9500, 10},
64 // 0.949 → steps=1 → floor(10 * 1.1) = 11
65 {"cr_9490_steps_1", 9490, 11},
66 // 0.948 → steps=2 → floor(10 * 1.21) = 12
67 {"cr_9480_steps_2", 9480, 12},
68 // 0.945 → steps=5 → floor(10 * 1.1^5) = floor(16.1051) = 16
69 {"cr_9450_steps_5", 9450, 16},
70 // 0.940 → steps=10 → floor(10 * 1.1^10) = floor(25.937) = 25
71 {"cr_9400_steps_10", 9400, 25},
72 // 0.930 → steps=20 → floor(10 * 1.1^20) = floor(67.275) = 67
73 {"cr_9300_steps_20", 9300, 67},
74 // 0.920 → steps=30 → floor(10 * 1.1^30) = floor(174.494) = 174
75 {"cr_9200_steps_30", 9200, 174},
76 // 0.910 → steps=40 → floor(10 * 1.1^40) = floor(452.593) = 452
77 {"cr_9100_steps_40", 9100, 452},
78 // 0.900 → steps=50 → floor(10 * 1.1^50) = floor(1173.909) = 1173
79 {"cr_9000_steps_50", 9000, 1173},
80 }
81
82 for _, tc := range tests {
83 t.Run(tc.name, func(t *testing.T) {
84 result := calculateBlocksDiff(params, tc.cr)
85 require.Equal(t, tc.expected, result, "cr=%d", tc.cr)
86 })
87 }
88}
89
90func TestCalculateBlocksDiff_AggressiveBackoff(t *testing.T) {
91 // EpochBlocksBackoffPercent=100 (100%), base = 2.0

Callers

nothing calls this directly

Calls 3

defaultTestParamsFunction · 0.85
calculateBlocksDiffFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected