Skip to content

Commit 01fcbb7

Browse files
committed
fix: update methods
1 parent cb14671 commit 01fcbb7

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

internal/strategy/chain_event_processor_strategy_test.go

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ func buildMockCurrentState(
3232
require.Len(t, parts, 2, "Invalid key format: %s", keyStr)
3333
objID, key := parts[0], parts[1]
3434

35-
keyHex := actor.keyHashHex(objID, key)
36-
valueHex, err := actor.valueHashHex(value)
35+
keyHex := actor.db.KeyHashHex(objID, key)
36+
valueHex, err := actor.db.ValueHashHex(value)
3737
require.NoError(t, err)
3838
currentState[keyHex] = valueHex
3939
}
@@ -59,7 +59,7 @@ func mustValueHash(
5959
v interface{},
6060
) string {
6161
t.Helper()
62-
hash, err := actor.valueHashHex(v)
62+
hash, err := actor.db.ValueHashHex(v)
6363
require.NoError(t, err)
6464
return hash
6565
}
@@ -123,8 +123,8 @@ func TestDiffTrieOps_InsertionsOnly(t *testing.T) {
123123
assert.Len(t, deletions, 0)
124124

125125
expectedKeys := map[string]bool{
126-
actor.keyHashHex("user1", "name"): true,
127-
actor.keyHashHex("user1", "age"): true,
126+
actor.db.KeyHashHex("user1", "name"): true,
127+
actor.db.KeyHashHex("user1", "age"): true,
128128
}
129129
for _, insertion := range insertions {
130130
assert.True(
@@ -158,8 +158,8 @@ func TestDiffTrieOps_UpdatesOnly(t *testing.T) {
158158
assert.Len(t, deletions, 0)
159159

160160
expectedKeys := map[string]bool{
161-
actor.keyHashHex("user1", "name"): true,
162-
actor.keyHashHex("user1", "age"): true,
161+
actor.db.KeyHashHex("user1", "name"): true,
162+
actor.db.KeyHashHex("user1", "age"): true,
163163
}
164164
for _, update := range updates {
165165
assert.True(
@@ -194,8 +194,8 @@ func TestDiffTrieOps_DeletionsOnly(t *testing.T) {
194194
assert.Len(t, deletions, 2)
195195

196196
expectedKeys := map[string]bool{
197-
actor.keyHashHex("user1", "name"): true,
198-
actor.keyHashHex("user1", "age"): true,
197+
actor.db.KeyHashHex("user1", "name"): true,
198+
actor.db.KeyHashHex("user1", "age"): true,
199199
}
200200
for _, deletion := range deletions {
201201
assert.True(
@@ -234,9 +234,9 @@ func TestDiffTrieOps_MixedOperations(t *testing.T) {
234234
assert.Greater(t, len(updates), 0, "Should have some updates")
235235
assert.Greater(t, len(deletions), 0, "Should have some deletions")
236236

237-
user1NameKey := actor.keyHashHex("user1", "name")
238-
user1EmailKey := actor.keyHashHex("user1", "email")
239-
user3NameKey := actor.keyHashHex("user3", "name")
237+
user1NameKey := actor.db.KeyHashHex("user1", "name")
238+
user1EmailKey := actor.db.KeyHashHex("user1", "email")
239+
user3NameKey := actor.db.KeyHashHex("user3", "name")
240240

241241
found := false
242242
for _, update := range updates {
@@ -374,14 +374,14 @@ func TestValueHashHex(t *testing.T) {
374374

375375
for _, tc := range testCases {
376376
t.Run(tc.name, func(t *testing.T) {
377-
hash, err := actor.valueHashHex(tc.value)
377+
hash, err := actor.db.ValueHashHex(tc.value)
378378
assert.NoError(t, err)
379379
assert.NotEmpty(t, hash)
380380

381381
_, err = hex.DecodeString(hash)
382382
assert.NoError(t, err)
383383

384-
hash2, err := actor.valueHashHex(tc.value)
384+
hash2, err := actor.db.ValueHashHex(tc.value)
385385
assert.NoError(t, err)
386386
assert.Equal(t, hash, hash2, "Same value should produce same hash")
387387
})
@@ -404,13 +404,13 @@ func TestKeyHashHex(t *testing.T) {
404404

405405
for _, tc := range testCases {
406406
t.Run(tc.objID+"_"+tc.key, func(t *testing.T) {
407-
hash := actor.keyHashHex(tc.objID, tc.key)
407+
hash := actor.db.KeyHashHex(tc.objID, tc.key)
408408
assert.NotEmpty(t, hash)
409409

410410
_, err := hex.DecodeString(hash)
411411
assert.NoError(t, err)
412412

413-
hash2 := actor.keyHashHex(tc.objID, tc.key)
413+
hash2 := actor.db.KeyHashHex(tc.objID, tc.key)
414414
assert.Equal(
415415
t,
416416
hash,
@@ -419,7 +419,7 @@ func TestKeyHashHex(t *testing.T) {
419419
)
420420

421421
if tc.objID != "" && tc.key != "" {
422-
differentHash := actor.keyHashHex(tc.objID+"_diff", tc.key)
422+
differentHash := actor.db.KeyHashHex(tc.objID+"_diff", tc.key)
423423
assert.NotEqual(
424424
t,
425425
hash,
@@ -457,7 +457,7 @@ func TestValidateTrieOperations_ValidCase(t *testing.T) {
457457
Value string `json:"value"`
458458
}{
459459
{
460-
Key: actor.keyHashHex("user1", "email"),
460+
Key: actor.db.KeyHashHex("user1", "email"),
461461
Value: mustValueHash(t, actor, "alice@example.com"),
462462
},
463463
}
@@ -466,18 +466,18 @@ func TestValidateTrieOperations_ValidCase(t *testing.T) {
466466
Value string `json:"value"`
467467
}{
468468
{
469-
Key: actor.keyHashHex("user1", "name"),
469+
Key: actor.db.KeyHashHex("user1", "name"),
470470
Value: mustValueHash(t, actor, "Alice Updated"),
471471
},
472472
{
473-
Key: actor.keyHashHex("user1", "age"),
473+
Key: actor.db.KeyHashHex("user1", "age"),
474474
Value: mustValueHash(t, actor, 26),
475475
},
476476
}
477477
actualDeletions := []struct {
478478
Key string `json:"key"`
479479
}{
480-
{Key: actor.keyHashHex("user3", "status")},
480+
{Key: actor.db.KeyHashHex("user3", "status")},
481481
}
482482

483483
report, err := actor.validateTrieOperations(
@@ -517,11 +517,11 @@ func TestValidateTrieOperations_InvalidCase(t *testing.T) {
517517
Value string `json:"value"`
518518
}{
519519
{
520-
Key: actor.keyHashHex("user1", "name"),
520+
Key: actor.db.KeyHashHex("user1", "name"),
521521
Value: mustValueHash(t, actor, "Alice"),
522522
},
523523
{
524-
Key: actor.keyHashHex("user1", "age"),
524+
Key: actor.db.KeyHashHex("user1", "age"),
525525
Value: mustValueHash(t, actor, 25),
526526
},
527527
}

0 commit comments

Comments
 (0)