Skip to content

Commit

Permalink
unit-test fixed
Browse files Browse the repository at this point in the history
Signed-off-by: Angelo De Caro <[email protected]>
  • Loading branch information
adecaro committed Sep 25, 2024
1 parent 08521ad commit dad6f06
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion platform/common/core/generic/vault/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ func TTestMerge(t *testing.T, ddb VersionedPersistence, vp artifactsProvider) {
},
}
rwsb.ReadSet.Add(ns, k1, versionBlockTxNumToBytes(35, 1))
rwsb.ReadSet.Add(ns, ne2Key, versionBlockTxNumToBytes(0, 0))
rwsb.ReadSet.Add(ns, ne2Key, nil)
rwsb.WriteSet.Add(ns, k1, []byte("newv1"))
rwsb.MetaWriteSet.Add(ns, k1, map[string][]byte{"k1": []byte("v1")})
m := vp.NewMarshaller()
Expand Down
17 changes: 11 additions & 6 deletions platform/view/services/db/dbtest/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ func TTestRangeQueries(t *testing.T, db driver.TransactionalVersionedPersistence
res = append(res, *n)
}
assert.Len(t, res, 2)
assert.Equal(t, expected, res)
for _, read := range expected {
assert.Contains(t, res, read)
}
}

func TTestMeta(t *testing.T, db driver.TransactionalVersionedPersistence) {
Expand Down Expand Up @@ -215,7 +217,7 @@ func TTestMeta(t *testing.T, db driver.TransactionalVersionedPersistence) {
err = db.BeginUpdate()
assert.NoError(t, err)

err = db.SetStateMetadata(ns, key, map[string][]byte{"foo": []byte("bar")}, nil)
err = db.SetStateMetadata(ns, key, map[string][]byte{"foo": []byte("bar")}, ToBytes(36, 2))
assert.NoError(t, err)

err = db.Commit()
Expand Down Expand Up @@ -380,7 +382,7 @@ func TTestMetadata(t *testing.T, db driver.TransactionalVersionedPersistence) {

err = db.BeginUpdate()
assert.NoError(t, err)
err = db.SetStateMetadata(ns, key, map[string][]byte{"foo": []byte("bar")}, nil)
err = db.SetStateMetadata(ns, key, map[string][]byte{"foo": []byte("bar")}, ToBytes(35, 1))
assert.NoError(t, err)
err = db.Commit()
assert.NoError(t, err)
Expand All @@ -395,7 +397,7 @@ func TTestMetadata(t *testing.T, db driver.TransactionalVersionedPersistence) {

err = db.BeginUpdate()
assert.NoError(t, err)
err = db.SetStateMetadata(ns, key, map[string][]byte{"foo1": []byte("bar1")}, nil)
err = db.SetStateMetadata(ns, key, map[string][]byte{"foo1": []byte("bar1")}, ToBytes(36, 2))
assert.NoError(t, err)
err = db.Commit()
assert.NoError(t, err)
Expand Down Expand Up @@ -867,10 +869,13 @@ func TTestUnversionedRange(t *testing.T, db driver.UnversionedPersistence) {
res = append(res, *n)
}
assert.Len(t, res, 2)
assert.Equal(t, []driver.UnversionedRead{
expected := []driver.UnversionedRead{
{Key: "k1", Raw: []byte("k1_value")},
{Key: "k2", Raw: []byte("k2_value")},
}, res)
}
for _, read := range expected {
assert.Contains(t, res, read)
}
}

func TTestUnversionedSimple(t *testing.T, db driver.UnversionedPersistence) {
Expand Down

0 comments on commit dad6f06

Please sign in to comment.